Skip to content
Snippets Groups Projects
Commit 961f1f58 authored by Rob Swindell's avatar Rob Swindell :speech_balloon:
Browse files

Support @-codes in text centered with the CENTER @-code

Note: this centering logic does not know the expanded-size of the @-code, so use a fixed-length @-code (e.g. with padding) or use the 'C' @-code format modifier instead.

Fix issue #418
parent b8345f80
No related branches found
No related tags found
1 merge request!463MRC mods by Codefenix (2024-10-20)
Pipeline #3161 passed
...@@ -775,7 +775,7 @@ void sbbs_t::inc_row(int count) ...@@ -775,7 +775,7 @@ void sbbs_t::inc_row(int count)
} }
} }
void sbbs_t::center(const char *instr, unsigned int columns) void sbbs_t::center(const char *instr, bool msg, unsigned int columns)
{ {
char str[256]; char str[256];
size_t len; size_t len;
...@@ -789,6 +789,9 @@ void sbbs_t::center(const char *instr, unsigned int columns) ...@@ -789,6 +789,9 @@ void sbbs_t::center(const char *instr, unsigned int columns)
carriage_return(); carriage_return();
if(len < columns) if(len < columns)
cursor_right((columns - len) / 2); cursor_right((columns - len) / 2);
if(msg)
putmsg(str, P_NONE);
else
bputs(str); bputs(str);
newline(); newline();
} }
......
...@@ -421,7 +421,7 @@ char sbbs_t::putmsgfrag(const char* buf, long& mode, long org_cols, JSObject* ob ...@@ -421,7 +421,7 @@ char sbbs_t::putmsgfrag(const char* buf, long& mode, long org_cols, JSObject* ob
tmp2[i++] = str[l++]; tmp2[i++] = str[l++];
tmp2[i] = 0; tmp2[i] = 0;
truncsp(tmp2); truncsp(tmp2);
center(tmp2); center(tmp2, /* msg: */true);
if(str[l] == '\r') if(str[l] == '\r')
l++; l++;
if(str[l] == '\n') if(str[l] == '\n')
......
...@@ -825,7 +825,7 @@ public: ...@@ -825,7 +825,7 @@ public:
int outchar(enum unicode_codepoint, const char* cp437_fallback = NULL); int outchar(enum unicode_codepoint, const char* cp437_fallback = NULL);
void inc_row(int count); void inc_row(int count);
void inc_column(int count); void inc_column(int count);
void center(const char *str, unsigned int columns = 0); void center(const char *str, bool msg = false, unsigned int columns = 0);
void wide(const char*); void wide(const char*);
void clearscreen(long term); void clearscreen(long term);
void clearline(void); void clearline(void);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment