Skip to content
Snippets Groups Projects
Commit 1c630caf authored by rswindell's avatar rswindell
Browse files

Created new console output method: sbbs_t::backfill():

it displays a string of text and fills the background color up to the
specified percentage fo the string length. I will be using it for displaying
poll results, but it could possibly be used for progress displays and such.
The colors used are configured via the "backfill" and "unfill" attributes in
ctrl/attr.cfg.
parent 79cebbe3
Branches
Tags
No related merge requests found
...@@ -621,4 +621,23 @@ bool sbbs_t::msgabort() ...@@ -621,4 +621,23 @@ bool sbbs_t::msgabort()
return(false); return(false);
} }
int sbbs_t::backfill(const char* str, float pct)
{
uint8_t atr;
int len;
if(!term_supports(ANSI))
return bputs(str);
len = strlen(str);
for(int i=0; i<len; i++) {
if(((float)i / len)*100.0 <= pct)
atr = cfg.color[clr_backfill];
else
atr = cfg.color[clr_unfill];
if(curatr != atr) attr(atr);
outchar(str[i]);
}
attr(LIGHTGRAY);
return len;
}
...@@ -674,6 +674,7 @@ public: ...@@ -674,6 +674,7 @@ public:
void cursor_left(int count=1); void cursor_left(int count=1);
void cursor_right(int count=1); void cursor_right(int count=1);
long term_supports(long cmp_flags=0); long term_supports(long cmp_flags=0);
int backfill(const char* str, float pct);
/* getstr.cpp */ /* getstr.cpp */
size_t getstr_offset; size_t getstr_offset;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment