Fix keypad on/off for ^Z suspends by replacing reset_*_mode()
from libmytinfo
This commit is contained in:
parent
7bc8e89840
commit
2ed2c53bd8
@ -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 {
|
||||
|
@ -55,34 +55,40 @@ int wattroff(WINDOW *win, chtype at)
|
||||
return OK;
|
||||
}
|
||||
|
||||
#ifndef MYTINFO
|
||||
int reset_prog_mode()
|
||||
{
|
||||
int ret = ERR;
|
||||
|
||||
T(("reset_prog_mode() called"));
|
||||
|
||||
#ifdef TERMIOS
|
||||
tcsetattr(cur_term->Filedes, TCSANOW, &cur_term->Nttyb);
|
||||
#else
|
||||
stty(cur_term->Filedes, &cur_term->Nttyb);
|
||||
#endif
|
||||
|
||||
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)
|
||||
{
|
||||
|
@ -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);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user