/****************************************************************************
- * Copyright 2018-2020,2021 Thomas E. Dickey *
+ * Copyright 2018-2021,2023 Thomas E. Dickey *
* Copyright 2002-2009,2011 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
#include <curses.priv.h>
-MODULE_ID("$Id: lib_get_wstr.c,v 1.20 2021/10/23 19:02:59 tom Exp $")
+MODULE_ID("$Id: lib_get_wstr.c,v 1.21 2023/04/29 19:02:03 tom Exp $")
static int
wadd_wint(WINDOW *win, wint_t *src)
{
SCREEN *sp = _nc_screen_of(win);
TTY buf;
- bool oldnl, oldecho, oldraw, oldcbreak;
+ TTY_FLAGS save_flags;
wchar_t erasec = 0;
wchar_t killc = 0;
wint_t *oldstr = str;
_nc_get_tty_mode(&buf);
- oldnl = sp->_nl;
- oldecho = sp->_echo;
- oldraw = sp->_raw;
- oldcbreak = sp->_cbreak;
+ save_flags = sp->_tty_flags;
NCURSES_SP_NAME(nl) (NCURSES_SP_ARG);
NCURSES_SP_NAME(noecho) (NCURSES_SP_ARG);
- NCURSES_SP_NAME(raw) (NCURSES_SP_ARG);
+ if (!save_flags._raw)
+ NCURSES_SP_NAME(cbreak) (NCURSES_SP_ARG);
NCURSES_SP_NAME(erasewchar) (NCURSES_SP_ARGx &erasec);
NCURSES_SP_NAME(killwchar) (NCURSES_SP_ARGx &killc);
* *getn_wstr() with \n should work either way.
*/
if (ch == KEY_DOWN || ch == KEY_ENTER) {
- if (oldecho == TRUE
+ if (save_flags._echo == TRUE
&& win->_cury == win->_maxy
&& win->_scroll)
wechochar(win, (chtype) '\n');
}
if (ch == KEY_LEFT || ch == KEY_BACKSPACE) {
if (tmpstr > oldstr) {
- tmpstr = WipeOut(win, y, x, oldstr, tmpstr, oldecho);
+ tmpstr = WipeOut(win, y, x, oldstr, tmpstr, save_flags._echo);
}
} else if (ch == KEY_EOL) {
while (tmpstr > oldstr) {
- tmpstr = WipeOut(win, y, x, oldstr, tmpstr, oldecho);
+ tmpstr = WipeOut(win, y, x, oldstr, tmpstr, save_flags._echo);
}
} else {
beep();
} else {
*tmpstr++ = ch;
*tmpstr = 0;
- if (oldecho == TRUE) {
+ if (save_flags._echo == TRUE) {
int oldy = win->_cury;
if (wadd_wint(win, tmpstr - 1) == ERR) {
*/
win->_flags &= ~_WRAPPED;
waddch(win, (chtype) ' ');
- tmpstr = WipeOut(win, y, x, oldstr, tmpstr, oldecho);
+ tmpstr = WipeOut(win, y, x, oldstr, tmpstr, save_flags._echo);
continue;
} else if (IS_WRAPPED(win)) {
/*
/* Restore with a single I/O call, to fix minor asymmetry between
* raw/noraw, etc.
*/
- sp->_nl = oldnl;
- sp->_echo = oldecho;
- sp->_raw = oldraw;
- sp->_cbreak = oldcbreak;
-
+ sp->_tty_flags = save_flags;
(void) _nc_set_tty_mode(&buf);
*tmpstr = 0;