]> ncurses.scripts.mit.edu Git - ncurses.git/blobdiff - ncurses/base/lib_getstr.c
ncurses 5.7 - patch 20090221
[ncurses.git] / ncurses / base / lib_getstr.c
index 761703824496e49130faac7de64d466425350035..b17df03d2a416bce2ccd98c8cda2c153ec92f990 100644 (file)
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright (c) 1998-2000,2002 Free Software Foundation, Inc.              *
+ * Copyright (c) 1998-2006,2008 Free Software Foundation, Inc.              *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
  * copy of this software and associated documentation files (the            *
@@ -41,7 +41,7 @@
 #include <curses.priv.h>
 #include <term.h>
 
-MODULE_ID("$Id: lib_getstr.c,v 1.24 2002/09/01 17:31:12 tom Exp $")
+MODULE_ID("$Id: lib_getstr.c,v 1.27 2008/08/16 19:20:04 tom Exp $")
 
 /*
  * This wipes out the last character, no matter whether it was a tab, control
@@ -75,6 +75,7 @@ wgetnstr_events(WINDOW *win,
                int maxlen,
                EVENTLIST_1st(_nc_eventlist * evl))
 {
+    SCREEN *sp = _nc_screen_of(win);
     TTY buf;
     bool oldnl, oldecho, oldraw, oldcbreak;
     char erasec;
@@ -90,10 +91,10 @@ wgetnstr_events(WINDOW *win,
 
     _nc_get_tty_mode(&buf);
 
-    oldnl = SP->_nl;
-    oldecho = SP->_echo;
-    oldraw = SP->_raw;
-    oldcbreak = SP->_cbreak;
+    oldnl = sp->_nl;
+    oldecho = sp->_echo;
+    oldraw = sp->_raw;
+    oldcbreak = sp->_cbreak;
     nl();
     noecho();
     noraw();
@@ -128,6 +129,10 @@ wgetnstr_events(WINDOW *win,
 #ifdef KEY_EVENT
        if (ch == KEY_EVENT)
            break;
+#endif
+#ifdef KEY_RESIZE
+       if (ch == KEY_RESIZE)
+           break;
 #endif
        if (ch == erasec || ch == KEY_LEFT || ch == KEY_BACKSPACE) {
            if (str > oldstr) {
@@ -141,7 +146,7 @@ wgetnstr_events(WINDOW *win,
                   || (maxlen >= 0 && str - oldstr >= maxlen)) {
            beep();
        } else {
-           *str++ = ch;
+           *str++ = (char) ch;
            if (oldecho == TRUE) {
                int oldy = win->_cury;
                if (waddch(win, (chtype) ch) == ERR) {
@@ -183,22 +188,27 @@ wgetnstr_events(WINDOW *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->_nl = oldnl;
+    sp->_echo = oldecho;
+    sp->_raw = oldraw;
+    sp->_cbreak = oldcbreak;
 
     _nc_set_tty_mode(&buf);
 
     *str = '\0';
     if (ch == ERR)
        returnCode(ch);
+
+    T(("wgetnstr returns %s", _nc_visbuf(oldstr)));
+
 #ifdef KEY_EVENT
     if (ch == KEY_EVENT)
        returnCode(ch);
 #endif
-
-    T(("wgetnstr returns %s", _nc_visbuf(oldstr)));
+#ifdef KEY_RESIZE
+    if (ch == KEY_RESIZE)
+       returnCode(ch);
+#endif
 
     returnCode(OK);
 }