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

Add P_CENTER mode flag for printing centered multline text buffers/strings

When used with putmsg(), centers the output based on the longest line.
When used with printfile() line at a time mode, centers each line.
When used with printfile() open/close mode, centers just the first line.

So it's a little weird and wonky.
parent 51ba2cae
No related branches found
No related tags found
No related merge requests found
...@@ -125,6 +125,13 @@ char sbbs_t::putmsgfrag(const char* buf, int& mode, unsigned org_cols, JSObject* ...@@ -125,6 +125,13 @@ char sbbs_t::putmsgfrag(const char* buf, int& mode, unsigned org_cols, JSObject*
l += 9; // Skip "<NUL>WRAPOFF@" l += 9; // Skip "<NUL>WRAPOFF@"
} }
} }
if (mode & P_CENTER) {
size_t widest = widest_line(str + l);
if (widest < term->cols && term->column == 0) {
term->cursor_right((term->cols - widest) / 2);
mode |= P_INDENT;
}
}
while (l < len && (mode & P_NOABORT || !msgabort()) && online) { while (l < len && (mode & P_NOABORT || !msgabort()) && online) {
switch (str[l]) { switch (str[l]) {
......
...@@ -701,6 +701,7 @@ typedef enum { // Values for xtrn_t.event ...@@ -701,6 +701,7 @@ typedef enum { // Values for xtrn_t.event
#define P_INDENT (1 << 19) // Indent lines to current cursor column #define P_INDENT (1 << 19) // Indent lines to current cursor column
#define P_ATCODES (1 << 20) // Trusted @-codes in formatted string #define P_ATCODES (1 << 20) // Trusted @-codes in formatted string
#define P_MODS (1 << 21) // Display from mods/text dir, if file is there #define P_MODS (1 << 21) // Display from mods/text dir, if file is there
#define P_CENTER (1 << 22) // Center the output based on widest line
#define P_XATTR_SHIFT 20 #define P_XATTR_SHIFT 20
#define P_WILDCAT (SM_WILDCAT << P_XATTR_SHIFT) #define P_WILDCAT (SM_WILDCAT << P_XATTR_SHIFT)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment