Commit 074c693c authored by rswindell's avatar rswindell

Create sbbs_t::comprintf(), a direct-output printf(), used in place of rprintf()

when "extra raw" output is needed.
Use putcom() and comprintf() instead of rputs() and rprintf() for ANSI escape
sequences. This doesn't actually fix any problem, but since rputs() is
"less raw" than it used to be, let's use direct-output routines instead, for
ANSI output.
parent 0bcc0416
......@@ -225,7 +225,7 @@ bool sbbs_t::ansi_getxy(int* x, int* y)
*x=0;
*y=0;
putcom("\x1b[6n"); /* Request cusor position */
putcom("\x1b[6n"); /* Request cursor position */
time_t start=time(NULL);
sys_status&=~SS_ABORT;
......@@ -274,7 +274,7 @@ bool sbbs_t::ansi_getxy(int* x, int* y)
bool sbbs_t::ansi_gotoxy(int x, int y)
{
if(term_supports(ANSI)) {
rprintf("\x1b[%d;%dH",y,x);
comprintf("\x1b[%d;%dH",y,x);
if(x>0)
column=x-1;
lncntr=0;
......@@ -286,7 +286,7 @@ bool sbbs_t::ansi_gotoxy(int x, int y)
bool sbbs_t::ansi_save(void)
{
if(term_supports(ANSI)) {
rputs("\x1b[s");
putcom("\x1b[s");
return true;
}
return false;
......@@ -295,7 +295,7 @@ bool sbbs_t::ansi_save(void)
bool sbbs_t::ansi_restore(void)
{
if(term_supports(ANSI)) {
rputs("\x1b[u");
putcom("\x1b[u");
return true;
}
return false;
......
......@@ -1042,7 +1042,7 @@ void sbbs_t::privchat(bool local)
,thisnode.misc&NODE_NMSG ? 'M':' ');
attr(cfg.color[clr_chatlocal]);
for(x=13,y=0;x<rows;x++,y++) {
rprintf("\x1b[%d;1H\x1b[K",x+1);
comprintf("\x1b[%d;1H\x1b[K",x+1);
if(y<=localline)
bprintf("%s\r\n",localbuf[y]);
}
......
......@@ -451,6 +451,21 @@ int sbbs_t::rprintf(const char *fmt, ...)
return(rputs(sbuf));
}
/****************************************************************************/
/* Performs printf() using bbs putcom/outcom functions */
/****************************************************************************/
int sbbs_t::comprintf(const char *fmt, ...)
{
va_list argptr;
char sbuf[4096];
va_start(argptr,fmt);
vsnprintf(sbuf,sizeof(sbuf),fmt,argptr);
sbuf[sizeof(sbuf)-1]=0; /* force termination */
va_end(argptr);
return(putcom(sbuf));
}
/****************************************************************************/
/* Outputs destructive backspace */
/****************************************************************************/
......@@ -807,7 +822,7 @@ void sbbs_t::cursor_home(void)
{
long term = term_supports();
if(term&ANSI)
rputs("\x1b[H");
putcom("\x1b[H");
else if(term&PETSCII)
outcom(PETSCII_HOME);
else
......@@ -823,9 +838,9 @@ void sbbs_t::cursor_up(int count)
long term = term_supports();
if(term&ANSI) {
if(count>1)
rprintf("\x1b[%dA",count);
comprintf("\x1b[%dA",count);
else
rputs("\x1b[A");
putcom("\x1b[A");
} else {
if(term&PETSCII) {
for(int i=0;i<count;i++)
......@@ -840,9 +855,9 @@ void sbbs_t::cursor_down(int count)
return;
if(term_supports(ANSI)) {
if(count>1)
rprintf("\x1b[%dB",count);
comprintf("\x1b[%dB",count);
else
rputs("\x1b[B");
putcom("\x1b[B");
} else {
for(int i=0;i<count;i++)
line_feed();
......@@ -856,9 +871,9 @@ void sbbs_t::cursor_right(int count)
long term = term_supports();
if(term&ANSI) {
if(count>1)
rprintf("\x1b[%dC",count);
comprintf("\x1b[%dC",count);
else
rputs("\x1b[C");
putcom("\x1b[C");
} else {
for(int i=0;i<count;i++) {
if(term&PETSCII)
......@@ -877,9 +892,9 @@ void sbbs_t::cursor_left(int count)
long term = term_supports();
if(term&ANSI) {
if(count>1)
rprintf("\x1b[%dD",count);
comprintf("\x1b[%dD",count);
else
rputs("\x1b[D");
putcom("\x1b[D");
} else {
for(int i=0;i<count;i++) {
if(term&PETSCII)
......@@ -900,7 +915,7 @@ void sbbs_t::cleartoeol(void)
long term = term_supports();
if(term&ANSI)
rputs("\x1b[K");
putcom("\x1b[K");
else {
i=j=column;
while(++i<cols)
......@@ -917,7 +932,7 @@ void sbbs_t::cleartoeol(void)
void sbbs_t::cleartoeos(void)
{
if(term_supports(ANSI))
rputs("\x1b[J");
putcom("\x1b[J");
}
void sbbs_t::set_output_rate(enum output_rate speed)
......@@ -942,7 +957,7 @@ void sbbs_t::set_output_rate(enum output_rate speed)
val = 11;
break;
}
rprintf("\x1b[;%u*r", val);
comprintf("\x1b[;%u*r", val);
cur_output_rate = speed;
}
}
......
......@@ -723,6 +723,11 @@ public:
int rprintf(const char *fmt, ...) /* BBS raw printf function */
#if defined(__GNUC__) // Catch printf-format errors
__attribute__ ((format (printf, 2, 3))); // 1 is 'this'
#endif
;
int comprintf(const char *fmt, ...) /* BBS direct-comm printf function */
#if defined(__GNUC__) // Catch printf-format errors
__attribute__ ((format (printf, 2, 3))); // 1 is 'this'
#endif
;
void backspace(int count=1); /* Output destructive backspace(s) via outchar */
......
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