]> ncurses.scripts.mit.edu Git - ncurses.git/blobdiff - ncurses/base/lib_getch.c
ncurses 5.6 - patch 20070421
[ncurses.git] / ncurses / base / lib_getch.c
index f8f3512d077439f88c86ac626f9ea9d7cd19e993..d8906daec63b7de903b3b82465e1c40a69bd813f 100644 (file)
@@ -1,5 +1,5 @@
 /****************************************************************************
 /****************************************************************************
- * Copyright (c) 1998-2005,2006 Free Software Foundation, Inc.              *
+ * Copyright (c) 1998-2006,2007 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            *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
  * copy of this software and associated documentation files (the            *
 
 #include <curses.priv.h>
 
 
 #include <curses.priv.h>
 
-MODULE_ID("$Id: lib_getch.c,v 1.76 2006/12/30 16:03:27 tom Exp $")
+MODULE_ID("$Id: lib_getch.c,v 1.79 2007/04/19 20:57:49 tom Exp $")
 
 #include <fifo_defs.h>
 
 
 #include <fifo_defs.h>
 
+#if USE_REENTRANT
+NCURSES_EXPORT(int)
+NCURSES_PUBLIC_VAR(ESCDELAY) (void)
+{
+    return SP ? SP->_ESCDELAY : 1000;
+}
+#else
 NCURSES_EXPORT_VAR(int)
 ESCDELAY = 1000;               /* max interval betw. chars in funkeys, in millisecs */
 NCURSES_EXPORT_VAR(int)
 ESCDELAY = 1000;               /* max interval betw. chars in funkeys, in millisecs */
+#endif
 
 #ifdef NCURSES_WGETCH_EVENTS
 #define TWAIT_MASK 7
 
 #ifdef NCURSES_WGETCH_EVENTS
 #define TWAIT_MASK 7
@@ -234,15 +242,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 +290,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 +325,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)
@@ -384,7 +391,7 @@ _nc_wgetch(WINDOW *win,
 
     if (ch == ERR) {
 #if USE_SIZECHANGE
 
     if (ch == ERR) {
 #if USE_SIZECHANGE
-       if (SP->_sig_winch) {
+       if (_nc_handle_sigwinch(FALSE)) {
            _nc_update_screensize();
            /* resizeterm can push KEY_RESIZE */
            if (cooked_key_in_fifo()) {
            _nc_update_screensize();
            /* resizeterm can push KEY_RESIZE */
            if (cooked_key_in_fifo()) {