diff --git a/README.md b/README.md index ec0084c..3f40a71 100644 --- a/README.md +++ b/README.md @@ -116,8 +116,8 @@ Build yours by copying `irc9rc-example` to `irc9rc` next to the binary (or to | |-#help(3) | | \-alice | [10:21] hello there |* irc.other | [10:22] hi -\______________________/ [10:22] * alice!u@host joined #help ----------------------------------------------------------------- +| | [10:22] * alice!u@host joined #help +\______________________/---------------------------------------- [10:23] (me@irc.example:6697 [TLS]) > your message here ``` diff --git a/irc9.c b/irc9.c index 04ac8df..a84331f 100644 --- a/irc9.c +++ b/irc9.c @@ -2245,7 +2245,7 @@ static void layout(void) treew = cols >= 60 ? TREEW : (cols >= 30 ? 16 : 8); if (copy_view) treew = 0; else if (treew > cols / 2) treew = cols / 2; - mainh = lines > 4 ? lines - 4 : 0; + mainh = lines > 5 ? lines - 5 : lines == 5; } static void terminal_move(int row, int col) @@ -2422,26 +2422,27 @@ static int irc_to_ansi_color(int color) static void draw_tree(void) { - if (treew < 2 || mainh < 2) return; + int bottom = lines - 4; + if (treew < 2 || bottom < 2) return; terminal_accent(); terminal_move(1, 0); putchar('/'); terminal_repeat('-', treew - 2); putchar('\\'); - for (int row = 2; row < mainh; row++) { + for (int row = 2; row < bottom; row++) { terminal_move(row, 0); putchar('|'); terminal_move(row, treew - 1); putchar('|'); } - terminal_move(mainh, 0); + terminal_move(bottom, 0); putchar('\\'); terminal_repeat('_', treew - 2); putchar('/'); fputs("\033[0m", stdout); int y = 1; for (Server *s = servers; s; s = s->next) { - if (y >= mainh - 1) break; + if (y >= bottom - 1) break; int selected = (serverwin(s) == curwin); if (treew > 4) { terminal_move(y, 1); @@ -2452,7 +2453,7 @@ static void draw_tree(void) } y++; for (Window *w = s->windows->next; w; w = w->next) { - if (y >= mainh - 1) break; + if (y >= bottom - 1) break; char label[CHANLEN + 16]; if (w->unread) snprintf(label, sizeof label, "%s(%d)", w->name, w->unread); else snprintf(label, sizeof label, "%s", w->name); @@ -2620,14 +2621,20 @@ static void draw_main(void) } } +static void draw_bottom_divider(void) +{ + if (lines < 4) return; + int left = lines > 5 && treew >= 2 ? treew : 0; + terminal_move(lines - (lines > 5 ? 4 : 3), left); + terminal_accent(); + terminal_repeat('-', cols - left); + fputs("\033[0m", stdout); +} + static void draw_status(void) { status_minute = time(NULL) / 60; if (lines < 4) return; - terminal_move(lines - 3, 0); - terminal_accent(); - terminal_repeat('-', cols); - fputs("\033[0m", stdout); fputs(terminal_color ? "\033[1m" : "\033[7m", stdout); terminal_move(lines - 2, 0); terminal_repeat(' ', cols); @@ -2692,6 +2699,7 @@ static void redraw(void) draw_title(); draw_tree(); draw_main(); + draw_bottom_divider(); draw_status(); draw_input(); fputs("\033[?25h", stdout);