ncurses- KEY_ENTER is fail

前端 未结 4 1329
灰色年华
灰色年华 2020-12-20 13:56

I\'ve been trying to teach myself ncurses and I\'m loving it so far. However, I\'m trying to write a small little text editor like pico or nano. I\'ve got it set up fairly

4条回答
  •  我在风中等你
    2020-12-20 15:02

    I got the same KEY_ENTER problem recently, and I fixed it by replacing KEY_ENTER with 10 or \n, which is ASCII new line.

    #include 
    int main() {
        initscr();  /* init ncurses */
        keypad(stdscr, TRUE);   /* get keyboard input */
        addstr("Press enter to exit.\n");
        while (10 != getch()) {}    /* 10 == enter */
        endwin();   /* end ncurses */
        return 0;
    }
    

提交回复
热议问题