2 /* This work is copyrighted. See COPYRIGHT.OLD & COPYRIGHT.NEW for *
3 * details. If they are missing then this copy is in violation of *
4 * the copyright conditions. */
9 ** The routine wgetstr().
13 #include "curses.priv.h"
16 inline void backspace(WINDOW *win)
18 mvwaddstr(curscr, win->_begy + win->_cury, win->_begx + win->_curx,
20 waddstr(win, "\b \b");
21 fputs("\b \b", SP->_ofp);
26 int wgetnstr(WINDOW *win, char *str, int maxlen)
28 bool oldnl, oldecho, oldraw, oldcbreak, oldkeypad;
34 T(("wgetnstr(%x,%x, %d) called", win, str, maxlen));
39 oldcbreak = SP->_cbreak;
40 oldkeypad = win->_use_keypad;
53 if (is_wintouched(win) || (win->_flags & _HASMOVED))
56 while ((ch = wgetch(win)) != ERR) {
57 if (ch == '\n' || ch == '\r')
59 if (ch == erasec || ch == KEY_LEFT || ch == KEY_BACKSPACE) {
64 } else if (ch == killc) {
65 while (str > oldstr) {
69 } else if (maxlen >= 0 && str - oldstr >= maxlen) {
72 mvwaddstr(curscr, win->_begy + win->_cury,
73 win->_begx + win->_curx, unctrl(ch));
74 waddstr(win, unctrl(ch));
75 if (oldecho == TRUE) {
76 fputs(unctrl(ch), SP->_ofp);
85 if (win->_cury < win->_maxy)
98 if (oldcbreak == FALSE)
101 if (oldkeypad == FALSE)
110 T(("wgetnstr returns \"%s\"", visbuf(oldstr)));