From fd14e03f37f430c4b208bacfec4d735c8f4231c0 Mon Sep 17 00:00:00 2001 From: Johannes Findeisen Date: Thu, 3 Dec 2026 01:11:42 +0100 Subject: [PATCH] Toggle the channel tree with Ctrl+Y --- README.md | 1 + irc9.c | 14 +++++++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index ebedab2..c00bb7d 100644 --- a/README.md +++ b/README.md @@ -175,6 +175,7 @@ MODE, TOPIC, and INVITE events are shown in the relevant window. | `Tab` | complete a `/` command or a nick; press again to cycle matches (recently completed nicks come first) | | `Ctrl+Left` / `Ctrl+Right` | move to the previous / next word in the input line | | `Ctrl+PgUp` / `Ctrl+PgDn` | scroll the channel tree by one row | +| `Ctrl+Y` | hide or show the channel tree | | `Ctrl+N` or `Ctrl+Down` / `Ctrl+P` or `Ctrl+Up` | next / previous visible window (tree order, wraps around) | | Enter | with empty input, fold or unfold a server, or toggle a chat’s sticky status (`*` after its name) | | `Ctrl+O` | toggle hiding inactive channels and private chats with no unread messages. Active and sticky chats stay visible when their server is unfolded | diff --git a/irc9.c b/irc9.c index 3a599cb..acaf7ab 100644 --- a/irc9.c +++ b/irc9.c @@ -202,6 +202,7 @@ static int terminal_active; static int terminal_color; static int colored_nicks; static int copy_view; +static int tree_hidden; static long accent_color = -1; enum { @@ -2483,6 +2484,7 @@ static void do_command(Window *window, char *line) appendf(t, "keys: ctrl-n / ctrl-p switch windows, pgup/pgdn scroll, ctrl-l clear screen"); appendf(t, " ctrl-up / ctrl-down scroll the channel tree"); appendf(t, " ctrl-s save scrollback, ctrl-t toggle copy view"); + appendf(t, " ctrl-y hide or show the channel tree"); } else { if (window) appendf(window, "* unknown command: /%s", cmd); } @@ -2702,6 +2704,12 @@ static void handle_key(int c) dirty = 1; return; } + if (c == 0x19) { /* ctrl-y */ + tree_hidden = !tree_hidden; + layout(); + dirty = 1; + return; + } if (c == 0x0c) { /* ctrl-l */ if (curwin) { curwin->scroll = -(mainh - layout_topic(0)); dirty = 1; } return; @@ -2764,7 +2772,7 @@ static void handle_key(int c) static void layout(void) { treew = cols >= 60 ? TREEW : (cols >= 30 ? 16 : 8); - if (copy_view || lines < 6) treew = 0; + if (copy_view || tree_hidden || 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; @@ -3293,6 +3301,10 @@ static void terminal_start(void) struct termios mode = saved_terminal; mode.c_lflag &= ~(ICANON | ECHO | IEXTEN); mode.c_iflag &= ~(ICRNL | INLCR | IGNCR | ISTRIP | IXON | IXOFF); +#ifdef VDSUSP + /* Allow Ctrl+Y to reach the key handler on terminals with delayed suspend. */ + mode.c_cc[VDSUSP] = _POSIX_VDISABLE; +#endif mode.c_cc[VMIN] = 0; mode.c_cc[VTIME] = 0; if (tcsetattr(STDIN_FILENO, TCSANOW, &mode) < 0)