diff --git a/README.md b/README.md index 97820a9..643ea91 100644 --- a/README.md +++ b/README.md @@ -134,14 +134,14 @@ Build yours by copying `irc9rc-example` to `irc9rc` next to the binary (or to ``` [irc9] irc.example / #general -/----------------------\/--------------------------------------\ -|*irc.example | General discussion -| |-#general |---------------------------------------| -| |-#help(3) | -| \-alice | [10:21] hello there -|*irc.other | [10:22] hi -| | [10:22] * alice!u@host joined #help -\----------------------/\--------------------------------------/ +┌──────────────────────┐┌───────────────────────────────────────┐ +│*irc.example ││ General discussion │ +| |-#general |├───────────────────────────────────────┤ +│ |-#help(3) ││ │ +│ \-alice ││ [10:21] hello there │ +│*irc.other ││ [10:22] hi │ +│ ││ [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 afa3fb8..19c488b 100644 --- a/irc9.c +++ b/irc9.c @@ -2621,7 +2621,7 @@ static void handle_key(int c) static void layout(void) { treew = cols >= 60 ? TREEW : (cols >= 30 ? 16 : 8); - if (copy_view) treew = 0; + if (copy_view || lines < 6) treew = 0; else if (treew > cols / 2) treew = cols / 2; chat_top = lines >= 7 ? 2 : 1; mainh = lines >= 5 ? lines - 3 - chat_top : 0; @@ -2814,26 +2814,35 @@ static long long server_unread_messages(const Server *s) return unread; } +static void draw_horizontal_border(int row, int left, int width, + const char *opening, const char *closing) +{ + terminal_move(row, left); + terminal_accent(); + if (width > 1) { + fputs(opening, stdout); + for (int i = 0; i < width - 2; i++) fputs("─", stdout); + fputs(closing, stdout); + } else if (width == 1) { + fputs("─", stdout); + } + fputs("\033[0m", stdout); +} + static void draw_tree(void) { int bottom = lines - 3; if (treew < 2 || lines < 6) return; + draw_horizontal_border(1, 0, treew, "┌", "┐"); terminal_accent(); - terminal_move(1, 0); - putchar('/'); - terminal_repeat('-', treew - 2); - putchar('\\'); for (int row = 2; row < bottom; row++) { terminal_move(row, 0); - putchar('|'); + fputs("│", stdout); terminal_move(row, treew - 1); - putchar('|'); + fputs("│", stdout); } - terminal_move(bottom, 0); - putchar('\\'); - terminal_repeat('-', treew - 2); - putchar('/'); fputs("\033[0m", stdout); + draw_horizontal_border(bottom, 0, treew, "└", "┘"); position_tree(0, 0); int index = 0; for (Server *s = servers; s; s = s->next) { @@ -2959,18 +2968,21 @@ static void draw_title(void) fputs("\033[0m", stdout); } -static void draw_pane_divider(int row, int opening, int closing) +static void draw_pane_divider(int row, const char *opening, const char *closing) { - int left = lines > 5 && treew >= 2 ? treew : 0; - terminal_move(row, left); + int left = treew >= 2 ? treew : 0; + draw_horizontal_border(row, left, cols - left, opening, closing); +} + +static void draw_pane_sides(void) +{ + if (copy_view || cols - treew < 2 || mainh < 1) return; terminal_accent(); - int width = cols - left; - if (width > 1) { - putchar(opening); - terminal_repeat('-', width - 2); - putchar(closing); - } else if (width == 1) { - putchar('-'); + for (int row = chat_top; row < chat_top + mainh; row++) { + terminal_move(row, treew); + fputs("│", stdout); + terminal_move(row, cols - 1); + fputs("│", stdout); } fputs("\033[0m", stdout); } @@ -2996,7 +3008,7 @@ static int layout_topic(int draw) if (draw && row < height) draw_irc_text(chat_top + row, left, text, width); free(text); } - if (draw && divider) draw_pane_divider(chat_top + height, '-', '|'); + if (draw && divider) draw_pane_divider(chat_top + height, copy_view ? "─" : "├", copy_view ? "─" : "┤"); return height + divider; } @@ -3104,9 +3116,10 @@ static void redraw(void) fputs("\033[?25l\033[0m\033[2J", stdout); draw_title(); draw_tree(); - if (chat_top > 1) draw_pane_divider(1, '/', '\\'); + if (chat_top > 1) draw_pane_divider(1, "┌", "┐"); + draw_pane_sides(); draw_main(); - if (lines >= 4) draw_pane_divider(lines - 3, '\\', '/'); + if (lines >= 4) draw_pane_divider(lines - 3, "└", "┘"); draw_status(); draw_input(); fputs("\033[?25h", stdout);