X-Git-Url: https://plomlompom.com/repos/foo.html?a=blobdiff_plain;f=windows.c;h=31da8333d91c35cd4b3b8671cc37676e99c2a796;hb=47ba3228624b18452e47de53e33ac8c3095319a5;hp=5d924e9327001d4127904b8cf9eac6dafa8cfafb;hpb=ac4305d47335de070f5f940220d0e9d6be32fe49;p=plomrogue
diff --git a/windows.c b/windows.c
index 5d924e9..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)
@@ -151,14 +152,9 @@ void draw_windows_borders (struct Win * win, struct Win * win_active, struct Cor
if (0 != win->next) {
draw_windows_borders (win->next, win_active, corners, ccount + 1); } }
-void draw_window(struct Win * win) {
-// Draw window content if visible.
- if (win->height > 1 && win->width > 1)
- win->draw(win); }
-
void draw_windows (struct Win * win) {
// Draw contents of all windows in window chain from win on.
- draw_window(win);
+ win->draw(win);
if (0 != win->next) {
draw_windows (win->next); } }