summaryrefslogtreecommitdiffstats
path: root/InfoScreen.c
diff options
context:
space:
mode:
authorryenus <ryenus@gmail.com>2020-10-03 00:12:31 +0800
committercgzones <cgzones@googlemail.com>2020-10-05 12:18:05 +0200
commitff455b0004080a260a63f12ca8bf7c148eab6ee7 (patch)
tree74816461597e0b2c11a0812dbca83b0dfda2215c /InfoScreen.c
parent72613a38f40840df99955d555c9bd5d53368e52e (diff)
limit max screen title length to window width
Applies screen title truncating to all InfoScreen classes.
Diffstat (limited to 'InfoScreen.c')
-rw-r--r--InfoScreen.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/InfoScreen.c b/InfoScreen.c
index 35c16473..52117d0b 100644
--- a/InfoScreen.c
+++ b/InfoScreen.c
@@ -42,14 +42,21 @@ InfoScreen* InfoScreen_done(InfoScreen* this) {
void InfoScreen_drawTitled(InfoScreen* this, const char* fmt, ...) {
va_list ap;
va_start(ap, fmt);
+
+ char* title = xMalloc(COLS + 1);
+ int len = vsnprintf(title, COLS + 1, fmt, ap);
+ if (len > COLS) {
+ memset(&title[COLS - 3], '.', 3);
+ }
+
attrset(CRT_colors[METER_TEXT]);
mvhline(0, 0, ' ', COLS);
- (void) wmove(stdscr, 0, 0);
- vw_printw(stdscr, fmt, ap);
+ mvwprintw(stdscr, 0, 0, title);
attrset(CRT_colors[DEFAULT_COLOR]);
this->display->needsRedraw = true;
Panel_draw(this->display, true);
IncSet_drawBar(this->inc);
+ free(title);
va_end(ap);
}

© 2014-2024 Faster IT GmbH | imprint | privacy policy