summaryrefslogtreecommitdiff
path: root/usr.bin/tmux/window-choose.c
diff options
context:
space:
mode:
authorNicholas Marriott <nicm@cvs.openbsd.org>2010-02-01 22:15:52 +0000
committerNicholas Marriott <nicm@cvs.openbsd.org>2010-02-01 22:15:52 +0000
commit0e27ffb41e860c61a5d3246899ae37c8932dcc2b (patch)
tree50b67e99c258bb77409ded7f1c0a50ed818313a9 /usr.bin/tmux/window-choose.c
parentb67122c7b7fd9f997014f4dc88bfed12551d443b (diff)
Add scroll-up/scroll-down for choose/more mode, from Micah Cowan.
Diffstat (limited to 'usr.bin/tmux/window-choose.c')
-rw-r--r--usr.bin/tmux/window-choose.c35
1 files changed, 30 insertions, 5 deletions
diff --git a/usr.bin/tmux/window-choose.c b/usr.bin/tmux/window-choose.c
index d6c6669f5ae..023ec35e013 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.14 2010/01/11 23:46:22 nicm Exp $ */
+/* $OpenBSD: window-choose.c,v 1.15 2010/02/01 22:15:51 nicm Exp $ */
/*
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -225,16 +225,41 @@ window_choose_key(struct window_pane *wp, unused struct client *c, int key)
}
data->selected++;
- if (data->selected >= data->top + screen_size_y(&data->screen))
- window_choose_scroll_down(wp);
- else {
+ if (data->selected < data->top + screen_size_y(s)) {
screen_write_start(&ctx, wp, NULL);
window_choose_write_line(
wp, &ctx, data->selected - data->top);
window_choose_write_line(
wp, &ctx, data->selected - 1 - data->top);
screen_write_stop(&ctx);
- }
+ } else
+ window_choose_scroll_down(wp);
+ break;
+ case MODEKEYCHOICE_SCROLLUP:
+ if (items == 0 || data->top == 0)
+ break;
+ if (data->selected == data->top + screen_size_y(s) - 1) {
+ data->selected--;
+ window_choose_scroll_up(wp);
+ screen_write_start(&ctx, wp, NULL);
+ window_choose_write_line(
+ wp, &ctx, screen_size_y(s) - 1);
+ screen_write_stop(&ctx);
+ } else
+ window_choose_scroll_up(wp);
+ break;
+ case MODEKEYCHOICE_SCROLLDOWN:
+ if (items == 0 ||
+ data->top + screen_size_y(&data->screen) >= items)
+ break;
+ if (data->selected == data->top) {
+ data->selected++;
+ window_choose_scroll_down(wp);
+ screen_write_start(&ctx, wp, NULL);
+ window_choose_write_line(wp, &ctx, 0);
+ screen_write_stop(&ctx);
+ } else
+ window_choose_scroll_down(wp);
break;
case MODEKEYCHOICE_PAGEUP:
if (data->selected < screen_size_y(s)) {