]> ncurses.scripts.mit.edu Git - ncurses.git/blobdiff - ncurses/base/lib_getch.c
ncurses 5.7 - patch 20100206
[ncurses.git] / ncurses / base / lib_getch.c
index 8609a90659ee42246f0cf721ae254b023b3b7284..e3e4075f742ed40950812362c61f47f10fe04cc4 100644 (file)
@@ -42,7 +42,7 @@
 
 #include <curses.priv.h>
 
-MODULE_ID("$Id: lib_getch.c,v 1.106 2009/07/25 17:02:03 tom Exp $")
+MODULE_ID("$Id: lib_getch.c,v 1.110 2010/02/06 18:39:16 tom Exp $")
 
 #include <fifo_defs.h>
 
@@ -110,9 +110,9 @@ NCURSES_SP_NAME(get_escdelay) (NCURSES_SP_DCL0)
 
 #if NCURSES_SP_FUNCS
 NCURSES_EXPORT(int)
-get_escdelay (void)
+get_escdelay(void)
 {
-    return NCURSES_SP_NAME(get_escdelay)(CURRENT_SCREEN);
+    return NCURSES_SP_NAME(get_escdelay) (CURRENT_SCREEN);
 }
 #endif
 #endif /* NCURSES_EXT_FUNCS */
@@ -256,6 +256,14 @@ fifo_push(SCREEN *sp EVENTLIST_2nd(_nc_eventlist * evl))
        ch = KEY_MOUSE;
        n = 1;
     } else
+#endif
+#ifdef USE_TERM_DRIVER
+       if ((sp->_mouse_type == M_TERM_DRIVER)
+           && (sp->_drv_mouse_head < sp->_drv_mouse_tail)) {
+       sp->_mouse_event(sp);
+       ch = KEY_MOUSE;
+       n = 1;
+    } else
 #endif
     {                          /* Can block... */
 #ifdef USE_TERM_DRIVER
@@ -380,7 +388,7 @@ _nc_wgetch(WINDOW *win,
     long event_delay = -1;
 #endif
 
-    T((T_CALLED("_nc_wgetch(%p)"), win));
+    T((T_CALLED("_nc_wgetch(%p)"), (void *) win));
 
     *result = 0;
 
@@ -467,7 +475,7 @@ _nc_wgetch(WINDOW *win,
            }
 #endif
            if (!rc) {
-               returnCode(ERR);
+               goto check_sigwinch;
            }
        }
        /* else go on to read data available */
@@ -529,12 +537,19 @@ _nc_wgetch(WINDOW *win,
     }
 
     if (ch == ERR) {
+      check_sigwinch:
 #if USE_SIZECHANGE
        if (_nc_handle_sigwinch(sp)) {
            _nc_update_screensize(sp);
            /* resizeterm can push KEY_RESIZE */
            if (cooked_key_in_fifo()) {
                *result = fifo_pull(sp);
+               /*
+                * Get the ERR from queue -- it is from WINCH,
+                * so we should take it out, the "error" is handled.
+                */
+               if (fifo_peek(sp) == -1)
+                   fifo_pull(sp);
                returnCode(*result >= KEY_MIN ? KEY_CODE_YES : OK);
            }
        }
@@ -611,7 +626,7 @@ wgetch(WINDOW *win)
     int code;
     unsigned long value;
 
-    T((T_CALLED("wgetch(%p)"), win));
+    T((T_CALLED("wgetch(%p)"), (void *) win));
     code = _nc_wgetch(win,
                      &value,
                      _nc_use_meta(win)
@@ -685,7 +700,7 @@ kgetch(SCREEN *sp EVENTLIST_2nd(_nc_eventlist * evl))
            break;
        }
        TR(TRACE_IEVENT, ("ptr=%p, ch=%d, value=%d",
-                         ptr, ptr->ch, ptr->value));
+                         (void *) ptr, ptr->ch, ptr->value));
 
        if (ptr->value != 0) {  /* sequence terminated */
            TR(TRACE_IEVENT, ("end of sequence"));