summaryrefslogtreecommitdiffstats
path: root/lib/libncurses/lib_options.c
diff options
context:
space:
mode:
authorache <ache@FreeBSD.org>1998-06-19 16:12:41 +0000
committerache <ache@FreeBSD.org>1998-06-19 16:12:41 +0000
commitd3ff12efce40503105e4580a0d3213a8793a5e89 (patch)
tree80411ea65b6e08fc85c46cffbfbbe31c4b3763d6 /lib/libncurses/lib_options.c
parent2e210ceb513fc03627756d71376a8935f4a3744c (diff)
downloadFreeBSD-src-d3ff12efce40503105e4580a0d3213a8793a5e89.zip
FreeBSD-src-d3ff12efce40503105e4580a0d3213a8793a5e89.tar.gz
Fix keypad on/off for ^Z suspends by replacing reset_*_mode()
from libmytinfo
Diffstat (limited to 'lib/libncurses/lib_options.c')
-rw-r--r--lib/libncurses/lib_options.c41
1 files changed, 31 insertions, 10 deletions
diff --git a/lib/libncurses/lib_options.c b/lib/libncurses/lib_options.c
index df2449b..789ebc6 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);
+}
OpenPOWER on IntegriCloud