From c874292110366387822784ee2c1958d7babd90ab Mon Sep 17 00:00:00 2001 From: "Rob Swindell (on Debian Linux)" <rob@synchro.net> Date: Sat, 3 May 2025 22:43:48 -0700 Subject: [PATCH] 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. --- src/sbbs3/putmsg.cpp | 7 +++++++ src/sbbs3/sbbsdefs.h | 1 + 2 files changed, 8 insertions(+) diff --git a/src/sbbs3/putmsg.cpp b/src/sbbs3/putmsg.cpp index dfe3f464cc..12d599c342 100644 --- a/src/sbbs3/putmsg.cpp +++ b/src/sbbs3/putmsg.cpp @@ -125,6 +125,13 @@ char sbbs_t::putmsgfrag(const char* buf, int& mode, unsigned org_cols, JSObject* 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) { switch (str[l]) { diff --git a/src/sbbs3/sbbsdefs.h b/src/sbbs3/sbbsdefs.h index 63488ce0b2..92ff08c92d 100644 --- a/src/sbbs3/sbbsdefs.h +++ b/src/sbbs3/sbbsdefs.h @@ -701,6 +701,7 @@ typedef enum { // Values for xtrn_t.event #define P_INDENT (1 << 19) // Indent lines to current cursor column #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_CENTER (1 << 22) // Center the output based on widest line #define P_XATTR_SHIFT 20 #define P_WILDCAT (SM_WILDCAT << P_XATTR_SHIFT) -- GitLab