X-Git-Url: https://plomlompom.com/repos/berlin_corona.txt?a=blobdiff_plain;f=windows.c;h=31da8333d91c35cd4b3b8671cc37676e99c2a796;hb=3eb21ebb5bf34437530c06f17122e5570c8d2856;hp=8b82d60a1aac1007a0748fc3186cc26210d2c46d;hpb=e0f6898722d88af212b9fd658aa8a54226deabc3;p=plomrogue 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)