Skip to content
Snippets Groups Projects
Commit de7b2c60 authored by Rob Swindell's avatar Rob Swindell :speech_balloon:
Browse files

Add suport for option/item tagging using the WIN_TAG ulist() mode flag

For use with fileman.js:

The space bar can be used by the user to "tag" items, or Ctrl-A to toggle
tag status for *all* items. Returns MSK_TAG|with the option tagged/untagged
or MSG_TAGALL when all tags are being toggled (via ^A).

Also, fix bug where ^Find command would not restore the status bar after
ulist() would overwrite it with the string-input/edit hot-keys available.
parent c8f60b06
No related branches found
No related tags found
1 merge request!455Update branch with changes from master
...@@ -88,6 +88,9 @@ ...@@ -88,6 +88,9 @@
#define MSK_CUT 0x40000000 #define MSK_CUT 0x40000000
#define MSK_PASTE 0x50000000 /* Overwrite selected item with previously copied item */ #define MSK_PASTE 0x50000000 /* Overwrite selected item with previously copied item */
#define MSK_EDIT 0x60000000 #define MSK_EDIT 0x60000000
#define MSK_TAG 0x70000000
#define MSK_TAGALL (MSK_TAG | MSK_OFF)
/* Legacy terms (get/put instead of copy/paste) */ /* Legacy terms (get/put instead of copy/paste) */
#define MSK_GET MSK_COPY #define MSK_GET MSK_COPY
...@@ -140,6 +143,7 @@ ...@@ -140,6 +143,7 @@
#define WIN_DYN (1LL<<16) /* Dynamic window - return at least every second */ #define WIN_DYN (1LL<<16) /* Dynamic window - return at least every second */
#define WIN_CUT (1LL<<17) /* Allow ^X (cut) a menu item */ #define WIN_CUT (1LL<<17) /* Allow ^X (cut) a menu item */
#define WIN_HLP (1LL<<17) /* Parse 'Help codes' - showbuf() */ #define WIN_HLP (1LL<<17) /* Parse 'Help codes' - showbuf() */
#define WIN_TAG (1LL<<18) /* Allow space bar to toggle tagged options */
#define WIN_PACK (1LL<<18) /* Pack text in window (No padding) - showbuf() */ #define WIN_PACK (1LL<<18) /* Pack text in window (No padding) - showbuf() */
#define WIN_IMM (1LL<<19) /* Draw window and return immediately */ #define WIN_IMM (1LL<<19) /* Draw window and return immediately */
#define WIN_FAT (1LL<<20) /* Do not pad outside borders */ #define WIN_FAT (1LL<<20) /* Do not pad outside borders */
......
...@@ -1222,6 +1222,10 @@ int ulist(uifc_winmode_t mode, int left, int top, int width, int *cur, int *bar ...@@ -1222,6 +1222,10 @@ int ulist(uifc_winmode_t mode, int left, int top, int width, int *cur, int *bar
case DEL: case DEL:
gotkey=CIO_KEY_DC; /* delete */ gotkey=CIO_KEY_DC; /* delete */
break; break;
case CTRL_A:
if(mode & WIN_TAG)
return MSK_TAGALL;
break;
case CTRL_B: case CTRL_B:
if(!(api->mode&UIFC_NOCTRL)) if(!(api->mode&UIFC_NOCTRL))
gotkey=CIO_KEY_HOME; gotkey=CIO_KEY_HOME;
...@@ -1730,6 +1734,10 @@ int ulist(uifc_winmode_t mode, int left, int top, int width, int *cur, int *bar ...@@ -1730,6 +1734,10 @@ int ulist(uifc_winmode_t mode, int left, int top, int width, int *cur, int *bar
} }
else else
switch(gotkey) { switch(gotkey) {
case ' ':
if(mode & WIN_TAG)
return MSK_TAG | (*cur);
break;
case CR: case CR:
if(!opts) if(!opts)
break; break;
...@@ -1878,7 +1886,7 @@ int ulist(uifc_winmode_t mode, int left, int top, int width, int *cur, int *bar ...@@ -1878,7 +1886,7 @@ int ulist(uifc_winmode_t mode, int left, int top, int width, int *cur, int *bar
int uinput(uifc_winmode_t mode, int left, int top, const char *inprompt, char *str, int uinput(uifc_winmode_t mode, int left, int top, const char *inprompt, char *str,
int max, int kmode) int max, int kmode)
{ {
struct vmem_cell shade[MAX_COLS], save_buf[MAX_COLS*4], in_win[MAX_COLS*3]; struct vmem_cell shade[MAX_COLS], save_buf[MAX_COLS*4], in_win[MAX_COLS*3], save_bottomline[MAX_COLS];
int width; int width;
int height=3; int height=3;
int i,plen,slen,j; int i,plen,slen,j;
...@@ -1933,9 +1941,11 @@ int uinput(uifc_winmode_t mode, int left, int top, const char *inprompt, char *s ...@@ -1933,9 +1941,11 @@ int uinput(uifc_winmode_t mode, int left, int top, const char *inprompt, char *s
left=-(s_left)+1; left=-(s_left)+1;
if(top<0) if(top<0)
top=0; top=0;
if(mode&WIN_SAV) if(mode&WIN_SAV) {
vmem_gettext(s_left+left,s_top+top,s_left+left+width+(shadow*2)-1 vmem_gettext(s_left+left,s_top+top,s_left+left+width+(shadow*2)-1
,s_top+top+height+(!shadow),save_buf); ,s_top+top+height+(!shadow),save_buf);
vmem_gettext(1, api->scrn_len + 1, api->scrn_width, api->scrn_len + 1, save_bottomline);
}
if(mode&WIN_ORG) { /* Clear around menu */ if(mode&WIN_ORG) { /* Clear around menu */
if(top) if(top)
vmem_puttext(1,2,api->scrn_width,s_top+top-1,blk_scrn); vmem_puttext(1,2,api->scrn_width,s_top+top-1,blk_scrn);
...@@ -2032,9 +2042,11 @@ int uinput(uifc_winmode_t mode, int left, int top, const char *inprompt, char *s ...@@ -2032,9 +2042,11 @@ int uinput(uifc_winmode_t mode, int left, int top, const char *inprompt, char *s
api->bottomline(WIN_COPY|WIN_CUT|WIN_PASTE); api->bottomline(WIN_COPY|WIN_CUT|WIN_PASTE);
textattr(api->lclr|(api->bclr<<4)); textattr(api->lclr|(api->bclr<<4));
i=ugetstr(s_left+left+plen+offset,s_top+top+tbrdrwidth,iwidth,str,max,kmode,NULL); i=ugetstr(s_left+left+plen+offset,s_top+top+tbrdrwidth,iwidth,str,max,kmode,NULL);
if(mode&WIN_SAV) if(mode&WIN_SAV) {
vmem_puttext(s_left+left,s_top+top,s_left+left+width+(shadow*2)-1 vmem_puttext(s_left+left,s_top+top,s_left+left+width+(shadow*2)-1
,s_top+top+height+(!shadow),save_buf); ,s_top+top+height+(!shadow),save_buf);
vmem_puttext(1, api->scrn_len + 1, api->scrn_width, api->scrn_len + 1, save_bottomline);
}
free(prompt); free(prompt);
return(i); return(i);
} }
...@@ -2543,6 +2555,12 @@ void bottomline(uifc_winmode_t mode) ...@@ -2543,6 +2555,12 @@ void bottomline(uifc_winmode_t mode)
i += uprintf(i,api->scrn_len+1,api->bclr|(api->cclr<<4),"F2 "); i += uprintf(i,api->scrn_len+1,api->bclr|(api->cclr<<4),"F2 ");
i += uprintf(i,api->scrn_len+1,BLACK|(api->cclr<<4),"Edit Item "); i += uprintf(i,api->scrn_len+1,BLACK|(api->cclr<<4),"Edit Item ");
} }
if(mode&WIN_TAG) {
i += uprintf(i,api->scrn_len+1,api->bclr|(api->cclr<<4),"Space ");
i += uprintf(i,api->scrn_len+1,BLACK|(api->cclr<<4),"Tag Item ");
i += uprintf(i,api->scrn_len+1,api->bclr|(api->cclr<<4),"^A ");
i += uprintf(i,api->scrn_len+1,BLACK|(api->cclr<<4),"Tag All ");
}
if(mode&WIN_COPY) { if(mode&WIN_COPY) {
if(api->mode&UIFC_NOCTRL) { if(api->mode&UIFC_NOCTRL) {
i += uprintf(i,api->scrn_len+1,api->bclr|(api->cclr<<4),"F5 "); i += uprintf(i,api->scrn_len+1,api->bclr|(api->cclr<<4),"F5 ");
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment