C++ NCurses–;getstr()和函数键
我的处境:C++ NCurses–;getstr()和函数键,c++,c,ncurses,C++,C,Ncurses,我的处境: 在ncurses模式下我有一个窗口contentWin 从这个窗口,我想通过这个代码读取“字符串” 我希望能在这一刻抓住F2键。我考虑catch字符,然后比较,然后(如果!=F2)将其放入终端并str,而不使用wgetnstr() 有不同(更简单)的方法吗?谢谢:-)。据我所知不是这样。您可能希望创建自己的函数,该函数类似于执行F2等检查的wgetnstr() 您可以根据以下捕获F2的代码来创建函数 #include <ncurses.h> int main()
- 在ncurses模式下我有一个窗口contentWin
- 从这个窗口,我想通过这个代码读取“字符串”
我希望能在这一刻抓住F2键。我考虑catch字符,然后比较,然后(如果!=F2)将其放入终端并str,而不使用wgetnstr()
有不同(更简单)的方法吗?谢谢:-)。据我所知不是这样。您可能希望创建自己的函数,该函数类似于执行F2等检查的
wgetnstr()
您可以根据以下捕获F2的代码来创建函数
#include <ncurses.h>
int main()
{
int ch;
initscr(); /* Start curses mode */
raw(); /* Line buffering disabled */
keypad(stdscr, TRUE); /* We get F1, F2 etc.. */
noecho(); /* Don't echo() while we do getch */
while( (ch = wgetch(stdscr) ) != KEY_F(2))
{
printw("Key code: %u Key: %c\n", ch, ch);
refresh(); /* Print it on to the real screen */
}
endwin(); /* End curses mode */
printf("F2 pressed .. program exiting\n");
return(0);
}
#包括
int main()
{
int-ch;
initscr();/*开始诅咒模式*/
raw();/*已禁用行缓冲*/
键盘(stdscr,TRUE);/*我们得到F1、F2等*/
noecho();/*在我们做getch时不要回显()*/
而((ch=wgetch(stdscr))!=KEY_F(2))
{
printw(“密钥代码:%u密钥:%c\n”,ch,ch);
刷新();/*将其打印到真实屏幕上*/
}
endwin();/*结束诅咒模式*/
printf(“按F2键..程序退出\n”);
返回(0);
}
#include <ncurses.h>
int main()
{
int ch;
initscr(); /* Start curses mode */
raw(); /* Line buffering disabled */
keypad(stdscr, TRUE); /* We get F1, F2 etc.. */
noecho(); /* Don't echo() while we do getch */
while( (ch = wgetch(stdscr) ) != KEY_F(2))
{
printw("Key code: %u Key: %c\n", ch, ch);
refresh(); /* Print it on to the real screen */
}
endwin(); /* End curses mode */
printf("F2 pressed .. program exiting\n");
return(0);
}