From 47ba3228624b18452e47de53e33ac8c3095319a5 Mon Sep 17 00:00:00 2001 From: Christian Heller Date: Thu, 2 May 2013 04:46:22 +0200 Subject: [PATCH] Repaired buggy window title display. --- windows.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/windows.c b/windows.c index 8b82d60..31da833 100644 --- a/windows.c +++ b/windows.c @@ -121,10 +121,11 @@ void draw_window_borders (struct Win * win, char active) { mvwaddch(wgetparent(win->curses_win), getbegy(win->curses_win) - 1, x, '-'); mvwaddch(wgetparent(win->curses_win), getbegy(win->curses_win) + win->height, x, '-'); } char min_title_length_visible = 3; // 1 char minimal, plus 2 chars for decoration left/right of title - if (win->width > min_title_length_visible) { - int title_length = strlen(win->title); - int title_offset = (((win->width) - (title_length + 2)) / 2); // + 2 is for decoration - int length_visible = strnlen(win->title, win->width - min_title_length_visible); + if (win->width >= min_title_length_visible) { + int title_offset = 0; + if (win->width > strlen(win->title) + 2) + title_offset = (win->width - (strlen(win->title) + 2)) / 2; // + 2 is for decoration + int length_visible = strnlen(win->title, win->width - 2); char title[length_visible + 3]; char decoration = ' '; if (1 == active) -- 2.30.2