From c3287f08c69d8dd4dbaf91761243d89ae86f102e Mon Sep 17 00:00:00 2001 From: Johannes Findeisen Date: Fri, 27 Nov 2026 02:42:18 +0100 Subject: [PATCH] Restyle the terminal interface with ASCII borders --- README.md | 31 ++++++++++++++----------------- irc9.c | 38 +++++++++++++++++++++----------------- 2 files changed, 35 insertions(+), 34 deletions(-) diff --git a/README.md b/README.md index 37f9a0d..4211706 100644 --- a/README.md +++ b/README.md @@ -73,29 +73,26 @@ Build yours by copying `irc9rc-example` to `irc9rc` next to the binary (or to ## Layout ``` -irc.example / #general -┌────────────────┬──────────────────────────────────────────┐ -│* irc.example │ [10:21] hello there │ -│ #general │ [10:22] hi │ -│ #help(3) │ [10:22] * alice!u@host joined #help │ -│ alice │ │ -│* irc.other │ │ -│ │ │ -├────────────────┴──────────────────────────────────────────┤ -│ me@irc.example #general (3) connected TLS 10:23 │ -│> your message here │ -└────────────────────────────────────────────────────────────┘ + [irc9] irc.example / #general +/----------------------\ +|* irc.example | +| |-#general | +| |-#help(3) | [10:21] hello there +| \-alice | [10:22] hi +|* irc.other | [10:22] * alice!u@host joined #help +\______________________/ +---------------------------------------------------------------- + [10:23] (me@irc.example:6697 [TLS]) +> your message here ``` The left column is a tree: each server and its windows (channels and private message windows). An unread window shows `(n)` next to its name. `*` marks a connected server. The selected server or window is shown bold and underlined. Highlights use the -terminal's default background (so transparency is preserved where supported). -The -right pane shows the current window's scrollback with `[HH:MM]` timestamps. +terminal's default background so transparency is preserved where supported. +The right pane shows the current window's scrollback with `[HH:MM]` timestamps. Joins, parts and quits include the full hostmask; joins and parts also name the -channel. The status line above the input shows your nick, server, current -window, member count, connection state (including `TLS`), and the time. +channel. The status line above the input shows the time, nick, server, port, TLS state, and user modes. Joining a channel prints its nicklist; `/n` and `/names` print it again. CTCP `ACTION`, `VERSION`, `PING`, `TIME`, and `USERINFO` are understood; KICK, MODE, TOPIC, and INVITE events are shown in the relevant window. diff --git a/irc9.c b/irc9.c index 973cc01..447f23d 100644 --- a/irc9.c +++ b/irc9.c @@ -2061,22 +2061,22 @@ static void push_wrapped(char **rows, int *nr, int maxrows, const char *s, int w static void draw_tree(void) { if (treew < 2 || mainh < 2) return; - fputs("\033(0", stdout); + if (terminal_color) fputs("\033[36m", stdout); terminal_move(1, 0); - putchar('l'); - terminal_repeat('q', treew - 2); - putchar('k'); + putchar('/'); + terminal_repeat('-', treew - 2); + putchar('\\'); for (int row = 2; row < mainh; row++) { terminal_move(row, 0); - putchar('x'); + putchar('|'); terminal_move(row, treew - 1); - putchar('x'); + putchar('|'); } terminal_move(mainh, 0); - putchar('m'); - terminal_repeat('q', treew - 2); - putchar('j'); - fputs("\033(B", stdout); + 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; @@ -2095,9 +2095,12 @@ static void draw_tree(void) if (w->unread) snprintf(label, sizeof label, "%s(%d)", w->name, w->unread); else snprintf(label, sizeof label, "%s", w->name); if (treew > 5) { - terminal_move(y, 3); + terminal_move(y, 2); + if (terminal_color) fputs("\033[36m", stdout); + fputs(w->next ? "|-" : "\\-", stdout); + fputs("\033[0m", stdout); if (w == curwin) fputs(terminal_color ? "\033[1;4m" : "\033[7m", stdout); - terminal_text(label, treew - 5); + terminal_text(label, treew - 6); fputs("\033[0m", stdout); } y++; @@ -2172,8 +2175,9 @@ static void draw_title(void) fputs(terminal_color ? "\033[1m" : "\033[7m", stdout); terminal_move(0, 0); terminal_repeat(' ', cols); - terminal_move(0, 0); if (curwin) { + int margin = cols > 24; + terminal_move(0, margin); char head[MAXLINE]; if (curwin->type == W_SERVER) snprintf(head, sizeof head, "[irc9] (status) %s%s", curwin->srv->host, @@ -2184,7 +2188,7 @@ static void draw_title(void) else snprintf(head, sizeof head, "[irc9] %s / %s%s", curwin->srv->host, curwin->name, curwin->scroll > 0 ? " [scroll]" : ""); - terminal_text(head, cols); + terminal_text(head, cols - margin); } fputs("\033[0m", stdout); } @@ -2226,9 +2230,9 @@ static void draw_input(void) { if (lines < 4) return; terminal_move(lines - 3, 0); - fputs("\033(0", stdout); - terminal_repeat('q', cols); - fputs("\033(B", stdout); + if (terminal_color) fputs("\033[36m", stdout); + terminal_repeat('-', cols); + fputs("\033[0m", stdout); fputs(terminal_color ? "\033[1m" : "\033[7m", stdout); terminal_move(lines - 2, 0); terminal_repeat(' ', cols);