ncurses 5.7 - patch 20090704
[ncurses.git] / ncurses / base / lib_getch.c
index e228355a019ea38a9bd1aaac92a471a0698ff4f9..ccfcc33656df68410e60deb7775c90738ebdadef 100644 (file)
 
 #include <curses.priv.h>
 
-MODULE_ID("$Id: lib_getch.c,v 1.103 2009/05/30 15:50:47 tom Exp $")
+MODULE_ID("$Id: lib_getch.c,v 1.104 2009/07/04 20:41:13 tom Exp $")
 
 #include <fifo_defs.h>
 
 #if USE_REENTRANT
-#define GetEscdelay(sp) (sp)->_ESCDELAY
+#define GetEscdelay(sp) *_nc_ptr_Escdelay(sp)
 NCURSES_EXPORT(int *)
 _nc_ptr_Escdelay(SCREEN *sp)
 {
@@ -56,7 +56,7 @@ _nc_ptr_Escdelay(SCREEN *sp)
 NCURSES_EXPORT(int)
 NCURSES_PUBLIC_VAR(ESCDELAY) (void)
 {
-    return *_nc_ptr_Escdelay(CURRENT_SCREEN);
+    return *(_nc_ptr_Escdelay(CURRENT_SCREEN));
 }
 #else
 #define GetEscdelay(sp) ESCDELAY
@@ -71,7 +71,7 @@ NCURSES_SP_NAME(set_escdelay) (NCURSES_SP_DCLx int value)
     int code = OK;
 #if USE_REENTRANT
     if (SP_PARM) {
-       SP_PARM->_ESCDELAY = value;
+       SET_ESCDELAY(value);
     } else {
        code = ERR;
     }
@@ -86,7 +86,33 @@ NCURSES_SP_NAME(set_escdelay) (NCURSES_SP_DCLx int value)
 NCURSES_EXPORT(int)
 set_escdelay(int value)
 {
-    return NCURSES_SP_NAME(set_escdelay) (CURRENT_SCREEN, value);
+    int code;
+#if USE_REENTRANT
+    code = NCURSES_SP_NAME(set_escdelay) (CURRENT_SCREEN, value);
+#else
+    ESCDELAY = value;
+    code = OK;
+#endif
+    return code;
+}
+#endif
+#endif /* NCURSES_EXT_FUNCS */
+
+#if NCURSES_EXT_FUNCS
+NCURSES_EXPORT(int)
+NCURSES_SP_NAME(get_escdelay) (NCURSES_SP_DCL0)
+{
+#if !USE_REENTRANT
+    (void) SP_PARM;
+#endif
+    return GetEscdelay(SP_PARM);
+}
+
+#if NCURSES_SP_FUNCS
+NCURSES_EXPORT(int)
+get_escdelay (void)
+{
+    return NCURSES_SP_NAME(get_escdelay)(CURRENT_SCREEN);
 }
 #endif
 #endif /* NCURSES_EXT_FUNCS */
@@ -115,10 +141,22 @@ check_mouse_activity(SCREEN *sp, int delay EVENTLIST_2nd(_nc_eventlist * evl))
 #if USE_SYSMOUSE
     if ((sp->_mouse_type == M_SYSMOUSE)
        && (sp->_sysmouse_head < sp->_sysmouse_tail)) {
-       return 2;
+       return TW_MOUSE;
     }
 #endif
-    rc = _nc_timed_wait(sp, TWAIT_MASK, delay, (int *) 0 EVENTLIST_2nd(evl));
+#ifdef USE_TERM_DRIVER
+    rc = TCBOf(sp)->drv->twait(TCBOf(sp),
+                              TWAIT_MASK,
+                              delay,
+                              (int *) 0
+                              EVENTLIST_2nd(evl));
+#else
+    rc = _nc_timed_wait(sp,
+                       TWAIT_MASK,
+                       delay,
+                       (int *) 0
+                       EVENTLIST_2nd(evl));
+#endif
 #if USE_SYSMOUSE
     if ((sp->_mouse_type == M_SYSMOUSE)
        && (sp->_sysmouse_head < sp->_sysmouse_tail)
@@ -220,9 +258,15 @@ fifo_push(SCREEN *sp EVENTLIST_2nd(_nc_eventlist * evl))
     } else
 #endif
     {                          /* Can block... */
+#ifdef USE_TERM_DRIVER
+       int buf;
+       n = CallDriver_1(sp, read, &buf);
+       ch = buf;
+#else
        unsigned char c2 = 0;
        n = read(sp->_ifd, &c2, 1);
        ch = c2;
+#endif
     }
 
 #ifdef HIDE_EINTR