From 9cf536fa28419d328cbb90834e6238525635c778 Mon Sep 17 00:00:00 2001
From: rswindell <>
Date: Wed, 11 Oct 2017 00:14:00 +0000
Subject: [PATCH] Treat Shift-Insert as "Paste Insert" (new item inserted above
 selected item) different from Ctrl-V or F6 which is "Paste Over" (overwriting
 selected item)

---
 src/sbbs3/scfg/scfgsub.c | 16 ++++++++++------
 src/uifc/uifc.h          | 41 +++++++++++++++++++++-------------------
 src/uifc/uifc32.c        | 11 +++++++----
 3 files changed, 39 insertions(+), 29 deletions(-)

diff --git a/src/sbbs3/scfg/scfgsub.c b/src/sbbs3/scfg/scfgsub.c
index 79730b37b5..6177fd1439 100644
--- a/src/sbbs3/scfg/scfgsub.c
+++ b/src/sbbs3/scfg/scfgsub.c
@@ -110,11 +110,11 @@ while(1) {
 	sprintf(str,"%s Sub-boards",cfg.grp[grpnum]->sname);
 	i=WIN_SAV|WIN_ACT;
 	if(j)
-		i|=WIN_DEL|WIN_GET|WIN_DELACT;
+		i|=WIN_DEL|WIN_COPY|WIN_DELACT;
 	if(j<MAX_OPTS)
-		i|=WIN_INS|WIN_XTR|WIN_PUTXTR|WIN_INSACT;
+		i|=WIN_INS|WIN_XTR|WIN_PASTEXTR|WIN_INSACT;
 	if(savsub.sname[0])
-		i|=WIN_PUT;
+		i|=WIN_PASTE;
 	uifc.helpbuf=
 		"`Message Sub-boards:`\n"
 		"\n"
@@ -244,16 +244,20 @@ while(1) {
 		uifc.changes=1;
 		continue; 
 	}
-	if((i&MSK_ON)==MSK_GET) {
+	if((i&MSK_ON)==MSK_COPY) {
 		i&=MSK_OFF;
 		savsub=*cfg.sub[subnum[i]];
 		continue; 
 	}
-	if((i&MSK_ON)==MSK_PUT) {
+	if((i&MSK_ON)==MSK_PASTE_OVER || (i&MSK_ON) == MSK_PASTE_INSERT) {
+		int msk = i&MSK_ON;
 		i&=MSK_OFF;
-		if (opt[i][0] == 0) {	/* Paste-over extra/blank item */
+		if (msk == MSK_PASTE_INSERT) {
 			if (!new_sub(subnum[i], grpnum))
 				continue;
+		} else if (opt[i][0] == 0) {	/* Paste-over extra/blank item */
+			if (!new_sub(cfg.total_subs, grpnum))
+				continue;
 		}
 		ptridx=cfg.sub[subnum[i]]->ptridx;
 		*cfg.sub[subnum[i]]=savsub;
diff --git a/src/uifc/uifc.h b/src/uifc/uifc.h
index 4e289e666d..f491814ade 100644
--- a/src/uifc/uifc.h
+++ b/src/uifc/uifc.h
@@ -96,19 +96,20 @@
 	#endif
 #endif
 
-#define MAX_OPTS	10000
-#define MSK_ON		0xf0000000
-#define MSK_OFF 	0x0fffffff
-#define MSK_INS 	0x10000000
-#define MSK_DEL 	0x20000000
-#define MSK_COPY 	0x30000000
-#define MSK_CUT 	0x40000000
-#define MSK_PASTE 	0x50000000
-#define MSK_EDIT 	0x60000000
+#define MAX_OPTS			10000
+#define MSK_ON				0xf0000000
+#define MSK_OFF 			0x0fffffff
+#define MSK_INS 			0x10000000
+#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
 
 /* Legacy terms (get/put instead of copy/paste) */
 #define MSK_GET		MSK_COPY
-#define MSK_PUT		MSK_PASTE
+#define MSK_PUT		MSK_PASTE_OVER
 
 /* 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 */
@@ -149,8 +150,8 @@
 #define WIN_ESC 	(1<<9)	/* Screen is active when escape is hit			 */
 #define WIN_RHT 	(1<<10) /* Place window against right side of screen */
 #define WIN_BOT 	(1<<11) /* Place window against bottom of screen */
-#define WIN_GET 	(1<<12) /* Allows F5 to Get (copy) a menu item */
-#define WIN_PUT 	(1<<13) /* Allows F6 to Put (paste) a menu item */
+#define WIN_COPY 	(1<<12) /* Allows F5 to Get (copy) a menu item */
+#define WIN_PASTE 	(1<<13) /* Allows F6 to Put (paste) a menu item */
 #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 */
@@ -166,15 +167,17 @@
 #define WIN_FIXEDHEIGHT	(1<<25)	/* Use list_height from uifc struct */
 #define WIN_UNGETMOUSE  (1<<26) /* If the mouse is clicked outside the window, */
 								/* Put the mouse event back into the event queue */
-#define WIN_EDIT	(1<<27)	/* Allow F2 to edit a menu item */
-#define WIN_PUTXTR	(1<<28)	/* Allow paste into extra (blank) item */
-#define WIN_INACT	(1<<29)	/* Draw window inactive... intended for use with WIN_IMM */
-#define WIN_POP		(1<<30)	/* Exit the list. Act as though ESC was pressed. */
-							/* Intended for use after a WIN_EXTKEYS or WIN_DYN */
-#define WIN_SEL		(1<<31)	/* Exit the list. Act as though ENTER was pressed. */
-							/* Intended for use after a WIN_EXTKEYS or WIN_DYN */
+#define WIN_EDIT		(1<<27)	/* Allow F2 to edit a menu item */
+#define WIN_PASTEXTR	(1<<28)	/* Allow paste into extra (blank) item */
+#define WIN_INACT		(1<<29)	/* Draw window inactive... intended for use with WIN_IMM */
+#define WIN_POP			(1<<30)	/* Exit the list. Act as though ESC was pressed. */
+								/* Intended for use after a WIN_EXTKEYS or WIN_DYN */
+#define WIN_SEL			(1<<31)	/* Exit the list. Act as though ENTER was pressed. */
+								/* Intended for use after a WIN_EXTKEYS or WIN_DYN */
 
 #define WIN_MID WIN_L2R|WIN_T2B  /* Place window in middle of screen */
+#define WIN_GET	WIN_COPY
+#define WIN_PUT WIN_PASTE
 
 #define SCRN_TOP	3
 #define SCRN_LEFT	5
diff --git a/src/uifc/uifc32.c b/src/uifc/uifc32.c
index c191a3b3df..5ce4576b72 100644
--- a/src/uifc/uifc32.c
+++ b/src/uifc/uifc32.c
@@ -1591,10 +1591,13 @@ int ulist(int mode, int left, int top, int width, int *cur, int *bar
 						if(mode&WIN_GET && !(mode&WIN_XTR && (*cur) == opts - 1))
 							return((*cur) | MSK_CUT);
 						break;
-					case CIO_KEY_F(6):		/* F6 - Paste */
-					case CIO_KEY_SHIFT_IC:	/* Shift-Insert */
-						if(mode&WIN_PUT && (mode&WIN_PUTXTR || !(mode&WIN_XTR && (*cur)==opts-1)))
-							return((*cur)|MSK_PUT);
+					case CIO_KEY_SHIFT_IC:	/* Shift-Insert: Paste-Insert */
+						if(mode&WIN_PUT)
+							return((*cur) | MSK_PASTE_INSERT);
+						break;
+					case CIO_KEY_F(6):		/* F6 - Paste-Over */
+						if(mode&WIN_PUT && (mode&WIN_PASTEXTR || !(mode&WIN_PASTEXTR && (*cur)==opts-1)))
+							return((*cur)|MSK_PASTE_OVER);
 						break;
 					case CIO_KEY_IC:	/* insert */
 						if(mode&WIN_INS) {
-- 
GitLab