vi 편집기 비슷하게 만들어 보던중 ~

NamSa의 이미지

vi 편집기 비슷하게 만들어보던중.. 색깔문제 이후로 ~~
커서 이동의 관문 에 막혓습니다..
편집모드만 구현 해볼생각인데 ..
커서이동이 난감하네요.. 좌우로는 그냥되는데 ..
위아레로는 어케 구현을해야할지. .~~
c를 시작한지 얼마안되어서 .. 소스가 엉망이네요~

Quote:

#include <stdio.h>
#include <string.h>
main(int argc, char *argv[])
{

static char *__tty_color[] = {
"\033[0;40;30m", /* 0 black on black */
"\033[0;40;31m", /* 1 red */
"\033[0;40;32m", /* 2 green */
"\033[0;40;33m", /* 3 brown */
"\033[0;40;34m", /* 4 blue */
"\033[0;40;35m", /* 5 magenta */
"\033[0;40;36m", /* 6 cyan */
"\033[0;40;37m", /* 7 light gray */
"\033[1;40;30m", /* 0 gray */
"\033[1;40;31m", /* 1 brightred */
"\033[1;40;32m", /* 2 brightgreen */
"\033[1;40;33m", /* 3 yellow */
"\033[1;40;34m", /* 4 brightblue */
"\033[1;40;35m", /* 5 brighmagenta */
"\033[1;40;36m", /* 6 brightcyan */
"\033[1;40;37m", /* 7 white */
};

FILE *fpin;
char s[256];
char a[256];
int ch;
int i=1;

if(argc != 2) {
fprintf(stderr, "input err! ex) read_file <filename>\n");
exit(1);
}
if((fpin = fopen(argv[1],"a+")) ==NULL){
fprintf(stderr, "file not read.\n");
exit(1);
}
printf("inset text (end is inset text exit)\n");
while((ch = fgetc(fpin)) !=EOF)
{
fgets(s,255,fpin);
printf("%s%4d %s%s",__tty_color[11],i,__tty_color[7],s);
i++;
}
while(1)
{

printf("%s%4d%s ",__tty_color[11],i,__tty_color[7]);
i++;
scanf("%s",a);
fprintf(fpin,"%s\n",a);
if(!(strcmp(a,"exit")))
{
printf("edit end%s\n",__tty_color[7]);
break;
}
}
fclose(fpin);
}

보시던중. 이상한 곳이 있을경우 많은..
지적을 부탁드립니다~~

noohgnas의 이미지

ncurses 라는 라이브러리를 한번 사용해 보세요.. =)

http://www.gnu.org/directory/libs/ncurses.html


----
I think, therefore I am.

NamSa의 이미지

한글 메뉴얼은 없나요...
영어도 보려고는 .. 애를 쓰지만 아직 실력이
않되네요 ㅠ,ㅜ c실력이 뛰어난것도 아니고~

NamSa의 이미지

http://www.joinc.co.kr/modules.php?name=News&file=article&sid=47

구글에서 검색해서.. 찻았습니다..
노력도 안하고 얻으려 하는 저의 불찰이었습니다..
반성~~ 반성~~

댓글 달기

Filtered HTML

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

BBCode

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param>
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

Textile

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • You can use Textile markup to format text.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Markdown

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • Quick Tips:
    • Two or more spaces at a line's end = Line break
    • Double returns = Paragraph
    • *Single asterisks* or _single underscores_ = Emphasis
    • **Double** or __double__ = Strong
    • This is [a link](http://the.link.example.com "The optional title text")
    For complete details on the Markdown syntax, see the Markdown documentation and Markdown Extra documentation for tables, footnotes, and more.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Plain text

  • HTML 태그를 사용할 수 없습니다.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 줄과 단락은 자동으로 분리됩니다.
댓글 첨부 파일
이 댓글에 이미지나 파일을 업로드 합니다.
파일 크기는 8 MB보다 작아야 합니다.
허용할 파일 형식: txt pdf doc xls gif jpg jpeg mp3 png rar zip.
CAPTCHA
이것은 자동으로 스팸을 올리는 것을 막기 위해서 제공됩니다.