summaryrefslogtreecommitdiffstats
path: root/lib/libncurses
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
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')
-rw-r--r--lib/libncurses/curses.priv.h1
-rw-r--r--lib/libncurses/lib_kernel.c36
-rw-r--r--lib/libncurses/lib_options.c41
3 files changed, 53 insertions, 25 deletions
diff --git a/lib/libncurses/curses.priv.h b/lib/libncurses/curses.priv.h
index 73e3d7d..6733ce0 100644
--- a/lib/libncurses/curses.priv.h
+++ b/lib/libncurses/curses.priv.h
@@ -64,6 +64,7 @@ extern WINDOW *makenew(int, int, int, int);
extern int timed_wait(int fd, int wait, int *timeleft);
extern chtype _nc_background(WINDOW *);
extern chtype _nc_render(WINDOW *, chtype);
+extern int _nc_keypad(bool);
extern void _nc_scroll_window(WINDOW *, int, short const, short const, chtype);
struct try {
diff --git a/lib/libncurses/lib_kernel.c b/lib/libncurses/lib_kernel.c
index 534f6f0..2cc71da 100644
--- a/lib/libncurses/lib_kernel.c
+++ b/lib/libncurses/lib_kernel.c
@@ -55,34 +55,40 @@ int wattroff(WINDOW *win, chtype at)
return OK;
}
-#ifndef MYTINFO
int reset_prog_mode()
{
- T(("reset_prog_mode() called"));
+ int ret = ERR;
-#ifdef TERMIOS
- tcsetattr(cur_term->Filedes, TCSANOW, &cur_term->Nttyb);
-#else
- stty(cur_term->Filedes, &cur_term->Nttyb);
-#endif
+ T(("reset_prog_mode() called"));
- return OK;
+ if (cur_term != 0) {
+ if (tcsetattr(cur_term->fd, TCSADRAIN, &cur_term->prog_mode)==0)
+ ret = OK;
+ if (SP && stdscr && stdscr->_use_keypad)
+ _nc_keypad(TRUE);
+ }
+ return ret;
}
int reset_shell_mode()
{
+ int ret = ERR;
+
T(("reset_shell_mode() called"));
-#ifdef TERMIOS
- tcsetattr(cur_term->Filedes, TCSANOW, &cur_term->Ottyb);
-#else
- stty(cur_term->Filedes, &cur_term->Ottyb);
-#endif
+ if (cur_term != 0) {
+ if (SP)
+ {
+ fflush(SP->_ofp);
+ _nc_keypad(FALSE);
+ }
+ if (tcsetattr(cur_term->fd, TCSADRAIN, &cur_term->shell_mode)==0)
+ ret = OK;
+ }
- return OK;
+ return ret;
}
-#endif
int curs_set(int vis)
{
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