From 138496105c69c30bce0a2b8eef307c6468342d24 Mon Sep 17 00:00:00 2001 From: William McBrine Date: Wed, 23 Nov 2005 23:46:42 +0000 Subject: [PATCH] halfdelay() to the rescue again. --- demos/newdemo.c | 37 +++++++++++-------------------------- 1 file changed, 11 insertions(+), 26 deletions(-) diff --git a/demos/newdemo.c b/demos/newdemo.c index cd45aed2..7660ef56 100644 --- a/demos/newdemo.c +++ b/demos/newdemo.c @@ -32,7 +32,6 @@ #include #include #include -#include #include #ifdef HAVE_MEMORY_H @@ -44,7 +43,7 @@ #endif #ifdef PDCDEBUG -char *rcsid_newdemo = "$Id: newdemo.c,v 1.6 2005/11/20 04:01:00 wmcbrine Exp $"; +char *rcsid_newdemo = "$Id: newdemo.c,v 1.7 2005/11/23 23:46:42 wmcbrine Exp $"; #endif #ifndef Args @@ -100,32 +99,18 @@ char *messages[] = */ int WaitForUser() { - time_t t; chtype ch; nodelay(stdscr,TRUE); - t = time((time_t *)0); - while(1) - { - if ((ch = getch()) != (chtype)ERR) - { - if (ch == '\033') - { - nodelay(stdscr, FALSE); - return ch; - } - else - { - nodelay(stdscr, FALSE); - return 0; - } - } - if (time((time_t *)0) - t > 5) - { - nodelay(stdscr, FALSE); - return 0; - } - } + halfdelay(50); + + ch = getch(); + + nodelay(stdscr,FALSE); + nocbreak(); /* Reset the halfdelay() value */ + cbreak(); + + return (ch == '\033') ? ch : 0; } /* @@ -339,7 +324,7 @@ void trap(); { ch = 'b'; init_pair(3,COLOR_CYAN,COLOR_YELLOW); - wattron(win, COLOR_PAIR(3)); + wattrset(win, COLOR_PAIR(3)); } } nodelay(stdscr,FALSE);