📄 实例11-9.c
字号:
#include <curses.h>
#include <stdio.h>
#define StartX 1
#define StartY 1
void initial();
main()
{
int x=StartX;
int y=StartY;
int ch;
initial();
box(stdscr,'|','-');
attron(A_REVERSE);
mvaddstr(0,20,"Curses Program");
attroff(A_REVERSE);
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=0;
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);
}
void initial()
{
initscr();
cbreak();
nonl();
noecho();
intrflush(stdscr,FALSE);
keypad(stdscr,TRUE);
refresh();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -