Restyle the terminal interface with ASCII borders
This commit is contained in:
parent
09e72d1b1f
commit
c3287f08c6
2 changed files with 35 additions and 34 deletions
31
README.md
31
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] <alice> hello there │
|
||||
│ #general │ [10:22] <bob> 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] <alice> hello there
|
||||
| \-alice | [10:22] <bob> 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.
|
||||
|
|
|
|||
38
irc9.c
38
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);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue