diff --git a/src/uifc/keys.h b/src/uifc/keys.h new file mode 100644 index 0000000000000000000000000000000000000000..cd02c589f3aecc911b0aa15116acd8502aae6357 --- /dev/null +++ b/src/uifc/keys.h @@ -0,0 +1,14 @@ +#define KEY_HOME 0x47 << 8 +#define KEY_UP 72 << 8 +#define KEY_END 0x4f << 8 +#define KEY_DOWN 80 << 8 +#define KEY_F(x) (0x3a+x) << 8 +#define KEY_IC 0x52 << 8 +#define KEY_DC 0x53 << 8 +#define KEY_LEFT 0x4b << 8 +#define KEY_RIGHT 0x4d << 8 +#define KEY_PPAGE 0x49 << 8 +#define KEY_NPAGE 0x51 << 8 + +/* #define KEY_BACKSPACE '\b' << 8 This is most likely wrong */ +#define KEY_BACKSPACE 0xff << 8 /* Just a placeholder for now */ diff --git a/src/uifc/uifc32.c b/src/uifc/uifc32.c index c692240cbc8067827a9546d31dae8fbe21151440..6af9aab5339df44a15e84c6f3383b404a272463a 100644 --- a/src/uifc/uifc32.c +++ b/src/uifc/uifc32.c @@ -41,10 +41,14 @@ #endif #include "ciowrap.h" #define mswait(x) delay(x) + #define putch(x) _putch(x,TRUE) + #define clreol() clrtoeol() + #define strnicmp(x,y,z) strncasecmp(x,y,z) #elif defined(_WIN32) #include <share.h> #include <conio.h> #include <windows.h> + #include "keys.h" #define mswait(x) Sleep(x) #endif @@ -56,24 +60,26 @@ #define BL_GET (1<<2) /* Get key */ #define BL_PUT (1<<3) /* Put key */ +#ifdef __unix__ enum { BLACK ,BLUE ,GREEN - ,CYAN + ,CYAN ,RED - ,MAGENTA + ,MAGENTA ,BROWN ,LIGHTGRAY - ,DARKGRAY + ,DARKGRAY ,LIGHTBLUE ,LIGHTGREEN - ,LIGHTCYAN - ,LIGHTRED + ,LIGHTCYAN + ,LIGHTRED ,LIGHTMAGENTA ,YELLOW ,WHITE }; +#endif #define BLINK 128 @@ -93,7 +99,6 @@ static char *utimestr(time_t *intime); static void help(); static int ugetstr(char *outstr, int max, long mode); static void timedisplay(void); -#define putch(x) _putch(x,TRUE) /* API routines */ static void uifcbail(void); @@ -126,6 +131,20 @@ static void reset_dynamic(void) { /* Returns 0 on success. */ /****************************************************************************/ +#ifdef _WIN32 /* ToDo Merge with __unix__ */ +int inkey(int mode) +{ + int c; + +if(mode) + return(kbhit()); +c=getch(); +if(!c) + c=(getch()<<8); +return(c); +} +#endif + int uifcini32(uifcapi_t* uifcapi) { int i; @@ -262,14 +281,13 @@ int uscrn(char *str) { textattr(bclr|(cclr<<4)); gotoxy(1,1); - clrtoeol(); + clreol(); gotoxy(3,1); cputs(str); if(!puttext(1,2,api->scrn_width,api->scrn_len,blk_scrn)) return(-1); gotoxy(1,api->scrn_len+1); - clrtoeol(); - refresh(); + clreol(); reset_dynamic(); return(0); } @@ -873,12 +891,12 @@ int ulist(int mode, int left, int top, int width, int *cur, int *bar break; case KEY_F(5): /* F5 */ if(mode&WIN_GET && !(mode&WIN_XTR && (*cur)==opts-1)) { - return((*cur)|MSK_GET); + return((*cur)|MSK_GET); } break; case KEY_F(6): /* F6 */ if(mode&WIN_PUT && !(mode&WIN_XTR && (*cur)==opts-1)) { - return((*cur)|MSK_PUT); + return((*cur)|MSK_PUT); } break; case KEY_IC: /* insert */ @@ -943,7 +961,7 @@ int ulist(int mode, int left, int top, int width, int *cur, int *bar if(a==1 && !s) break; if(strlen(option[j])>b - && ((!a && s && !strncasecmp(option[j]+b,search,s+1)) + && ((!a && s && !strnicmp(option[j]+b,search,s+1)) || ((a || !s) && toupper(option[j][b])==toupper(i)))) { if(a) s=0; else s++; @@ -1014,7 +1032,7 @@ int ulist(int mode, int left, int top, int width, int *cur, int *bar } } if(a==2) - s=0; + s=0; } else switch(i) { @@ -1452,7 +1470,7 @@ void bottomline(int line) i+=4; gotoxy(i,api->scrn_len+1); textattr(BLACK|(cclr<<4)); - clrtoeol(); + clreol(); }