summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authornicm <nicm@openbsd.org>2013-10-10 11:58:52 +0000
committernicm <nicm@openbsd.org>2013-10-10 11:58:52 +0000
commite4d791d3945dd4b0a8b46ba596f14c3b9e936c4a (patch)
tree581a7a7e1a1d18ad601cec2b3ab3b26d7d2406da
parentRenumber windows: Lookup lastw via window not index (diff)
downloadwireguard-openbsd-e4d791d3945dd4b0a8b46ba596f14c3b9e936c4a.tar.xz
wireguard-openbsd-e4d791d3945dd4b0a8b46ba596f14c3b9e936c4a.zip
choose-tree: Reset top when toggling items
When choose-tree is told to expand/collapse items (especially when first rendering collapsed to just show sessions), ensure that in addition to setting the selected item, that the item itself appears on the bottom of the screen, rather than off screen. This was causing rendering glitches when a very small tmux window tried to render a list of items in choose-tree much larger than itself, and the selected item appeared off screen, and didn't show the selection until the selection had wrapped around to the top of the screen.
-rw-r--r--usr.bin/tmux/cmd-choose-tree.c3
-rw-r--r--usr.bin/tmux/window-choose.c27
2 files changed, 19 insertions, 11 deletions
diff --git a/usr.bin/tmux/cmd-choose-tree.c b/usr.bin/tmux/cmd-choose-tree.c
index f3bfa8ed1e4..2e34537fad0 100644
--- a/usr.bin/tmux/cmd-choose-tree.c
+++ b/usr.bin/tmux/cmd-choose-tree.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: cmd-choose-tree.c,v 1.23 2013/04/22 22:17:29 nicm Exp $ */
+/* $OpenBSD: cmd-choose-tree.c,v 1.24 2013/10/10 11:58:52 nicm Exp $ */
/*
* Copyright (c) 2012 Thomas Adam <thomas@xteddy.org>
@@ -228,7 +228,6 @@ windows_only:
free(final_win_template_last);
window_choose_ready(wl->window->active, cur_win, NULL);
- window_choose_collapse_all(wl->window->active);
if (args_has(args, 'u')) {
window_choose_expand_all(wl->window->active);
diff --git a/usr.bin/tmux/window-choose.c b/usr.bin/tmux/window-choose.c
index 820c7168ee3..f2e59dec34b 100644
--- a/usr.bin/tmux/window-choose.c
+++ b/usr.bin/tmux/window-choose.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: window-choose.c,v 1.47 2013/04/22 22:17:29 nicm Exp $ */
+/* $OpenBSD: window-choose.c,v 1.48 2013/10/10 11:58:52 nicm Exp $ */
/*
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -81,6 +81,7 @@ int window_choose_key_index(struct window_choose_mode_data *, u_int);
int window_choose_index_key(struct window_choose_mode_data *, int);
void window_choose_prompt_input(enum window_choose_input_type,
const char *, struct window_pane *, int);
+void window_choose_reset_top(struct window_pane *, u_int);
void
window_choose_add(struct window_pane *wp, struct window_choose_data *wcd)
@@ -107,8 +108,17 @@ window_choose_set_current(struct window_pane *wp, u_int cur)
struct screen *s = &data->screen;
data->selected = cur;
- if (data->selected > screen_size_y(s) - 1)
- data->top = ARRAY_LENGTH(&data->list) - screen_size_y(s);
+ window_choose_reset_top(wp, screen_size_y(s));
+}
+
+void
+window_choose_reset_top(struct window_pane *wp, u_int sy)
+{
+ struct window_choose_mode_data *data = wp->modedata;
+
+ data->top = 0;
+ if (data->selected > sy - 1)
+ data->top = data->selected - (sy - 1);
window_choose_redraw_screen(wp);
}
@@ -277,10 +287,7 @@ window_choose_resize(struct window_pane *wp, u_int sx, u_int sy)
struct window_choose_mode_data *data = wp->modedata;
struct screen *s = &data->screen;
- data->top = 0;
- if (data->selected > sy - 1)
- data->top = data->selected - (sy - 1);
-
+ window_choose_reset_top(wp, sy);
screen_resize(s, sx, sy, 0);
window_choose_redraw_screen(wp);
}
@@ -373,6 +380,7 @@ window_choose_collapse_all(struct window_pane *wp)
{
struct window_choose_mode_data *data = wp->modedata;
struct window_choose_mode_item *item;
+ struct screen *scr = &data->screen;
struct session *s, *chosen;
u_int i;
@@ -391,7 +399,7 @@ window_choose_collapse_all(struct window_pane *wp)
if (item->wcd->type & TREE_SESSION)
data->selected = i;
}
- window_choose_redraw_screen(wp);
+ window_choose_reset_top(wp, screen_size_y(scr));
}
void
@@ -399,6 +407,7 @@ window_choose_expand_all(struct window_pane *wp)
{
struct window_choose_mode_data *data = wp->modedata;
struct window_choose_mode_item *item;
+ struct screen *scr = &data->screen;
struct session *s;
u_int i;
@@ -414,7 +423,7 @@ window_choose_expand_all(struct window_pane *wp)
}
}
- window_choose_redraw_screen(wp);
+ window_choose_reset_top(wp, screen_size_y(scr));
}
void