?? 實例11-8.c
字號:
#include <curses.h>
#include <stdlib.h>
#include <ctype.h>
int main(int argc,char*argv[])
{
WINDOW *win;
int ch;
int w=40,h=10;
int curx=10,cury=5;
if(initscr()== NULL) { /*初始化*/
perror("initcurs");
exit(EXIT_FAILURE);
}
/*設置模式*/
cbreak();
noecho();
keypad(stdscr,TRUE);
win=newwin(h,w,3,20); /*建立窗口*/
box(win,0,0);
keypad(win,TRUE);
wmove(win,cury,curx);
mvaddstr(16,1,"Press arrowkeys to move the cursor with in the WINDOW.\n");
mvaddstr(17,1,"Press 'q' to quit.\ n");
refresh();
wrefresh(win);
for(;;) {/*獲得輸入*/
ch=wgetch(win);
if(ch=='q') break;
if(ch==KEY_UP) {
if(cury>1) cury--; }
else if(ch==KEY_DOWN){if(cury<h-2)cury++;}
else if(ch==KEY_LEFT){if(curx>1)curx--;}
else if(ch==KEY_RIGHT){if(curx<w-2)curx++;}
wmove(win,cury,curx);
mvprintw(20,1,"Input Key:%s\n",keyname(ch));
refresh();
}
delwin(win);
endwin();
exit(0);
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -