LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
查看: 752|回复: 4

curses怎样从终端接受组合键(alt+..)

[复制链接]
发表于 2004-6-4 21:01:47 | 显示全部楼层 |阅读模式
如提
发表于 2004-6-4 22:33:25 | 显示全部楼层
这个问题我记得以前讨论过,alt+x等于连续输入了两个字符,第一个是27(Esc键),第二个是x键,和先按Esc再按x是一样的。
写个小程序验证一下:

  1. #include <curses.h>

  2. int
  3. main(void)
  4. {
  5.   int c;
  6.   initscr();
  7.   keypad(stdscr, TRUE);
  8.   cbreak();
  9.   noecho();
  10.   while((c = getch()) != 'q'){
  11.     printw("input is %d: %c. ", c, c);
  12.     refresh();
  13.   }
  14.   endwin();
  15.   exit(0);
  16. }
复制代码
发表于 2004-6-19 19:50:15 | 显示全部楼层

libinary版主,这个怎么解决啊

[root@dishui program]# gcc -o test test.c
/tmp/ccoGcGaw.o(.text+0x11): In function `main':
: undefined reference to `initscr'
/tmp/ccoGcGaw.o(.text+0x1c): In function `main':
: undefined reference to `stdscr'
/tmp/ccoGcGaw.o(.text+0x21): In function `main':
: undefined reference to `keypad'
/tmp/ccoGcGaw.o(.text+0x29): In function `main':
: undefined reference to `cbreak'
/tmp/ccoGcGaw.o(.text+0x2e): In function `main':
: undefined reference to `noecho'
/tmp/ccoGcGaw.o(.text+0x37): In function `main':
: undefined reference to `stdscr'
/tmp/ccoGcGaw.o(.text+0x3c): In function `main':
: undefined reference to `wgetch'
/tmp/ccoGcGaw.o(.text+0x5d): In function `main':
: undefined reference to `printw'
/tmp/ccoGcGaw.o(.text+0x69): In function `main':
: undefined reference to `stdscr'
/tmp/ccoGcGaw.o(.text+0x6e): In function `main':
: undefined reference to `wrefresh'
/tmp/ccoGcGaw.o(.text+0x78): In function `main':
: undefined reference to `endwin'
collect2: ld returned 1 exit status
发表于 2004-6-19 19:51:34 | 显示全部楼层
另外,请问对curse的编程有什么好的资料介绍,谢谢!
发表于 2004-6-20 20:10:56 | 显示全部楼层
编译时加上-lcurses。
要找资料就用google搜索,不要怕看看英文。这个仅供参考,不过我怀疑你看了之后还是不知道怎么用。
http://www.fanqiang.com/a4/b2/20020626/060200258.html
您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表