Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/155.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/c/69.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ NCurses–;getstr()和函数键_C++_C_Ncurses - Fatal编程技术网

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);
}