ncurses to external shell and back messing with keys

后端 未结 2 516
梦如初夏
梦如初夏 2021-01-13 09:21

I have this ncurses application that is doing the standard recipe for temporarily dropping out of ncurses, running an external editor/shell/whatever, and then dropping back

2条回答
  •  一整个雨季
    2021-01-13 09:48

    Yeah. Without keypad ncurses won't handle escape codes for you. From the keypad man page:

       The keypad option enables the keypad of the user's  terminal.   If  en-
       abled (bf is TRUE), the user can press a function key (such as an arrow
       key) and wgetch returns a single value representing the  function  key,
       as in KEY_LEFT.  If disabled (bf is FALSE), curses does not treat func-
       tion keys specially and the program has to  interpret  the  escape  se-
       quences  itself.   If the keypad in the terminal can be turned on (made
       to transmit) and off (made to work locally),  turning  on  this  option
       causes  the terminal keypad to be turned on when wgetch is called.  The
       default value for keypad is false.
    

    Often, the first thing I do in an ncurses program is call keypad(stdscr, true) to enable nice keyboard mapping.

    Hope that helps.

提交回复
热议问题