#include
#include
#include
#define StartX 2
#define StartY 2
void initial()
{
initscr();
cbreak();
nonl();
noecho();
intrflush(stdscr,FALSE);
keypad(stdscr,TRUE);
refresh();
}
main()
{
int x=StartX;
int y=StartY;
int ch;
initial();
box(stdscr,'|','-');
attron(A_REVERSE);
mvaddstr(0,20,"编辑器");
attroff(A_REVERSE);
/*
mvaddstr(2,10,"姓名:");
attron(A_UNDERLINE);
mvaddstr(2,15,"");
attroff(A_UNDERLINE);
mvaddstr(3,10,"密码:");
attron(A_UNDERLINE);
mvaddstr(3,15,"");
attroff(A_UNDERLINE);
*/
move(x,y);
do{
ch=getch();
switch(ch)
{
case KEY_UP:
--y;
break;
case KEY_DOWN:
++y;
break;
case KEY_RIGHT:
++x;
break;
case KEY_LEFT:
--x;
break;
case '\r':
++y;
x=2;
break;
case '\t':
x+=7;
break;
case 127:
mvaddch(y,--x,' ');
break;
case 27:
endwin();
exit(1);
default:
addch(ch);
x++;
break;
}
move(y,x);
}while(1);
}
阅读(576) | 评论(0) | 转发(0) |