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