Toggle hiding read channels and private chats
This commit is contained in:
parent
375a6b3e32
commit
d01cc258e3
2 changed files with 25 additions and 6 deletions
|
|
@ -175,6 +175,7 @@ MODE, TOPIC, and INVITE events are shown in the relevant window.
|
|||
| `Ctrl+Up` / `Ctrl+Down` | scroll the channel tree by one row |
|
||||
| `ctrl-n` / `ctrl-p` | next / previous visible window (tree order, wraps around) |
|
||||
| Enter | fold or unfold the selected server when the input line is empty |
|
||||
| `Ctrl+H` | toggle hiding channels and private chats with no unread messages. They reappear when they have unread messages and their server is unfolded |
|
||||
| `PageUp` / `PageDown` | scroll the current window |
|
||||
| `ctrl-l` | clear the screen (history stays scrollable) |
|
||||
| `ctrl-t` | toggle copy view, which hides the tree, chat timestamps, and sender names |
|
||||
|
|
|
|||
30
irc9.c
30
irc9.c
|
|
@ -187,6 +187,7 @@ static time_t status_minute;
|
|||
static int scrollback_limit = MAXSCROLL;
|
||||
static int cols = 80, lines = 24;
|
||||
static int tree_offset;
|
||||
static int hide_read_windows;
|
||||
static int treew = TREEW, mainh = 1, chat_top = 1;
|
||||
static struct termios saved_terminal;
|
||||
static int terminal_active;
|
||||
|
|
@ -366,9 +367,19 @@ static Window *window_get(Server *s, const char *name, Wintype type)
|
|||
return w;
|
||||
}
|
||||
|
||||
static int window_visible_in_tree(const Window *w)
|
||||
{
|
||||
if (w->type == W_SERVER) return 1;
|
||||
return !w->srv->tree_folded &&
|
||||
(!hide_read_windows || w->unread);
|
||||
}
|
||||
|
||||
static Window *next_visible_window(Window *w)
|
||||
{
|
||||
return w->srv->tree_folded ? NULL : w->next;
|
||||
if (w->srv->tree_folded) return NULL;
|
||||
for (w = w->next; w; w = w->next)
|
||||
if (window_visible_in_tree(w)) return w;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void position_tree(int delta, int reveal_current)
|
||||
|
|
@ -377,7 +388,8 @@ static void position_tree(int delta, int reveal_current)
|
|||
int count = 0, current = -1;
|
||||
for (Server *s = servers; s; s = s->next)
|
||||
for (Window *w = s->windows; w; w = next_visible_window(w), count++)
|
||||
if (w == curwin) current = count;
|
||||
if (curwin && (w == curwin ||
|
||||
(current < 0 && w == curwin->srv->windows))) current = count;
|
||||
|
||||
int offset = tree_offset + delta;
|
||||
if (reveal_current && current >= 0) {
|
||||
|
|
@ -395,9 +407,9 @@ static void focus_window(Window *w)
|
|||
if (!w || w == curwin) return;
|
||||
curwin = w;
|
||||
if (w->type != W_SERVER) w->srv->tree_folded = 0;
|
||||
position_tree(0, 1);
|
||||
curwin->scroll = 0;
|
||||
curwin->unread = 0;
|
||||
position_tree(0, 1);
|
||||
dirty = 1;
|
||||
}
|
||||
|
||||
|
|
@ -556,9 +568,9 @@ static void switch_window(int dir)
|
|||
if (t->windows) { target = t->windows; break; }
|
||||
} else {
|
||||
for (Server *s = servers; s; s = s->next)
|
||||
for (Window *w = s->windows; w; w = next_visible_window(w)) {
|
||||
for (Window *w = s->windows; w; w = w->next) {
|
||||
if (w == curwin) goto found;
|
||||
target = w;
|
||||
if (window_visible_in_tree(w)) target = w;
|
||||
}
|
||||
found:;
|
||||
if (!target)
|
||||
|
|
@ -2502,6 +2514,12 @@ static void handle_key(int c)
|
|||
}
|
||||
if (c != '\t') comp_active = 0;
|
||||
if (c == '\t') { complete_input(); return; }
|
||||
if (c == 0x08) { /* ctrl-h */
|
||||
hide_read_windows = !hide_read_windows;
|
||||
position_tree(0, 1);
|
||||
dirty = 1;
|
||||
return;
|
||||
}
|
||||
if (c == 0x0e) { switch_window(1); return; } /* ctrl-n */
|
||||
if (c == 0x10) { switch_window(-1); return; } /* ctrl-p */
|
||||
if (c == 0x14) { /* ctrl-t */
|
||||
|
|
@ -2801,7 +2819,7 @@ static void draw_tree(void)
|
|||
if (treew > 5) {
|
||||
terminal_move(y, 2);
|
||||
terminal_accent();
|
||||
fputs(w->next ? "|-" : "\\-", stdout);
|
||||
fputs(next_visible_window(w) ? "|-" : "\\-", stdout);
|
||||
fputs("\033[0m", stdout);
|
||||
if (w == curwin) fputs(terminal_color ? "\033[1;4m" : "\033[7m", stdout);
|
||||
if (colored_nicks && terminal_color && w->type == W_QUERY)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue