Toggle the channel tree with Ctrl+Y

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

14
irc9.c
View file

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