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

Refactor the internal message editor /D command to support deletion of ranges

Supporting the deletion of ranges of lines (e.g. 10-20 rather than one line
at a time) was a big ommission for a long time.
parent 0a1265a0
No related branches found
No related tags found
No related merge requests found
......@@ -1053,7 +1053,7 @@ uint sbbs_t::msgeditor(char *buf, const char *top, char *title, uint maxlines, u
continue;
}
}
if(strin[0]=='/' && strlen(strin)<8) {
if(strin[0]=='/' && strlen(strin)<16) {
if(!stricmp(strin,"/DEBUG") && SYSOP) {
bprintf("\r\nline=%d lines=%d (%d), rows=%d\r\n",line,lines,(int)strListCount(str), rows);
continue;
......@@ -1062,26 +1062,35 @@ uint sbbs_t::msgeditor(char *buf, const char *top, char *title, uint maxlines, u
strListFree(&str);
return(0);
}
else if(toupper(strin[1])=='D') { /* delete a line */
if(str[0] == NULL)
continue;
else if(toupper(strin[1])=='D') { // delete line(s)
lines = strListCount(str);
i=atoi(strin+2)-1;
if(i==-1) /* /D means delete last line */
i=lines-1;
if(i>=(int)lines || i<0)
bputs(text[InvalidLineNumber]);
else {
free(str[i]);
lines--;
while(i<(int)lines) {
str[i]=str[i+1];
i++;
char* p = strin + 2;
int first = atoi(p) - 1;
if(first < 0 || (uint)first >= lines) {
if(*p) {
bputs(text[InvalidLineNumber]);
continue;
}
first = lines - 1; // /D means delete last line
if(first < 0)
continue;
}
int last = first;
SKIP_DIGIT(p);
FIND_CHAR(p, '-');
if(*p == '-') {
++p;
last = atoi(p) - 1;
if(last < first || (uint)last >= lines) {
bputs(text[InvalidLineNumber]);
continue;
}
str[i] = NULL;
if(line>lines)
line=lines;
}
int count = (last - first) + 1;
strListFastDelete(str, first, count);
lines -= count;
if(line>lines)
line=lines;
continue;
}
else if(toupper(strin[1])=='I') { /* insert a line before number x */
......
......@@ -8,6 +8,7 @@
h/Ex nEdit Line x
h/D nDelete Last Line
h/Dx nDelete Line x
h/Dx-y nDelete Lines x through y
h/I nInsert Line Before Last
h/Ix nInsert Line Before Line x
h/T nEdit Message Subject
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment