Toggle the channel tree with Ctrl+Y

This commit is contained in:
Johannes Findeisen 2026-12-03 01:11:14 +01:00
commit b1f78e18f0
2 changed files with 14 additions and 1 deletions

View file

@ -174,6 +174,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) | | `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+Left` / `Ctrl+Right` | move to the previous / next word in the input line |
| `Ctrl+Y` | hide or show the channel tree |
| `Ctrl+PgUp` / `Ctrl+PgDn` | scroll the channel tree by one row | | `Ctrl+PgUp` / `Ctrl+PgDn` | scroll the channel tree by one row |
| `Ctrl+N` or `Ctrl+Down` / `Ctrl+P` or `Ctrl+Up` | next / previous visible window (tree order, wraps around) | | `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) | | Enter | with empty input, fold or unfold a server, or toggle a chat’s sticky status (`*` after its name) |

14
irc9.c
View file

@ -198,6 +198,7 @@ static int tree_offset;
static int hide_read_windows; static int hide_read_windows;
static int treew = TREEW, mainh = 1, chat_top = 1; static int treew = TREEW, mainh = 1, chat_top = 1;
static struct termios saved_terminal; static struct termios saved_terminal;
static int tree_hidden;
static int terminal_active; static int terminal_active;
static int terminal_color; static int terminal_color;
static int colored_nicks; static int colored_nicks;
@ -2463,6 +2464,7 @@ static void do_command(Window *window, char *line)
window_clear(window); window_clear(window);
} else if (strcasecmp(cmd, "reconnect") == 0) { } else if (strcasecmp(cmd, "reconnect") == 0) {
if (!window) return; if (!window) return;
appendf(t, " ctrl-y hide or show the channel tree");
Server *s = window->srv; Server *s = window->srv;
appendf(serverwin(s), "* reconnecting to %s:%d", s->host, s->port); appendf(serverwin(s), "* reconnecting to %s:%d", s->host, s->port);
disconnect_server(s); disconnect_server(s);
@ -2682,6 +2684,12 @@ static void handle_key(int c)
if (c == 0x13 && curwin) { /* ctrl-s */ if (c == 0x13 && curwin) { /* ctrl-s */
saving = 1; saving = 1;
save_path[0] = 0; save_path[0] = 0;
if (c == 0x19) { /* ctrl-y */
tree_hidden = !tree_hidden;
layout();
dirty = 1;
return;
}
save_len = save_pos = 0; save_len = save_pos = 0;
dirty = 1; dirty = 1;
return; return;
@ -2764,7 +2772,7 @@ static void handle_key(int c)
static void layout(void) static void layout(void)
{ {
treew = cols >= 60 ? TREEW : (cols >= 30 ? 16 : 8); 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; else if (treew > cols / 2) treew = cols / 2;
chat_top = lines >= 7 ? 2 : 1; chat_top = lines >= 7 ? 2 : 1;
mainh = lines >= 5 ? lines - 3 - chat_top : 0; mainh = lines >= 5 ? lines - 3 - chat_top : 0;
@ -3271,6 +3279,10 @@ static void redraw(void)
input_dirty = 0; input_dirty = 0;
} }
#ifdef VDSUSP
/* Allow Ctrl+Y to reach the key handler on terminals with delayed suspend. */
mode.c_cc[VDSUSP] = _POSIX_VDISABLE;
#endif
static void check_resize(void) static void check_resize(void)
{ {
struct winsize size; struct winsize size;