From ffcb5355a2186bdc617681488d0d7b7204292832 Mon Sep 17 00:00:00 2001 From: deuce <> Date: Fri, 23 May 2003 20:22:45 +0000 Subject: [PATCH] Added a *lastkey to getstrxy() which holds the last accepted char. Added mode K_TABEXIT mode flag to trat a TAB as a CR WIN_FAT listboxes extend to the bottom of the screen. --- src/uifc/uifc.h | 5 +++-- src/uifc/uifc32.c | 30 ++++++++++++++++++++---------- 2 files changed, 23 insertions(+), 12 deletions(-) diff --git a/src/uifc/uifc.h b/src/uifc/uifc.h index 1cf29edef5..eee68c93e7 100644 --- a/src/uifc/uifc.h +++ b/src/uifc/uifc.h @@ -195,7 +195,8 @@ #define K_CHAT (1L<<8) /* In chat multi-chat */ #define K_NOCRLF (1L<<9) /* Don't print CRLF after string input */ #define K_ALPHA (1L<<10) /* Only allow alphabetic characters */ -#define K_SCANNING (1L<<11) /* UPC Scanner is active... abort on '%' */ +#define K_SCANNING (1L<<11) /* UPC Scanner is active... return on '%' */ +#define K_TABEXIT (1L<<12) /* Return on TAB */ #define HELPBUF_SIZE 4000 @@ -371,7 +372,7 @@ typedef struct { /****************************************************************************/ /* String input/exit box at a specified position */ /****************************************************************************/ - int (*getstrxy)(int left, int top, char *outstr, int max, long mode); + int (*getstrxy)(int left, int top, char *outstr, int max, long mode, int *lastkey); } uifcapi_t; /****************************************************************************/ diff --git a/src/uifc/uifc32.c b/src/uifc/uifc32.c index b78706c9d9..b1514833dc 100644 --- a/src/uifc/uifc32.c +++ b/src/uifc/uifc32.c @@ -96,7 +96,7 @@ static int uprintf(int x, int y, unsigned char attr, char *fmt,...); static void bottomline(int line); static char *utimestr(time_t *intime); static void help(); -static int ugetstr(int left, int top, char *outstr, int max, long mode); +static int ugetstr(int left, int top, char *outstr, int max, long mode, int *lastkey); static void timedisplay(void); /* API routines */ @@ -362,11 +362,13 @@ int ulist(int mode, int left, int top, int width, int *cur, int *bar int s_top=SCRN_TOP; int s_left=SCRN_LEFT; int s_right=SCRN_RIGHT; + int s_bottom=api->scrn_len-3; if(mode&WIN_FAT) { s_top=1; s_left=0; - s_right=api->scrn_width-3; + s_right=api->scrn_width-3; /* Leave space for the shadow */ + s_bottom=api->scrn_len-1; /* Leave one for the shadow */ } if(mode&WIN_SAV && api->savnum>=MAX_BUFS-1) putch(7); @@ -383,8 +385,8 @@ int ulist(int mode, int left, int top, int width, int *cur, int *bar if(mode&WIN_XTR && opts<max_opts && opts<MAX_OPTS) option[opts++][0]=0; height=opts+4; - if(top+height>api->scrn_len-3) - height=(api->scrn_len-3)-top; + if(top+height>s_bottom) + height=(s_bottom)-top; if(!width || width<strlen(title)+6) { width=strlen(title)+6; for(i=0;i<opts;i++) { @@ -409,7 +411,7 @@ int ulist(int mode, int left, int top, int width, int *cur, int *bar if(mode&WIN_T2B) top=(api->scrn_len-height+1)/2-2; else if(mode&WIN_BOT) - top=api->scrn_len-height-3-top; + top=s_bottom-height-top; /* Dynamic Menus */ if(mode&WIN_DYN @@ -1210,9 +1212,9 @@ int uinput(int mode, int left, int top, char *prompt, char *str, textattr(lclr|(bclr<<4)); if(!plen) - i=ugetstr(SCRN_LEFT+left+2,SCRN_TOP+top+1,str,max,kmode); + i=ugetstr(SCRN_LEFT+left+2,SCRN_TOP+top+1,str,max,kmode,NULL); else - i=ugetstr(SCRN_LEFT+left+plen+4,SCRN_TOP+top+1,str,max,kmode); + i=ugetstr(SCRN_LEFT+left+plen+4,SCRN_TOP+top+1,str,max,kmode,NULL); if(mode&WIN_SAV) puttext(SCRN_LEFT+left,SCRN_TOP+top,SCRN_LEFT+left+width+1 ,SCRN_TOP+top+height,save_buf); @@ -1239,9 +1241,8 @@ void umsg(char *str) /****************************************************************************/ /* Gets a string of characters from the user. Turns cursor on. Allows */ /* Different modes - K_* macros. ESC aborts input. */ -/* Cursor should be at END of where string prompt will be placed. */ /****************************************************************************/ -int ugetstr(int left, int top, char *outstr, int max, long mode) +int ugetstr(int left, int top, char *outstr, int max, long mode, int *lastkey) { uchar str[256],ins=0,buf[256],y; int ch; @@ -1268,7 +1269,10 @@ int ugetstr(int left, int top, char *outstr, int max, long mode) #endif f=inkey(0); gotoxy(wherex()-i,y); - if(f == CR || (f >= 0xff && f != KEY_DC) || (f == '%' && mode&K_SCANNING)) + if(f == CR + || (f >= 0xff && f != KEY_DC) + || (f == '\t' && mode&K_TABEXIT) + || (f == '%' && mode&K_SCANNING)) { cputs(outstr); } @@ -1292,6 +1296,8 @@ int ugetstr(int left, int top, char *outstr, int max, long mode) ch=f; else ch=inkey(0); + if(lastkey != NULL) + *lastkey=ch; f=0; switch(ch) { @@ -1379,6 +1385,10 @@ int ugetstr(int left, int top, char *outstr, int max, long mode) } case CR: break; + case '\t': /* '%' indicates that a UPC is coming next */ + if(mode&K_TABEXIT) + ch=CR; + break; case '%': /* '%' indicates that a UPC is coming next */ if(mode&K_SCANNING) ch=CR; -- GitLab