From e2790b42f3d33e5342af6948a21a48b6fdd5a22a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C5=99emysl=20Eric=20Janouch?= Date: Mon, 11 Oct 2021 20:46:30 +0200 Subject: [PATCH] sdtui: fix introductory message centring --- src/sdtui.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/src/sdtui.c b/src/sdtui.c index b2e7066..5e00d7c 100644 --- a/src/sdtui.c +++ b/src/sdtui.c @@ -1087,16 +1087,13 @@ app_show_message (Application *self, const gchar *lines[], gsize len) while (len-- && i < LINES - TOP_BAR_CUTOFF) { - move (TOP_BAR_CUTOFF + i, 0); - clrtoeol (); - - gint x = (COLS - g_utf8_strlen (*lines, -1)) / 2; - if (x < 0) - x = 0; - RowBuffer buf = row_buffer_make (self); row_buffer_append (&buf, *lines, 0); - move (TOP_BAR_CUTOFF + i, x); + gint x = (COLS - buf.total_width) / 2; + + move (TOP_BAR_CUTOFF + i, 0); + clrtoeol (); + move (TOP_BAR_CUTOFF + i, MAX (x, 0)); row_buffer_finish (&buf, -1, 0); lines++;