From 5a2efd5619bea6085f13472c12f84ac3caf5c0ae Mon Sep 17 00:00:00 2001
From: rswindell <>
Date: Tue, 10 Oct 2017 23:07:52 +0000
Subject: [PATCH] Added Cut Item (Ctrl-X) support.

---
 src/sbbs3/scfg/scfg.c     | 10 ++++++++--
 src/sbbs3/scfg/scfgchat.c | 29 +++++++++++++++++++++--------
 src/sbbs3/scfg/scfgmsg.c  |  5 ++++-
 src/sbbs3/scfg/scfgxfr1.c | 37 +++++++++++++++++++++++++++++--------
 src/sbbs3/scfg/scfgxfr2.c | 10 ++++++++--
 src/sbbs3/scfg/scfgxtrn.c | 25 ++++++++++++++++++++-----
 6 files changed, 90 insertions(+), 26 deletions(-)

diff --git a/src/sbbs3/scfg/scfg.c b/src/sbbs3/scfg/scfg.c
index f888a97e3d..b1173fbec8 100644
--- a/src/sbbs3/scfg/scfg.c
+++ b/src/sbbs3/scfg/scfg.c
@@ -695,8 +695,11 @@ void txt_cfg()
 			uifc.changes=1;
 			continue; 
 		}
-		if((i&MSK_ON)==MSK_DEL) {
+		if((i&MSK_ON)==MSK_DEL || (i&MSK_ON) == MSK_CUT) {
+			int msk = i&MSK_ON;
 			i&=MSK_OFF;
+			if(msk == MSK_CUT)
+				savtxtsec = *cfg.txtsec[i];
 			free(cfg.txtsec[i]);
 			cfg.total_txtsecs--;
 			for(j=i;j<cfg.total_txtsecs;j++)
@@ -869,8 +872,11 @@ void shell_cfg()
 			uifc.changes=1;
 			continue; 
 		}
-		if((i&MSK_ON)==MSK_DEL) {
+		if((i&MSK_ON)==MSK_DEL || (i&MSK_ON) == MSK_CUT) {
+			int msk = i&MSK_ON;
 			i&=MSK_OFF;
+			if(msk == MSK_CUT)
+				savshell = *cfg.shell[i];
 			free(cfg.shell[i]);
 			cfg.total_shells--;
 			for(j=i;j<cfg.total_shells;j++)
diff --git a/src/sbbs3/scfg/scfgchat.c b/src/sbbs3/scfg/scfgchat.c
index 6ac21a0d9a..7dfffc039d 100644
--- a/src/sbbs3/scfg/scfgchat.c
+++ b/src/sbbs3/scfg/scfgchat.c
@@ -1,12 +1,10 @@
-/* scfgchat.c */
-
 /* $Id$ */
 
 /****************************************************************************
  * @format.tab-size 4		(Plain Text/Source Code File Header)			*
  * @format.use-tabs true	(see http://www.synchro.net/ptsc_hdr.html)		*
  *																			*
- * Copyright 2012 Rob Swindell - http://www.synchro.net/copyright.html		*
+ * Copyright Rob Swindell - http://www.synchro.net/copyright.html			*
  *																			*
  * This program is free software; you can redistribute it and/or			*
  * modify it under the terms of the GNU General Public License				*
@@ -100,8 +98,11 @@ while(1) {
 		uifc.changes=1;
 		continue; 
 	}
-	if((i&MSK_ON)==MSK_DEL) {
+	if((i&MSK_ON)==MSK_DEL || (i&MSK_ON) == MSK_CUT) {
+		int msk = i&MSK_ON;
 		i&=MSK_OFF;
+		if(msk == MSK_CUT)
+			savpage = *cfg.page[i];
 		free(cfg.page[i]);
 		cfg.total_pages--;
 		for(j=i;j<cfg.total_pages;j++)
@@ -283,8 +284,11 @@ while(1) {
 		uifc.changes=1;
 		continue; 
 	}
-	if((i&MSK_ON)==MSK_DEL) {
+	if((i&MSK_ON)==MSK_DEL || (i&MSK_ON) == MSK_CUT) {
+		int msk = i&MSK_ON;
 		i&=MSK_OFF;
+		if(msk == MSK_CUT)
+			savchan = *cfg.chan[i];
 		free(cfg.chan[i]);
 		cfg.total_chans--;
 		for(j=i;j<cfg.total_chans;j++)
@@ -545,8 +549,11 @@ while(1) {
 		uifc.changes=1;
 		continue; 
 	}
-	if((i&MSK_ON)==MSK_DEL) {
+	if((i&MSK_ON)==MSK_DEL || (i&MSK_ON) == MSK_CUT) {
+		int msk = i&MSK_ON;
 		i&=MSK_OFF;
+		if(msk == MSK_CUT)
+			savchatact = *cfg.chatact[chatnum[i]];
 		free(cfg.chatact[chatnum[i]]);
 		cfg.total_chatacts--;
 		for(j=chatnum[i];j<cfg.total_chatacts && j<MAX_OPTS;j++)
@@ -671,8 +678,11 @@ while(1) {
 		uifc.changes=1;
 		continue; 
 	}
-	if((i&MSK_ON)==MSK_DEL) {
+	if((i&MSK_ON)==MSK_DEL || (i&MSK_ON) == MSK_CUT) {
+		int msk = i&MSK_ON;
 		i&=MSK_OFF;
+		if(msk == MSK_CUT)
+			savguru = *cfg.guru[i];
 		free(cfg.guru[i]);
 		cfg.total_gurus--;
 		for(j=i;j<cfg.total_gurus;j++)
@@ -812,8 +822,11 @@ while(1) {
         uifc.changes=1;
         continue; 
 	}
-	if((i&MSK_ON)==MSK_DEL) {
+	if((i&MSK_ON)==MSK_DEL || (i&MSK_ON) == MSK_CUT) {
+		int msk = i&MSK_ON;
 		i&=MSK_OFF;
+		if(msk == MSK_CUT)
+			savactset = *cfg.actset[i];
         free(cfg.actset[i]);
         cfg.total_actsets--;
         for(j=i;j<cfg.total_actsets;j++)
diff --git a/src/sbbs3/scfg/scfgmsg.c b/src/sbbs3/scfg/scfgmsg.c
index 697ed84732..af58d51230 100644
--- a/src/sbbs3/scfg/scfgmsg.c
+++ b/src/sbbs3/scfg/scfgmsg.c
@@ -221,7 +221,8 @@ while(1) {
 		uifc.changes=1;
 		continue; 
 	}
-	if((i&MSK_ON)==MSK_DEL) {
+	if((i&MSK_ON)==MSK_DEL || (i&MSK_ON)==MSK_CUT) {
+		int msk = i&MSK_ON;
 		i&=MSK_OFF;
 		uifc.helpbuf=
 			"`Delete All Data in Group:`\n"
@@ -250,6 +251,8 @@ while(1) {
 					delfiles(tmp,str);
 					clearptrs(j); 
 				}
+		if(msk == MSK_CUT)
+			savgrp = *cfg.grp[i];
 		free(cfg.grp[i]);
 		for(j=0;j<cfg.total_subs;) {
 			if(cfg.sub[j]->grp==i) {	/* delete subs of this group */
diff --git a/src/sbbs3/scfg/scfgxfr1.c b/src/sbbs3/scfg/scfgxfr1.c
index 1c6a789b73..6d416419bc 100644
--- a/src/sbbs3/scfg/scfgxfr1.c
+++ b/src/sbbs3/scfg/scfgxfr1.c
@@ -251,8 +251,11 @@ uifc.helpbuf=
 				i=uifc.list(i,0,0,50,&fview_dflt,NULL,"Viewable File Types",opt);
 				if(i==-1)
 					break;
-				if((i&MSK_ON)==MSK_DEL) {
+				if((i&MSK_ON)==MSK_DEL || (i&MSK_ON) == MSK_CUT) {
+					int msk = i&MSK_ON;
 					i&=MSK_OFF;
+					if(msk == MSK_CUT)
+						savfview = *cfg.fview[i];
 					free(cfg.fview[i]);
 					cfg.total_fviews--;
 					while(i<cfg.total_fviews) {
@@ -375,8 +378,11 @@ uifc.helpbuf=
 				i=uifc.list(i,0,0,50,&ftest_dflt,NULL,"Testable File Types",opt);
 				if(i==-1)
 					break;
-				if((i&MSK_ON)==MSK_DEL) {
+				if((i&MSK_ON)==MSK_DEL || (i&MSK_ON) == MSK_CUT) {
+					int msk = i&MSK_ON;
 					i&=MSK_OFF;
+					if(msk == MSK_CUT)
+						savftest = *cfg.ftest[i];
 					free(cfg.ftest[i]);
 					cfg.total_ftests--;
 					while(i<cfg.total_ftests) {
@@ -506,8 +512,11 @@ uifc.helpbuf=
 				i=uifc.list(i,0,0,50,&dlevent_dflt,NULL,"Download Events",opt);
 				if(i==-1)
 					break;
-				if((i&MSK_ON)==MSK_DEL) {
+				if((i&MSK_ON)==MSK_DEL || (i&MSK_ON) == MSK_CUT) {
+					int msk = i&MSK_ON;
 					i&=MSK_OFF;
+					if(msk == MSK_CUT)
+						savdlevent = *cfg.dlevent[i];
 					free(cfg.dlevent[i]);
 					cfg.total_dlevents--;
 					while(i<cfg.total_dlevents) {
@@ -631,8 +640,11 @@ uifc.helpbuf=
 				i=uifc.list(i,0,0,50,&fextr_dflt,NULL,"Extractable File Types",opt);
                 if(i==-1)
                     break;
-				if((i&MSK_ON)==MSK_DEL) {
+				if((i&MSK_ON)==MSK_DEL || (i&MSK_ON) == MSK_CUT) {
+					int msk = i&MSK_ON;
 					i&=MSK_OFF;
+					if(msk == MSK_CUT)
+						savfextr = *cfg.fextr[i];
                     free(cfg.fextr[i]);
                     cfg.total_fextrs--;
                     while(i<cfg.total_fextrs) {
@@ -747,8 +759,11 @@ uifc.helpbuf=
 				i=uifc.list(i,0,0,50,&fcomp_dflt,NULL,"Compressable File Types",opt);
 				if(i==-1)
 					break;
-				if((i&MSK_ON)==MSK_DEL) {
+				if((i&MSK_ON)==MSK_DEL || (i&MSK_ON) == MSK_CUT) {
+					int msk = i&MSK_ON;
 					i&=MSK_OFF;
+					if(msk == MSK_CUT)
+						savfcomp = *cfg.fcomp[i];
 					free(cfg.fcomp[i]);
 					cfg.total_fcomps--;
 					while(i<cfg.total_fcomps) {
@@ -870,8 +885,11 @@ uifc.helpbuf=
 				i=uifc.list(i,0,0,50,&prot_dflt,NULL,"File Transfer Protocols",opt);
 				if(i==-1)
 					break;
-				if((i&MSK_ON)==MSK_DEL) {
+				if((i&MSK_ON)==MSK_DEL || (i&MSK_ON) == MSK_CUT) {
+					int msk = i&MSK_ON;
 					i&=MSK_OFF;
+					if(msk == MSK_CUT)
+						savprot = *cfg.prot[i];
 					free(cfg.prot[i]);
 					cfg.total_prots--;
 					while(i<cfg.total_prots) {
@@ -1068,8 +1086,11 @@ uifc.helpbuf=
 				i=uifc.list(i,0,0,50,&altpath_dflt,NULL,"Alternate File Paths",opt);
 				if(i==-1)
 					break;
-				if((i&MSK_ON)==MSK_DEL) {
+				if((i&MSK_ON)==MSK_DEL || (i&MSK_ON) == MSK_CUT) {
+					int msk = i&MSK_ON;
 					i&=MSK_OFF;
+					if(msk == MSK_CUT)
+						SAFECOPY(savaltpath, cfg.altpath[i]);
 					free(cfg.altpath[i]);
 					cfg.altpaths--;
 					while(i<cfg.altpaths) {
@@ -1114,7 +1135,7 @@ uifc.helpbuf=
 				}
 				if((i&MSK_ON)==MSK_GET) {
 					i&=MSK_OFF;
-					memcpy(savaltpath,cfg.altpath[i],LEN_DIR+1);
+					SAFECOPY(savaltpath,cfg.altpath[i]);
 					continue; 
 				}
 				if((i&MSK_ON)==MSK_PUT) {
diff --git a/src/sbbs3/scfg/scfgxfr2.c b/src/sbbs3/scfg/scfgxfr2.c
index 79ea3e7887..f136eec7be 100644
--- a/src/sbbs3/scfg/scfgxfr2.c
+++ b/src/sbbs3/scfg/scfgxfr2.c
@@ -210,7 +210,8 @@ while(1) {
 		uifc.changes=1;
 		continue;
 	}
-	if((i&MSK_ON)==MSK_DEL) {
+	if((i&MSK_ON)==MSK_DEL || (i&MSK_ON) == MSK_CUT) {
+		int msk = i&MSK_ON;
 		i&=MSK_OFF;
 		uifc.helpbuf=
 			"`Delete All Data in Library:`\n"
@@ -236,6 +237,8 @@ while(1) {
 						strcpy(tmp,cfg.dir[j]->data_dir);
 					delfiles(tmp,str);
 				}
+		if(msk == MSK_CUT)
+			savlib = *cfg.lib[i];
 		free(cfg.lib[i]);
 		for(j=0;j<cfg.total_dirs;) {
 			if(cfg.dir[j]->lib==i) {
@@ -896,7 +899,8 @@ while(1) {
 		uifc.changes=1;
 		continue;
 	}
-	if((i&MSK_ON)==MSK_DEL) {
+	if((i&MSK_ON)==MSK_DEL || (i&MSK_ON) == MSK_CUT) {
+		int msk = i&MSK_ON;
 		i&=MSK_OFF;
 		uifc.helpbuf=
 			"`Delete Directory Data Files:`\n"
@@ -923,6 +927,8 @@ while(1) {
 			if(j==0)
 					delfiles(data_dir,str); 
 		}
+		if(msk == MSK_CUT)
+			savdir = *cfg.dir[dirnum[i]];
 		free(cfg.dir[dirnum[i]]);
 		cfg.total_dirs--;
 		for(j=dirnum[i];j<cfg.total_dirs;j++)
diff --git a/src/sbbs3/scfg/scfgxtrn.c b/src/sbbs3/scfg/scfgxtrn.c
index f87b111e95..cfb3cbd2a6 100644
--- a/src/sbbs3/scfg/scfgxtrn.c
+++ b/src/sbbs3/scfg/scfgxtrn.c
@@ -356,8 +356,11 @@ while(1) {
 		uifc.changes=1;
 		continue; 
 	}
-	if((i&MSK_ON)==MSK_DEL) {
+	if((i&MSK_ON)==MSK_DEL || (i&MSK_ON) == MSK_CUT) {
+		int msk = i&MSK_ON;
 		i&=MSK_OFF;
+		if(msk == MSK_CUT)
+			savevent = *cfg.event[i];
 		free(cfg.event[i]);
 		cfg.total_events--;
 		for(j=i;j<cfg.total_events;j++)
@@ -845,8 +848,11 @@ while(1) {
 		uifc.changes=TRUE;
 		continue; 
 	}
-	if((i&MSK_ON)==MSK_DEL) {
+	if((i&MSK_ON)==MSK_DEL || (i&MSK_ON) == MSK_CUT) {
+		int msk = i&MSK_ON;
 		i&=MSK_OFF;
+		if(msk == MSK_CUT)
+			savxtrn = *cfg.xtrn[xtrnnum[i]];
 		free(cfg.xtrn[xtrnnum[i]]);
 		cfg.total_xtrns--;
 		for(j=xtrnnum[i];j<cfg.total_xtrns;j++)
@@ -1534,8 +1540,11 @@ while(1) {
 		uifc.changes=TRUE;
 		continue; 
 	}
-	if((i&MSK_ON)==MSK_DEL) {
+	if((i&MSK_ON)==MSK_DEL || (i&MSK_ON) == MSK_CUT) {
+		int msk = i&MSK_ON;
 		i&=MSK_OFF;
+		if(msk == MSK_CUT)
+			savxedit = *cfg.xedit[i];
 		free(cfg.xedit[i]);
 		cfg.total_xedits--;
 		for(j=i;j<cfg.total_xedits;j++)
@@ -2095,8 +2104,11 @@ while(1) {
 		uifc.changes=TRUE;
 		continue; 
 	}
-	if((i&MSK_ON)==MSK_DEL) {
+	if((i&MSK_ON)==MSK_DEL || (i&MSK_ON) == MSK_CUT) {
+		int msk = i&MSK_ON;
 		i&=MSK_OFF;
+		if(msk == MSK_CUT)
+			savxtrnsec = *cfg.xtrnsec[i];
 		free(cfg.xtrnsec[i]);
 		for(j=0;j<cfg.total_xtrns;) {
 			if(cfg.xtrn[j]->sec==i) {	 /* delete xtrns of this group */
@@ -2258,8 +2270,11 @@ while(1) {
 		uifc.changes=TRUE;
 		continue; 
 	}
-	if((i&MSK_ON)==MSK_DEL) {
+	if((i&MSK_ON)==MSK_DEL || (i&MSK_ON) == MSK_CUT) {
+		int msk = i&MSK_ON;
 		i&=MSK_OFF;
+		if(msk == MSK_CUT)
+			savhotkey = *cfg.hotkey[i];
 		free(cfg.hotkey[i]);
 		cfg.total_hotkeys--;
 		for(j=i;j<cfg.total_hotkeys;j++)
-- 
GitLab