Newer
Older

rswindell
committed
checkline();
if(sys_status&SS_ABORT)
return(true);
if(!online)
return(true);
return(false);
}
int sbbs_t::backfill(const char* instr, float pct, int full_attr, int empty_attr)
char* str = strip_ctrl(instr, NULL);
if(!term_supports(ANSI))
bputs(str);
else {
for(int i=0; i<len; i++) {
if(((float)(i+1) / len)*100.0 <= pct)
atr = full_attr;
else
atr = empty_attr;
if(curatr != atr) attr(atr);
outchar(str[i]);
}
attr(save_atr);
free(str);
void sbbs_t::progress(const char* text, int count, int total, int interval)
{
char str[128];
if(cfg.node_num == 0)
return; // Don't output this for events
if((count%interval) != 0)
return;
if(text == NULL) text = "";
float pct = ((float)count/total)*100.0F;
SAFEPRINTF2(str, "[ %-8s %4.1f%% ]", text, pct);
cursor_left(backfill(str, pct, cfg.color[clr_progress_full], cfg.color[clr_progress_empty]));
}
struct savedline {
char buf[LINE_BUFSIZE+1]; /* Line buffer (i.e. ANSI-encoded) */
uint beg_attr; /* Starting attribute of each line */
uint end_attr; /* Ending attribute of each line */
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
long column; /* Current column number */
};
bool sbbs_t::saveline(void)
{
struct savedline line;
line.beg_attr = latr;
line.end_attr = curatr;
line.column = column;
snprintf(line.buf, sizeof(line.buf), "%.*s", lbuflen, lbuf);
TERMINATE(line.buf);
lbuflen=0;
return listPushNodeData(&savedlines, &line, sizeof(line)) != NULL;
}
bool sbbs_t::restoreline(void)
{
struct savedline* line = (struct savedline*)listPopNode(&savedlines);
if(line == NULL)
return false;
lbuflen=0;
attr(line->beg_attr);
rputs(line->buf);
curatr = line->end_attr;
column = line->column;
free(line);
return true;
}