diff --git a/src/uifc/ciowrap.c b/src/uifc/ciowrap.c index 3c39a4b1722d5ebe4dd40462c254dd5962c98efc..5da98396399efc893ecf39827f5f3f77539d18a5 100644 --- a/src/uifc/ciowrap.c +++ b/src/uifc/ciowrap.c @@ -7,13 +7,6 @@ static int lastattr=0; static long mode; -int inkey(int mode) -{ - if(mode) - return(kbhit()); - return(getch()); -} - short curses_color(short color) { switch(color) @@ -335,12 +328,12 @@ void textattr(unsigned char attr) bkgdset(colour); } -int _kbhit(void) +int kbhit(void) { struct timeval timeout; fd_set rfds; - - timeout.tv_sec=1; + + timeout.tv_sec=0; timeout.tv_usec=0; FD_ZERO(&rfds); FD_SET(fileno(stdin),&rfds); @@ -623,7 +616,7 @@ void _setcursortype(int type) { default: /* Normal cursor */ curs_set(1); break; - + } refresh(); } diff --git a/src/uifc/ciowrap.h b/src/uifc/ciowrap.h index 0dd67c43de4f21406101b6589a9dedfe54482290..601876e373982d78114e81931b66581f7c5ddb67 100644 --- a/src/uifc/ciowrap.h +++ b/src/uifc/ciowrap.h @@ -3,7 +3,6 @@ #define MONO 1 #define BW80 MONO #define COLOR_MODE 2 -#define kbhit() _kbhit() #ifndef BOOL #define BOOL int @@ -28,12 +27,11 @@ struct text_info { unsigned char screenwidth; }; -int inkey(int mode); short curses_color(short color); int puttext(int sx, int sy, int ex, int ey, unsigned char *fill); int gettext(int sx, int sy, int ex, int ey, unsigned char *fill); void textattr(unsigned char attr); -int _kbhit(void); +int kbhit(void); #ifndef __QNX__ void delay(long msec); #endif diff --git a/src/uifc/uifc32.c b/src/uifc/uifc32.c index d416f259fe8f905c4b920f56e40c3e95e5617d4d..f370fd394630dc2b78910363de32390baded5c7d 100644 --- a/src/uifc/uifc32.c +++ b/src/uifc/uifc32.c @@ -66,7 +66,7 @@ enum { ,BLUE ,GREEN ,CYAN - ,RED + ,RED ,MAGENTA ,BROWN ,LIGHTGRAY @@ -131,19 +131,28 @@ static void reset_dynamic(void) { /* Returns 0 on success. */ /****************************************************************************/ -#ifdef _WIN32 /* ToDo Merge with __unix__ */ +int kbwait() { + int timeout=0; + while(timeout++<500) { + if(kbhit) + return(TRUE); + } + return(FALSE); +} + int inkey(int mode) { int c; -if(mode) - return(kbhit()); -c=getch(); -if(!c) - c=(getch()<<8); -return(c); -} + if(mode) + return(kbwait()); + c=getch(); +#ifdef _WIN32 + if(!c) + c=(getch()<<8); #endif + return(c); +} int uifcini32(uifcapi_t* uifcapi) { @@ -1571,33 +1580,32 @@ void upop(char *str) char buf[26*3*2]; int i,j,k; - reset_dynamic(); if(!str) { puttext(28,12,53,14,sav); - return; + return; } gettext(28,12,53,14,sav); memset(buf,SP,25*3*2); for(i=1;i<26*3*2;i+=2) buf[i]=(hclr|(bclr<<4)); - buf[0]='�'; + buf[0]='�'; for(i=2;i<25*2;i+=2) - buf[i]='�'; - buf[i]='�'; i+=2; - buf[i]='�'; i+=2; + buf[i]='�'; + buf[i]='�'; i+=2; + buf[i]='�'; i+=2; i+=2; k=strlen(str); i+=(((23-k)/2)*2); for(j=0;j<k;j++,i+=2) { buf[i]=str[j]; - buf[i+1]|=BLINK; + buf[i+1]|=BLINK; } i=((25*2)+1)*2; - buf[i]='�'; i+=2; - buf[i]='�'; i+=2; + buf[i]='�'; i+=2; + buf[i]='�'; i+=2; for(;i<((26*3)-1)*2;i+=2) - buf[i]='�'; - buf[i]='�'; + buf[i]='�'; + buf[i]='�'; puttext(28,12,53,14,buf); }