From 0a7d56c334c64a062066d6b29f72e086b6d5635e Mon Sep 17 00:00:00 2001 From: rswindell <> Date: Mon, 23 Oct 2017 03:04:38 +0000 Subject: [PATCH] Eliminated the "Paste Over" option/behavior. Paste (Ctrl-V, F6 or Shift-Insert) is always the same operation (e.g. Paste-Insert). MSK_PASTE_OVER and MSK_PASTE_INSERT have been removed (now combined into MSK_PASTE), so current SCFG code, for example, won't compile. Introduced a separate WIN_CUT uifc.list mode flag to enable the Cut (e.g. Ctrl-X) option on the status/help line. Re-factored the bottomline() routine to re-use the WIN_* mode flags. --- src/uifc/uifc.h | 24 ++++------ src/uifc/uifc32.c | 119 ++++++++++++++++++++++------------------------ src/uifc/uifcx.c | 26 ++++------ 3 files changed, 75 insertions(+), 94 deletions(-) diff --git a/src/uifc/uifc.h b/src/uifc/uifc.h index 6fd213f853..6443cd6d97 100644 --- a/src/uifc/uifc.h +++ b/src/uifc/uifc.h @@ -103,13 +103,12 @@ #define MSK_DEL 0x20000000 #define MSK_COPY 0x30000000 #define MSK_CUT 0x40000000 -#define MSK_PASTE_OVER 0x50000000 /* Overwrite selected item with previously copied item */ -#define MSK_PASTE_INSERT 0x60000000 /* Insert new item (above) current item with previously copied item */ -#define MSK_EDIT 0x70000000 +#define MSK_PASTE 0x50000000 /* Overwrite selected item with previously copied item */ +#define MSK_EDIT 0x60000000 /* Legacy terms (get/put instead of copy/paste) */ #define MSK_GET MSK_COPY -#define MSK_PUT MSK_PASTE_OVER +#define MSK_PUT MSK_PASTE /* Don't forget, negative return values are used for extended keys (if WIN_EXTKEYS used)! */ #define MAX_OPLN 75 /* Maximum length of each option per menu call */ @@ -156,8 +155,9 @@ #define WIN_CHE (1<<14) /* Stay active after escape if changes */ #define WIN_XTR (1<<15) /* Add extra line at end for inserting at end */ #define WIN_DYN (1<<16) /* Dynamic window - return at least every second */ -#define WIN_HLP (1<<17) /* Parse 'Help codes' */ -#define WIN_PACK (1<<18) /* Pack text in window (No padding) */ +#define WIN_CUT (1<<17) /* Allow ^X (cut) a menu item */ +#define WIN_HLP (1<<17) /* Parse 'Help codes' - showbuf() and bottomline */ +#define WIN_PACK (1<<18) /* Pack text in window (No padding) - showbuf() */ #define WIN_IMM (1<<19) /* Draw window and return immediately */ #define WIN_FAT (1<<20) /* Do not pad outside borders */ #define WIN_REDRAW (1<<21) /* Force redraw on dynamic window */ @@ -206,13 +206,6 @@ /* And ungets the mouse event. */ #define K_PASSWORD (1L<<16) /* Does not display text while editing */ - /* Bottom line elements */ -#define BL_INS (1<<0) /* INS key */ -#define BL_DEL (1<<1) /* DEL key */ -#define BL_COPY (1<<2) /* Copy operation */ -#define BL_PASTE (1<<3) /* Paste operation */ -#define BL_EDIT (1<<4) /* Edit key */ -#define BL_HELP (1<<5) /* Help key */ /* Extra exit flags */ #define UIFC_XF_QUIT (1<<0) /* Returned -1 due to CIO_KEY_QUIT */ @@ -384,6 +377,7 @@ typedef struct { /****************************************************************************/ char helpdatfile[MAX_PATH+1]; char helpixbfile[MAX_PATH+1]; + BOOL help_available; /****************************************************************************/ /* Help and exit button locations for current/last window */ /****************************************************************************/ @@ -489,9 +483,9 @@ typedef struct { void (*timedisplay)(BOOL force); /****************************************************************************/ -/* Displays the bottom line using the BL_* macros */ +/* Displays the bottom line using the WIN_* mode flags */ /****************************************************************************/ - void (*bottomline)(int line); + void (*bottomline)(int mode); /****************************************************************************/ /* String input/exit box at a specified position */ diff --git a/src/uifc/uifc32.c b/src/uifc/uifc32.c index 090b2d7fb0..878e010263 100644 --- a/src/uifc/uifc32.c +++ b/src/uifc/uifc32.c @@ -618,8 +618,7 @@ static void truncspctrl(char *str) int ulist(int mode, int left, int top, int width, int *cur, int *bar , char *initial_title, char **option) { - uchar line[MAX_COLS*2],shade[MAX_LINES*4],*ptr - ,bline=0,*win; + uchar line[MAX_COLS*2],shade[MAX_LINES*4],*ptr,*win; char search[MAX_OPLN]; int height,y; int i,j,opts=0,s=0; /* s=search index into options */ @@ -691,16 +690,13 @@ int ulist(int mode, int left, int top, int width, int *cur, int *bar if(mode&WIN_SAV && api->savnum>=MAX_BUFS-1) putch(7); + api->help_available = (api->helpbuf!=NULL || api->helpixbfile[0]!=0); + /* Create the status bar/bottom-line */ - if(api->helpbuf!=NULL || api->helpixbfile[0]!=0) bline|=BL_HELP; - if(mode&WIN_INS) bline|=BL_INS; - if(mode&WIN_DEL) bline|=BL_DEL; - if(mode&WIN_COPY) bline|=BL_COPY; - if(mode&WIN_PASTE) bline|=BL_PASTE; - if(mode&WIN_EDIT) bline|=BL_EDIT; + int bline = mode; if (api->bottomline != NULL) { if ((mode&(WIN_XTR | WIN_PASTEXTR)) == WIN_XTR && (*cur) == opts - 1) - api->bottomline(bline & ~BL_PASTE); + api->bottomline(bline & ~WIN_PASTE); else api->bottomline(bline); } @@ -725,7 +721,7 @@ int ulist(int mode, int left, int top, int width, int *cur, int *bar } /* Determine minimum widths here to accommodate mouse "icons" in border */ if(!(mode&WIN_NOBRDR) && api->mode&UIFC_MOUSE) { - if(bline&BL_HELP && width<8) + if(api->help_available && width<8) width=8; else if(width<5) width=5; @@ -783,7 +779,7 @@ int ulist(int mode, int left, int top, int width, int *cur, int *bar if(cur==sav[i].cur && bar==sav[i].bar) { /* Yes, it is... */ for(j=api->savnum-1; j>i; j--) { - /* Retore old screens */ + /* Restore old screens */ puttext(sav[j].left,sav[j].top,sav[j].right,sav[j].bot ,sav[j].buf); /* put original window back */ FREE_AND_NULL(sav[j].buf); @@ -875,7 +871,7 @@ int ulist(int mode, int left, int top, int width, int *cur, int *bar *(ptr++)=api->chars->button_right; *(ptr++)=hclr|(bclr<<4); i=3; - if(bline&BL_HELP) { + if(api->help_available) { *(ptr++)=api->chars->button_left; *(ptr++)=hclr|(bclr<<4); *(ptr++)=api->chars->help_char; @@ -1010,7 +1006,7 @@ int ulist(int mode, int left, int top, int width, int *cur, int *bar *(ptr++)=hclr|(bclr<<4); } *(ptr++)=api->chars->list_bottom_right; - *(ptr)=hclr|(bclr<<4); /* Not incremented to shut ot BCC */ + *(ptr)=hclr|(bclr<<4); /* Not incremented to shut up BCC */ } puttext(s_left+left,s_top+top,s_left+left+width-1 ,s_top+top+height-1,tmp_buffer); @@ -1108,9 +1104,11 @@ int ulist(int mode, int left, int top, int width, int *cur, int *bar while(1) { #if 0 /* debug */ + struct text_info txtinfo; + gettextinfo(&txtinfo); gotoxy(30,1); - cprintf("y=%2d h=%2d c=%2d b=%2d s=%2d o=%2d" - ,y,height,*cur,bar ? *bar :0xff,api->savnum,opts); + cprintf("y=%2d h=%2d c=%2d b=%2d s=%2d o=%2d w=%d/%d h=%d/%d" + ,y,height,*cur,bar ? *bar :0xff,api->savnum,opts,txtinfo.screenwidth, api->scrn_width, txtinfo.screenheight, api->scrn_len); #endif if(api->timedisplay != NULL) api->timedisplay(/* force? */FALSE); @@ -1594,19 +1592,16 @@ int ulist(int mode, int left, int top, int width, int *cur, int *bar case CIO_KEY_F(5): /* F5 - Copy */ case CIO_KEY_CTRL_IC: /* Ctrl-Insert */ if(mode&WIN_COPY && !(mode&WIN_XTR && (*cur)==opts-1)) - return((*cur)|MSK_GET); + return((*cur) | MSK_COPY); break; case CIO_KEY_SHIFT_DC: /* Shift-Del: Cut */ - if(mode&WIN_COPY && !(mode&WIN_XTR && (*cur) == opts - 1)) + if(mode&WIN_CUT && !(mode&WIN_XTR && (*cur) == opts - 1)) return((*cur) | MSK_CUT); break; - case CIO_KEY_SHIFT_IC: /* Shift-Insert: Paste-Insert */ - if(mode&WIN_PASTE) - return((*cur) | MSK_PASTE_INSERT); - break; - case CIO_KEY_F(6): /* F6 - Paste-Over */ + case CIO_KEY_SHIFT_IC: /* Shift-Insert: Paste */ + case CIO_KEY_F(6): /* F6 - Paste */ if(mode&WIN_PASTE && (mode&WIN_PASTEXTR || !(mode&WIN_XTR && (*cur)==opts-1))) - return((*cur)|MSK_PASTE_OVER); + return((*cur)|MSK_PASTE); break; case CIO_KEY_IC: /* insert */ if(mode&WIN_INS) { @@ -1825,9 +1820,9 @@ int ulist(int mode, int left, int top, int width, int *cur, int *bar } } /* Update the status bar to reflect the Put/Paste option applicability */ - if (bline&BL_PASTE && api->bottomline != NULL) { + if (bline&WIN_PASTE && api->bottomline != NULL) { if ((mode&(WIN_XTR | WIN_PASTEXTR)) == WIN_XTR && (*cur) == opts - 1) - api->bottomline(bline & ~BL_PASTE); + api->bottomline(bline & ~WIN_PASTE); else api->bottomline(bline); } @@ -2410,52 +2405,52 @@ static int uprintf(int x, int y, unsigned attr, char *fmat, ...) /****************************************************************************/ /* Display bottom line of screen in inverse */ /****************************************************************************/ -void bottomline(int line) +void bottomline(int mode) { int i=1; - uprintf(i,api->scrn_len+1,api->bclr|(api->cclr<<4)," "); - i+=4; - if(line&BL_HELP) { - uprintf(i,api->scrn_len+1,api->bclr|(api->cclr<<4),"F1 "); - i+=3; - uprintf(i,api->scrn_len+1,BLACK|(api->cclr<<4),"Help "); - i+=6; + i += uprintf(i,api->scrn_len+1,api->bclr|(api->cclr<<4)," "); + if(api->help_available) { + i += uprintf(i,api->scrn_len+1,api->bclr|(api->cclr<<4),"F1 "); + i += uprintf(i,api->scrn_len+1,BLACK|(api->cclr<<4),"Help "); } - if(line&BL_EDIT) { - uprintf(i,api->scrn_len+1,api->bclr|(api->cclr<<4),"F2 "); - i+=3; - uprintf(i,api->scrn_len+1,BLACK|(api->cclr<<4),"Edit Item "); - i+=11; + if(mode&WIN_EDIT) { + 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 "); } - if(line&BL_COPY) { - uprintf(i,api->scrn_len+1,api->bclr|(api->cclr<<4),"F5 "); - i+=3; - uprintf(i,api->scrn_len+1,BLACK|(api->cclr<<4),"Copy Item "); - i+=11; + if(mode&WIN_COPY) { + 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,BLACK|(api->cclr<<4),"Copy "); + } else { + i += uprintf(i,api->scrn_len+1,api->bclr|(api->cclr<<4),"^C"); + i += uprintf(i,api->scrn_len+1,BLACK|(api->cclr<<4),"opy "); + } + } + if(mode&WIN_CUT) { + if(api->mode&UIFC_NOCTRL) + i += uprintf(i,api->scrn_len+1,api->bclr|(api->cclr<<4),"Shift-DEL "); + else + i += uprintf(i,api->scrn_len+1,api->bclr|(api->cclr<<4),"^X "); + i += uprintf(i,api->scrn_len+1,BLACK|(api->cclr<<4),"Cut "); } - if(line&BL_PASTE) { - uprintf(i,api->scrn_len+1,api->bclr|(api->cclr<<4),"F6 "); - i+=3; - uprintf(i,api->scrn_len+1,BLACK|(api->cclr<<4),"Paste "); - i+=7; + if(mode&WIN_PASTE) { + if(api->mode&UIFC_NOCTRL) + i += uprintf(i,api->scrn_len+1,api->bclr|(api->cclr<<4),"F6 "); + else + i += uprintf(i,api->scrn_len+1,api->bclr|(api->cclr<<4),"^V "); + i += uprintf(i,api->scrn_len+1,BLACK|(api->cclr<<4),"Paste "); } - if(line&BL_INS) { - uprintf(i,api->scrn_len+1,api->bclr|(api->cclr<<4),"INS "); - i+=4; - uprintf(i,api->scrn_len+1,BLACK|(api->cclr<<4),"Add Item "); - i+=10; + if(mode&WIN_INS) { + i += uprintf(i,api->scrn_len+1,api->bclr|(api->cclr<<4),"INS"); + i += uprintf(i,api->scrn_len+1,BLACK|(api->cclr<<4),"ert Item "); } - if(line&BL_DEL) { - uprintf(i,api->scrn_len+1,api->bclr|(api->cclr<<4),"DEL "); - i+=4; - uprintf(i,api->scrn_len+1,BLACK|(api->cclr<<4),"Delete Item "); - i+=13; + if(mode&WIN_DEL) { + i += uprintf(i,api->scrn_len+1,api->bclr|(api->cclr<<4),"DEL"); + i += uprintf(i,api->scrn_len+1,BLACK|(api->cclr<<4),"ete Item "); } - uprintf(i,api->scrn_len+1,api->bclr|(api->cclr<<4),"ESC "); /* Backspace is no good no way to abort editing */ - i+=4; - uprintf(i,api->scrn_len+1,BLACK|(api->cclr<<4),"Exit"); - i+=4; + i += uprintf(i,api->scrn_len+1,api->bclr|(api->cclr<<4),"ESC "); /* Backspace is no good no way to abort editing */ + i += uprintf(i,api->scrn_len+1,BLACK|(api->cclr<<4),"Exit"); gotoxy(i,api->scrn_len+1); textattr(BLACK|(api->cclr<<4)); clreol(); diff --git a/src/uifc/uifcx.c b/src/uifc/uifcx.c index 9852221aca..777783c2a8 100644 --- a/src/uifc/uifcx.c +++ b/src/uifc/uifcx.c @@ -255,9 +255,11 @@ int ulist(int mode, int left, int top, int width, int *cur, int *bar } str[0]=0; if(mode&WIN_COPY) - strcat(str,", Copy, X-Cut"); + strcat(str,", Copy"); + if(mode&WIN_CUT) + strcat(str,", X-Cut"); if(mode&WIN_PASTE) - strcat(str,", Paste, Insert"); + strcat(str,", Paste"); if(mode&WIN_INS) strcat(str,", Add"); if(mode&WIN_DEL) @@ -324,7 +326,7 @@ int ulist(int mode, int left, int top, int width, int *cur, int *bar return(MSK_COPY); return(which("Copy",opts)|MSK_COPY); case 'X': /* Cut */ - if(!(mode&WIN_COPY)) + if(!(mode&WIN_CUT)) break; if(!opts) break; @@ -333,26 +335,16 @@ int ulist(int mode, int left, int top, int width, int *cur, int *bar if(opts==1) return(MSK_CUT); return(which("Cut",opts)|MSK_CUT); - case 'P': /* Paste-Over */ - if(!(mode&WIN_PASTE)) - break; - if(!opts) - break; - if(i>0 && i<=opts) - return((i-1)|MSK_PASTE_OVER); - if(opts==1) - return(MSK_PASTE_OVER); - return(which("Paste over",opts)|MSK_PASTE_OVER); - case 'I': /* Paste-Insert */ + case 'P': /* Paste */ if(!(mode&WIN_PASTE)) break; if(!opts) break; if(i>0 && i<=opts+1) - return((i-1)|MSK_PASTE_INSERT); + return((i-1)|MSK_PASTE); if(opts==1) - return(MSK_PASTE_INSERT); - return(which("Insert pasted item before",opts+1)|MSK_PASTE_INSERT); + return(MSK_PASTE); + return(which("Insert pasted item before",opts+1)|MSK_PASTE); } } } -- GitLab