Restyle the terminal interface with ASCII borders

This commit is contained in:
Johannes Findeisen 2026-11-27 02:42:18 +01:00
commit c3287f08c6
2 changed files with 35 additions and 34 deletions

38
irc9.c
View file

@ -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);