]> ncurses.scripts.mit.edu Git - ncurses.git/blobdiff - ncurses/base/lib_getch.c
ncurses 5.6 - patch 20070224
[ncurses.git] / ncurses / base / lib_getch.c
index 7891edf3b079fdd61d551db1198c5b31c341c841..e66602c28ce1c60fc8df896a626eaa82b65a7c66 100644 (file)
@@ -41,7 +41,7 @@
 
 #include <curses.priv.h>
 
 
 #include <curses.priv.h>
 
-MODULE_ID("$Id: lib_getch.c,v 1.75 2006/03/04 20:06:09 tom Exp $")
+MODULE_ID("$Id: lib_getch.c,v 1.77 2007/02/25 00:43:54 tom Exp $")
 
 #include <fifo_defs.h>
 
 
 #include <fifo_defs.h>
 
@@ -234,15 +234,16 @@ _nc_wgetch(WINDOW *win,
     T((T_CALLED("_nc_wgetch(%p)"), win));
 
     *result = 0;
     T((T_CALLED("_nc_wgetch(%p)"), win));
 
     *result = 0;
-    if (win == 0 || SP == 0)
+    if (win == 0 || SP == 0) {
        returnCode(ERR);
        returnCode(ERR);
+    }
 
     if (cooked_key_in_fifo()) {
        if (wgetch_should_refresh(win))
            wrefresh(win);
 
        *result = fifo_pull();
 
     if (cooked_key_in_fifo()) {
        if (wgetch_should_refresh(win))
            wrefresh(win);
 
        *result = fifo_pull();
-       returnCode(OK);
+       returnCode(*result >= KEY_MIN ? KEY_CODE_YES : OK);
     }
 #ifdef NCURSES_WGETCH_EVENTS
     if (evl && (evl->count == 0))
     }
 #ifdef NCURSES_WGETCH_EVENTS
     if (evl && (evl->count == 0))
@@ -281,12 +282,10 @@ _nc_wgetch(WINDOW *win,
        /* Return it first */
        if (rc == KEY_EVENT) {
            *result = rc;
        /* Return it first */
        if (rc == KEY_EVENT) {
            *result = rc;
-           returnCode(OK);
-       }
+       } else
 #endif
 #endif
-
-       *result = fifo_pull();
-       returnCode(OK);
+           *result = fifo_pull();
+       returnCode(*result >= KEY_MIN ? KEY_CODE_YES : OK);
     }
 
     if (win->_use_keypad != SP->_keypad_on)
     }
 
     if (win->_use_keypad != SP->_keypad_on)
@@ -318,7 +317,7 @@ _nc_wgetch(WINDOW *win,
 #ifdef NCURSES_WGETCH_EVENTS
            if (rc & 4) {
                *result = KEY_EVENT;
 #ifdef NCURSES_WGETCH_EVENTS
            if (rc & 4) {
                *result = KEY_EVENT;
-               returnCode(OK);
+               returnCode(KEY_CODE_YES);
            }
 #endif
            if (!rc)
            }
 #endif
            if (!rc)
@@ -493,7 +492,7 @@ wgetch(WINDOW *win)
 static int
 kgetch(EVENTLIST_0th(_nc_eventlist * evl))
 {
 static int
 kgetch(EVENTLIST_0th(_nc_eventlist * evl))
 {
-    struct tries *ptr;
+    TRIES *ptr;
     int ch = 0;
     int timeleft = ESCDELAY;
 
     int ch = 0;
     int timeleft = ESCDELAY;