diff options
| author | Andrey A. Chernov <ache@FreeBSD.org> | 1998-06-19 16:12:41 +0000 |
|---|---|---|
| committer | Andrey A. Chernov <ache@FreeBSD.org> | 1998-06-19 16:12:41 +0000 |
| commit | 2ed2c53bd8ebdac8bb8a43a99a0877ad326c5418 (patch) | |
| tree | bb19781e96e961a3a799ad823d8250786c2c9f8f /lib/libncurses/lib_options.c | |
| parent | 7bc8e898409f62bdf6d96cc6665ea9f72ac6a031 (diff) | |
Notes
Diffstat (limited to 'lib/libncurses/lib_options.c')
| -rw-r--r-- | lib/libncurses/lib_options.c | 41 |
1 files changed, 31 insertions, 10 deletions
diff --git a/lib/libncurses/lib_options.c b/lib/libncurses/lib_options.c index df2449bbce8d..789ebc62a303 100644 --- a/lib/libncurses/lib_options.c +++ b/lib/libncurses/lib_options.c @@ -108,16 +108,12 @@ int keypad(WINDOW *win, int flag) { T(("keypad(%x,%d) called", win, flag)); - win->_use_keypad = flag; - - if (flag && keypad_xmit) - putp(keypad_xmit); - else if (! flag && keypad_local) - putp(keypad_local); - - if (SP->_keytry == UNINITIALISED) - init_keytry(); - return OK; + if (win) { + win->_use_keypad = flag; + return _nc_keypad(flag); + } + else + return ERR; } @@ -250,3 +246,28 @@ int intrflush(WINDOW *win, bool flag) T(("intrflush(%x, %d) called", win, flag)); return OK; } + +/* Turn the keypad on/off + * + * Note: we flush the output because changing this mode causes some terminals + * to emit different escape sequences for cursor and keypad keys. If we don't + * flush, then the next wgetch may get the escape sequence that corresponds to + * the terminal state _before_ switching modes. + */ +int _nc_keypad(bool flag) +{ + if (flag && keypad_xmit) + { + putp(keypad_xmit); + (void) fflush(SP->_ofp); + } + else if (! flag && keypad_local) + { + putp(keypad_local); + (void) fflush(SP->_ofp); + } + + if (SP->_keytry == UNINITIALISED) + init_keytry(); + return(OK); +} |
