Commit d1643d21 authored by rswindell's avatar rswindell
Browse files

Using new console abstraction functions (e.g. cursor_left/right, cleartoeol).

parent 43e643e9
...@@ -965,7 +965,7 @@ void sbbs_t::privchat(bool local) ...@@ -965,7 +965,7 @@ void sbbs_t::privchat(bool local)
,thisnode.misc&NODE_NMSG ? 'M':SP); ,thisnode.misc&NODE_NMSG ? 'M':SP);
attr(cfg.color[clr_chatlocal]); attr(cfg.color[clr_chatlocal]);
for(x=13,y=0;x<rows;x++,y++) { for(x=13,y=0;x<rows;x++,y++) {
bprintf("\x1b[%d;1H\x1b[K",x+1); rprintf("\x1b[%d;1H\x1b[K",x+1);
if(y<=localline) if(y<=localline)
bprintf("%s\r\n",localbuf[y]); } bprintf("%s\r\n",localbuf[y]); }
GOTOXY(1,local_y=(15+localline)); GOTOXY(1,local_y=(15+localline));
...@@ -980,7 +980,7 @@ void sbbs_t::privchat(bool local) ...@@ -980,7 +980,7 @@ void sbbs_t::privchat(bool local)
CRLF; CRLF;
local_y++; local_y++;
if(sys_status&SS_SPLITP) if(sys_status&SS_SPLITP)
bputs("\x1b[K"); cleartoeol();
} }
} }
// SYNC; // SYNC;
...@@ -1067,7 +1067,11 @@ void sbbs_t::privchat(bool local) ...@@ -1067,7 +1067,11 @@ void sbbs_t::privchat(bool local)
CRLF; CRLF;
remote_y++; remote_y++;
if(sys_status&SS_SPLITP) if(sys_status&SS_SPLITP)
bputs("\x1b[K"); } } } } cleartoeol();
}
}
}
}
ch=0; ch=0;
write(in,&ch,1); write(in,&ch,1);
......
...@@ -61,7 +61,7 @@ size_t sbbs_t::getstr(char *strout, size_t maxlen, long mode) ...@@ -61,7 +61,7 @@ size_t sbbs_t::getstr(char *strout, size_t maxlen, long mode)
attr(cfg.color[clr_inputline]); attr(cfg.color[clr_inputline]);
for(i=0;i<maxlen;i++) for(i=0;i<maxlen;i++)
outchar(SP); outchar(SP);
bprintf("\x1b[%dD",maxlen); cursor_left(maxlen);
} }
if(wordwrap[0]) { if(wordwrap[0]) {
strcpy(str1,wordwrap); strcpy(str1,wordwrap);
...@@ -83,7 +83,7 @@ size_t sbbs_t::getstr(char *strout, size_t maxlen, long mode) ...@@ -83,7 +83,7 @@ size_t sbbs_t::getstr(char *strout, size_t maxlen, long mode)
} }
rputs(str1); rputs(str1);
if(mode&K_EDIT && !(mode&(K_LINE|K_AUTODEL)) && useron.misc&ANSI) if(mode&K_EDIT && !(mode&(K_LINE|K_AUTODEL)) && useron.misc&ANSI)
bputs("\x1b[K"); /* destroy to eol */ cleartoeol(); /* destroy to eol */
} }
SAFECOPY(undo,str1); SAFECOPY(undo,str1);
...@@ -111,11 +111,7 @@ size_t sbbs_t::getstr(char *strout, size_t maxlen, long mode) ...@@ -111,11 +111,7 @@ size_t sbbs_t::getstr(char *strout, size_t maxlen, long mode)
if(i>l) if(i>l)
i=l; i=l;
if(l-i) { if(l-i) {
if(useron.misc&ANSI) cursor_left(l-i);
bprintf("\x1b[%dD",l-i);
else
for(i=0;i<l-i;i++)
outchar(BS);
} }
} }
...@@ -156,7 +152,7 @@ size_t sbbs_t::getstr(char *strout, size_t maxlen, long mode) ...@@ -156,7 +152,7 @@ size_t sbbs_t::getstr(char *strout, size_t maxlen, long mode)
for(x=l;x>i;x--) for(x=l;x>i;x--)
str1[x]=str1[x-1]; str1[x]=str1[x-1];
rprintf("%.*s",l-i,str1+i); rprintf("%.*s",l-i,str1+i);
rprintf("\x1b[%dD",l-i); cursor_left(l-i);
#if 0 #if 0
if(i==maxlen-1) if(i==maxlen-1)
console&=~CON_INSERT; console&=~CON_INSERT;
...@@ -166,7 +162,7 @@ size_t sbbs_t::getstr(char *strout, size_t maxlen, long mode) ...@@ -166,7 +162,7 @@ size_t sbbs_t::getstr(char *strout, size_t maxlen, long mode)
break; break;
case CTRL_B: /* Ctrl-B Beginning of Line */ case CTRL_B: /* Ctrl-B Beginning of Line */
if(useron.misc&ANSI && i && !(mode&K_NOECHO)) { if(useron.misc&ANSI && i && !(mode&K_NOECHO)) {
bprintf("\x1b[%dD",i); cursor_left(i);
i=0; i=0;
} }
break; break;
...@@ -181,7 +177,7 @@ size_t sbbs_t::getstr(char *strout, size_t maxlen, long mode) ...@@ -181,7 +177,7 @@ size_t sbbs_t::getstr(char *strout, size_t maxlen, long mode)
outchar(SP); outchar(SP);
x++; x++;
} }
bprintf("\x1b[%dD",x-i); /* move cursor back */ cursor_left(x-i); /* move cursor back */
z=i; z=i;
while(z<l-(x-i)) { /* move chars in string */ while(z<l-(x-i)) { /* move chars in string */
outchar(str1[z]=str1[z+(x-i)]); outchar(str1[z]=str1[z+(x-i)]);
...@@ -191,19 +187,19 @@ size_t sbbs_t::getstr(char *strout, size_t maxlen, long mode) ...@@ -191,19 +187,19 @@ size_t sbbs_t::getstr(char *strout, size_t maxlen, long mode)
outchar(SP); outchar(SP);
z++; z++;
} }
bprintf("\x1b[%dD",z-i); cursor_left(z-i);
l-=x-i; /* l=new length */ l-=x-i; /* l=new length */
} }
break; break;
case CTRL_E: /* Ctrl-E End of line */ case CTRL_E: /* Ctrl-E End of line */
if(useron.misc&ANSI && i<l) { if(useron.misc&ANSI && i<l) {
bprintf("\x1b[%dC",l-i); /* move cursor to eol */ cursor_right(l-i); /* move cursor to eol */
i=l; i=l;
} }
break; break;
case CTRL_F: /* Ctrl-F move cursor forewards */ case CTRL_F: /* Ctrl-F move cursor forewards */
if(i<l && (useron.misc&ANSI)) { if(i<l && (useron.misc&ANSI)) {
bputs("\x1b[C"); /* move cursor right one */ cursor_right(); /* move cursor right one */
i++; i++;
} }
break; break;
...@@ -266,7 +262,7 @@ size_t sbbs_t::getstr(char *strout, size_t maxlen, long mode) ...@@ -266,7 +262,7 @@ size_t sbbs_t::getstr(char *strout, size_t maxlen, long mode)
z++; z++;
} }
outchar(SP); /* write over the last char */ outchar(SP); /* write over the last char */
bprintf("\x1b[%dD",(l-i)+1); cursor_left((l-i)+1);
} }
else if(!(mode&K_NOECHO)) else if(!(mode&K_NOECHO))
bputs("\b \b"); bputs("\b \b");
...@@ -338,7 +334,7 @@ size_t sbbs_t::getstr(char *strout, size_t maxlen, long mode) ...@@ -338,7 +334,7 @@ size_t sbbs_t::getstr(char *strout, size_t maxlen, long mode)
i++; i++;
while(str1[i]==SP && i<l) while(str1[i]==SP && i<l)
i++; i++;
bprintf("\x1b[%dC",i-x); cursor_right(i-x);
} }
break; break;
case CTRL_R: /* Ctrl-R Redraw Line */ case CTRL_R: /* Ctrl-R Redraw Line */
...@@ -371,7 +367,7 @@ size_t sbbs_t::getstr(char *strout, size_t maxlen, long mode) ...@@ -371,7 +367,7 @@ size_t sbbs_t::getstr(char *strout, size_t maxlen, long mode)
outchar(SP); outchar(SP);
z++; z++;
} }
bprintf("\x1b[%dD",z-i); /* back to new x corridnant */ cursor_left(z-i); /* back to new x corridnant */
l-=x-i; /* l=new length */ l-=x-i; /* l=new length */
} else { } else {
while(i && str1[i-1]==SP) { while(i && str1[i-1]==SP) {
...@@ -391,7 +387,7 @@ size_t sbbs_t::getstr(char *strout, size_t maxlen, long mode) ...@@ -391,7 +387,7 @@ size_t sbbs_t::getstr(char *strout, size_t maxlen, long mode)
case CTRL_Y: /* Ctrl-Y Delete to end of line */ case CTRL_Y: /* Ctrl-Y Delete to end of line */
if(i!=l) { /* if not at EOL */ if(i!=l) { /* if not at EOL */
if(useron.misc&ANSI && !(mode&K_NOECHO)) if(useron.misc&ANSI && !(mode&K_NOECHO))
bputs("\x1b[K"); cleartoeol();
l=i; l=i;
break; break;
} }
...@@ -401,7 +397,8 @@ size_t sbbs_t::getstr(char *strout, size_t maxlen, long mode) ...@@ -401,7 +397,8 @@ size_t sbbs_t::getstr(char *strout, size_t maxlen, long mode)
l=0; l=0;
else { else {
if(useron.misc&ANSI) { if(useron.misc&ANSI) {
bprintf("\x1b[%uD\x1b[K",i); cursor_left(i);
cleartoeol();
l=0; l=0;
} else { } else {
while(i<l) { while(i<l) {
...@@ -422,7 +419,7 @@ size_t sbbs_t::getstr(char *strout, size_t maxlen, long mode) ...@@ -422,7 +419,7 @@ size_t sbbs_t::getstr(char *strout, size_t maxlen, long mode)
i=l=strlen(str1); i=l=strlen(str1);
rprintf("\r%s",str1); rprintf("\r%s",str1);
if(useron.misc&ANSI) if(useron.misc&ANSI)
bputs("\x1b[K"); /* destroy to eol */ cleartoeol(); /* destroy to eol */
break; break;
case 28: /* Ctrl-\ Previous word */ case 28: /* Ctrl-\ Previous word */
if(i && (useron.misc&ANSI) && !(mode&K_NOECHO)) { if(i && (useron.misc&ANSI) && !(mode&K_NOECHO)) {
...@@ -431,7 +428,7 @@ size_t sbbs_t::getstr(char *strout, size_t maxlen, long mode) ...@@ -431,7 +428,7 @@ size_t sbbs_t::getstr(char *strout, size_t maxlen, long mode)
i--; i--;
while(str1[i-1]!=SP && i) while(str1[i-1]!=SP && i)
i--; i--;
bprintf("\x1b[%dD",x-i); cursor_left(x-i);
} }
break; break;
case 29: /* Ctrl-]/Left Arrow Reverse Cursor Movement */ case 29: /* Ctrl-]/Left Arrow Reverse Cursor Movement */
...@@ -441,7 +438,7 @@ size_t sbbs_t::getstr(char *strout, size_t maxlen, long mode) ...@@ -441,7 +438,7 @@ size_t sbbs_t::getstr(char *strout, size_t maxlen, long mode)
break; break;
} }
if((useron.misc&ANSI) && !(mode&K_NOECHO)) { if((useron.misc&ANSI) && !(mode&K_NOECHO)) {
bputs("\x1b[D"); /* move cursor left one */ cursor_left(); /* move cursor left one */
i--; i--;
} }
break; break;
...@@ -480,7 +477,7 @@ size_t sbbs_t::getstr(char *strout, size_t maxlen, long mode) ...@@ -480,7 +477,7 @@ size_t sbbs_t::getstr(char *strout, size_t maxlen, long mode)
z++; z++;
} }
outchar(SP); /* write over the last char */ outchar(SP); /* write over the last char */
bprintf("\x1b[%dD",(l-i)+1); cursor_left((l-i)+1);
break; break;
default: default:
if(mode&K_WRAP && i==maxlen && ch>=SP && !(console&CON_INSERT)) { if(mode&K_WRAP && i==maxlen && ch>=SP && !(console&CON_INSERT)) {
...@@ -535,7 +532,7 @@ size_t sbbs_t::getstr(char *strout, size_t maxlen, long mode) ...@@ -535,7 +532,7 @@ size_t sbbs_t::getstr(char *strout, size_t maxlen, long mode)
for(x=l;x>i;x--) for(x=l;x>i;x--)
str1[x]=str1[x-1]; str1[x]=str1[x-1];
rprintf("%.*s",l-i,str1+i); rprintf("%.*s",l-i,str1+i);
rprintf("\x1b[%dD",l-i); cursor_left(l-i);
#if 0 #if 0
if(i==maxlen-1) { if(i==maxlen-1) {
bputs(" \b\b"); bputs(" \b\b");
......
...@@ -604,9 +604,9 @@ ulong sbbs_t::msgeditor(char *buf, char *top, char *title) ...@@ -604,9 +604,9 @@ ulong sbbs_t::msgeditor(char *buf, char *top, char *title)
putmsg(top,P_SAVEATR|P_NOATCODES); putmsg(top,P_SAVEATR|P_NOATCODES);
for(line=0;line<lines && !msgabort();line++) { /* display lines in buf */ for(line=0;line<lines && !msgabort();line++) { /* display lines in buf */
putmsg(str[line],P_SAVEATR|P_NOATCODES); putmsg(str[line],P_SAVEATR|P_NOATCODES);
if(useron.misc&ANSI) cleartoeol(); /* delete to end of line */
bputs("\x1b[K"); /* delete to end of line */ CRLF;
CRLF; } }
SYNC; SYNC;
if(online==ON_REMOTE) if(online==ON_REMOTE)
rioctl(IOSM|ABORT); rioctl(IOSM|ABORT);
...@@ -735,8 +735,7 @@ ulong sbbs_t::msgeditor(char *buf, char *top, char *title) ...@@ -735,8 +735,7 @@ ulong sbbs_t::msgeditor(char *buf, char *top, char *title)
putmsg(tmp,P_SAVEATR|P_NOATCODES); } putmsg(tmp,P_SAVEATR|P_NOATCODES); }
else else
putmsg(str[j],P_SAVEATR|P_NOATCODES); putmsg(str[j],P_SAVEATR|P_NOATCODES);
if(useron.misc&ANSI) cleartoeol(); /* delete to end of line */
bputs("\x1b[K"); /* delete to end of line */
CRLF; CRLF;
j++; } j++; }
SYNC; SYNC;
...@@ -776,7 +775,8 @@ ulong sbbs_t::msgeditor(char *buf, char *top, char *title) ...@@ -776,7 +775,8 @@ ulong sbbs_t::msgeditor(char *buf, char *top, char *title)
lines++; lines++;
if(console&CON_UPARROW) { if(console&CON_UPARROW) {
outchar(CR); outchar(CR);
bprintf("\x1b[A\x1b[K"); /* up one line, clear to eol */ cursor_up();
cleartoeol();
line-=2; } line-=2; }
} }
if(!online) { if(!online) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment