From: nicm Date: Tue, 4 Jul 2017 22:21:31 +0000 (+0000) Subject: < and > keys to scroll preview list left and right in tree mode. X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=05d445865895ce89d571f04616c2cb2c97018240;p=openbsd < and > keys to scroll preview list left and right in tree mode. --- diff --git a/usr.bin/tmux/tmux.1 b/usr.bin/tmux/tmux.1 index 2cfa33ecc7c..62ed321055e 100644 --- a/usr.bin/tmux/tmux.1 +++ b/usr.bin/tmux/tmux.1 @@ -1,4 +1,4 @@ -.\" $OpenBSD: tmux.1,v 1.565 2017/06/29 22:02:19 nicm Exp $ +.\" $OpenBSD: tmux.1,v 1.566 2017/07/04 22:21:31 nicm Exp $ .\" .\" Copyright (c) 2007 Nicholas Marriott .\" @@ -14,7 +14,7 @@ .\" IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING .\" OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. .\" -.Dd $Mdocdate: June 29 2017 $ +.Dd $Mdocdate: July 4 2017 $ .Dt TMUX 1 .Os .Sh NAME @@ -1422,6 +1422,8 @@ The following keys may be used in tree mode: .It Li "Enter" Ta "Choose selected item" .It Li "Up" Ta "Select previous item" .It Li "Down" Ta "Select next item" +.It Li "<" Ta "Scroll list of previews left" +.It Li ">" Ta "Scroll list of previews right" .It Li "C-s" Ta "Search by name" .It Li "n" Ta "Repeat last search" .It Li "t" Ta "Toggle if item is tagged" diff --git a/usr.bin/tmux/window-tree.c b/usr.bin/tmux/window-tree.c index 07f3545707e..106d9097698 100644 --- a/usr.bin/tmux/window-tree.c +++ b/usr.bin/tmux/window-tree.c @@ -1,4 +1,4 @@ -/* $OpenBSD: window-tree.c,v 1.10 2017/07/04 12:26:14 nicm Exp $ */ +/* $OpenBSD: window-tree.c,v 1.11 2017/07/04 22:21:31 nicm Exp $ */ /* * Copyright (c) 2017 Nicholas Marriott @@ -83,6 +83,8 @@ struct window_tree_modedata { struct cmd_find_state fs; enum window_tree_type type; + + int offset; }; static void @@ -409,8 +411,8 @@ window_tree_build(void *modedata, u_int sort_type, uint64_t *tag, } static void -window_tree_draw_session(struct session *s, struct screen_write_ctx *ctx, - u_int sx, u_int sy) +window_tree_draw_session(struct window_tree_modedata *data, struct session *s, + struct screen_write_ctx *ctx, u_int sx, u_int sy) { struct options *oo = s->options; struct winlink *wl; @@ -453,6 +455,13 @@ window_tree_draw_session(struct session *s, struct screen_write_ctx *ctx, end = start + visible; } + if (data->offset < -(int)start) + data->offset = -(int)start; + if (data->offset > (int)(total - end)) + data->offset = (int)(total - end); + start += data->offset; + end += data->offset; + left = (start != 0); right = (end != total); if (((left && right) && sx <= 6) || ((left || right) && sx <= 3)) @@ -530,8 +539,8 @@ window_tree_draw_session(struct session *s, struct screen_write_ctx *ctx, } static void -window_tree_draw_window(struct session *s, struct window *w, - struct screen_write_ctx *ctx, u_int sx, u_int sy) +window_tree_draw_window(struct window_tree_modedata *data, struct session *s, + struct window *w, struct screen_write_ctx *ctx, u_int sx, u_int sy) { struct options *oo = s->options; struct window_pane *wp; @@ -573,6 +582,13 @@ window_tree_draw_window(struct session *s, struct window *w, end = start + visible; } + if (data->offset < -(int)start) + data->offset = -(int)start; + if (data->offset > (int)(total - end)) + data->offset = (int)(total - end); + start += data->offset; + end += data->offset; + left = (start != 0); right = (end != total); if (((left && right) && sx <= 6) || ((left || right) && sx <= 3)) @@ -647,7 +663,7 @@ window_tree_draw_window(struct session *s, struct window *w, } static struct screen * -window_tree_draw(__unused void *modedata, void *itemdata, u_int sx, u_int sy) +window_tree_draw(void *modedata, void *itemdata, u_int sx, u_int sy) { struct window_tree_itemdata *item = itemdata; struct session *sp; @@ -667,10 +683,10 @@ window_tree_draw(__unused void *modedata, void *itemdata, u_int sx, u_int sy) case WINDOW_TREE_NONE: return (0); case WINDOW_TREE_SESSION: - window_tree_draw_session(sp, &ctx, sx, sy); + window_tree_draw_session(modedata, sp, &ctx, sx, sy); break; case WINDOW_TREE_WINDOW: - window_tree_draw_window(sp, wlp->window, &ctx, sx, sy); + window_tree_draw_window(modedata, sp, wlp->window, &ctx, sx, sy); break; case WINDOW_TREE_PANE: screen_write_preview(&ctx, &wp->base, sx, sy); @@ -898,8 +914,17 @@ window_tree_key(struct window_pane *wp, struct client *c, int finished; u_int tagged; + item = mode_tree_get_current(data->data); finished = mode_tree_key(data->data, c, &key, m); + if (item != mode_tree_get_current(data->data)) + data->offset = 0; switch (key) { + case '<': + data->offset--; + break; + case '>': + data->offset++; + break; case ':': tagged = mode_tree_count_tagged(data->data); if (tagged != 0)