diff --git a/cmd-choose-tree.c b/cmd-choose-tree.c index 1dfb04f5..6bb17fc2 100644 --- a/cmd-choose-tree.c +++ b/cmd-choose-tree.c @@ -33,8 +33,8 @@ const struct cmd_entry cmd_choose_tree_entry = { .name = "choose-tree", .alias = NULL, - .args = { "F:f:GK:kNO:rst:wyZ", 0, 1, cmd_choose_tree_args_parse }, - .usage = "[-GkNrswZ] [-F format] [-f filter] [-K key-format] " + .args = { "F:f:GhK:kNO:rst:wyZ", 0, 1, cmd_choose_tree_args_parse }, + .usage = "[-GhkNrswZ] [-F format] [-f filter] [-K key-format] " "[-O sort-order] " CMD_TARGET_PANE_USAGE " [template]", .target = { 't', CMD_FIND_PANE, 0 }, @@ -47,8 +47,8 @@ const struct cmd_entry cmd_choose_client_entry = { .name = "choose-client", .alias = NULL, - .args = { "F:f:K:kNO:rt:yZ", 0, 1, cmd_choose_tree_args_parse }, - .usage = "[-kNrZ] [-F format] [-f filter] [-K key-format] " + .args = { "F:f:hK:kNO:rt:yZ", 0, 1, cmd_choose_tree_args_parse }, + .usage = "[-hkNrZ] [-F format] [-f filter] [-K key-format] " "[-O sort-order] " CMD_TARGET_PANE_USAGE " [template]", .target = { 't', CMD_FIND_PANE, 0 }, diff --git a/tmux.1 b/tmux.1 index 94597786..43f7dec8 100644 --- a/tmux.1 +++ b/tmux.1 @@ -2312,7 +2312,6 @@ cursor on that line. Scroll pane in copy\-mode when bound to a mouse drag event. .Fl e causes copy mode to exit when at the bottom. -.Pp .It Xo .Ic scroll\-top .Xc @@ -2743,7 +2742,7 @@ the end of the visible pane. The default is to capture only the visible contents of the pane. .It Xo .Ic choose\-client -.Op Fl kNryZ +.Op Fl hkNryZ .Op Fl F Ar format .Op Fl f Ar filter .Op Fl K Ar key\-format @@ -2814,14 +2813,20 @@ If a filter would lead to an empty list, it is ignored. specifies the format for each item in the list and .Fl K a format for each shortcut key; both are evaluated once for each line. +.Pp .Fl N starts without the preview or if given twice with the larger preview. +.Fl h +hides the pane containing the mode. .Fl k kills the pane when the mode is exited. -This command works only if at least one client is attached. +.Pp +The +.Ic choose-client +command works only if at least one client is attached. .It Xo .Ic choose\-tree -.Op Fl GkNrswyZ +.Op Fl GhkNrswyZ .Op Fl F Ar format .Op Fl f Ar filter .Op Fl K Ar key\-format @@ -2906,14 +2911,27 @@ If a filter would lead to an empty list, it is ignored. specifies the format for each item in the tree and .Fl K a format for each shortcut key; both are evaluated once for each line. -.Fl N -starts without the preview or if given twice with the larger preview. .Fl G includes all sessions in any session groups in the tree rather than only the first. +.Pp +.Fl N +starts without the preview or if given twice with the larger preview. +.Fl h +hides the pane containing the mode. .Fl k kills the pane when the mode is exited. -This command works only if at least one client is attached. +.Fl h +and +.Fl k +are intended to ease use of the mode in a floating pane; for example: +.Bd -literal -offset indent +bind s 'new-pane -x50% -y50% -E; choose-tree -hks' +.Ed +.Pp +The +.Ic choose-tree +command works only if at least one client is attached. .It Xo .Ic customize\-mode .Op Fl kNZ @@ -2962,11 +2980,15 @@ the item in the list is not shown, otherwise it is shown. If a filter would lead to an empty list, it is ignored. .Fl F specifies the format for each item in the tree. +.Pp .Fl N starts without the option information. .Fl k kills the pane when the mode is exited. -This command works only if at least one client is attached. +.Pp +The +.Ic customize-mode +command works only if at least one client is attached. .It Xo .Tg displayp .Ic display\-panes @@ -3037,7 +3059,9 @@ The default is .Fl Z zooms the pane. .Pp -This command works only if at least one client is attached. +The +.Ic find-window +command works only if at least one client is attached. .Tg joinp .It Xo Ic join\-pane .Op Fl bdfhv @@ -7706,7 +7730,9 @@ a format for each shortcut key; both are evaluated once for each line. starts without the preview. .Fl k kills the pane when the mode is exited. -This command works only if at least one client is attached. +The +.Ic choose-buffer +command works only if at least one client is attached. .Tg clearhist .It Xo Ic clear\-history .Op Fl H diff --git a/window-client.c b/window-client.c index be1fd5fa..519222d9 100644 --- a/window-client.c +++ b/window-client.c @@ -82,6 +82,7 @@ struct window_client_modedata { char *format; char *key_format; char *command; + int hide_preview_this_pane; struct window_client_itemdata **item_list; u_int item_size; @@ -162,9 +163,10 @@ window_client_build(void *modedata, struct sort_criteria *sort_crit, } static void -window_client_draw(__unused void *modedata, void *itemdata, +window_client_draw(void *modedata, void *itemdata, struct screen_write_ctx *ctx, u_int sx, u_int sy) { + struct window_client_modedata *data = modedata; struct window_client_itemdata *item = itemdata; struct client *c = item->c; struct screen *s = ctx->s; @@ -174,6 +176,12 @@ window_client_draw(__unused void *modedata, void *itemdata, if (c->session == NULL || (c->flags & CLIENT_UNATTACHEDFLAGS)) return; wp = c->session->curw->window->active; + if (data->hide_preview_this_pane && wp == data->wp) { + if (!TAILQ_EMPTY(&c->session->curw->window->last_panes)) + wp = TAILQ_FIRST(&c->session->curw->window->last_panes); + else + wp = NULL; + } lines = status_line_size(c); if (lines >= sy) @@ -184,7 +192,8 @@ window_client_draw(__unused void *modedata, void *itemdata, at = 0; screen_write_cursormove(ctx, cx, cy + at, 0); - screen_write_preview(ctx, &wp->base, sx, sy - 2 - lines); + if (wp != NULL) + screen_write_preview(ctx, &wp->base, sx, sy - 2 - lines); if (at != 0) screen_write_cursormove(ctx, cx, cy + 2, 0); @@ -270,6 +279,7 @@ window_client_init(struct window_mode_entry *wme, wme->data = data = xcalloc(1, sizeof *data); data->wp = wp; + data->hide_preview_this_pane = args != NULL && args_has(args, 'h'); if (args == NULL || !args_has(args, 'F')) data->format = xstrdup(WINDOW_CLIENT_DEFAULT_FORMAT); diff --git a/window-tree.c b/window-tree.c index 3508ddb8..bff945c8 100644 --- a/window-tree.c +++ b/window-tree.c @@ -113,6 +113,7 @@ struct window_tree_modedata { char *key_format; char *command; int squash_groups; + int hide_preview_this_pane; int prompt_flags; struct window_tree_itemdata **item_list; @@ -289,6 +290,8 @@ window_tree_build_window(struct session *s, struct winlink *wl, if (n == 0) goto empty; for (i = 0; i < n; i++) { + if (data->hide_preview_this_pane && l[i] == data->wp) + continue; if (window_tree_filter_pane(s, wl, l[i], filter)) window_tree_build_pane(s, wl, l[i], modedata, mti); } @@ -580,6 +583,10 @@ window_tree_draw_window(struct window_tree_modedata *data, struct session *s, struct options *oo; total = window_count_panes(w, 1); + if (data->hide_preview_this_pane && data->wp->window == w) + total--; + if (total == 0) + return; if (sx / total < 24) { visible = sx / 24; @@ -590,6 +597,8 @@ window_tree_draw_window(struct window_tree_modedata *data, struct session *s, current = 0; TAILQ_FOREACH(wp, &w->panes, entry) { + if (data->hide_preview_this_pane && wp == data->wp) + continue; if (wp == w->active) break; current++; @@ -653,6 +662,8 @@ window_tree_draw_window(struct window_tree_modedata *data, struct session *s, i = loop = 0; TAILQ_FOREACH(wp, &w->panes, entry) { + if (data->hide_preview_this_pane && wp == data->wp) + continue; if (loop == end) break; if (loop < start) { @@ -704,6 +715,7 @@ static void window_tree_draw(void *modedata, void *itemdata, struct screen_write_ctx *ctx, u_int sx, u_int sy) { + struct window_tree_modedata *data = modedata; struct window_tree_itemdata *item = itemdata; struct session *sp; struct winlink *wl; @@ -723,7 +735,8 @@ window_tree_draw(void *modedata, void *itemdata, struct screen_write_ctx *ctx, window_tree_draw_window(modedata, sp, wl, ctx, sx, sy); break; case WINDOW_TREE_PANE: - screen_write_preview(ctx, &wp->base, sx, sy); + if (!data->hide_preview_this_pane || wp != data->wp) + screen_write_preview(ctx, &wp->base, sx, sy); break; } } @@ -932,6 +945,7 @@ window_tree_init(struct window_mode_entry *wme, struct cmd_find_state *fs, else data->command = xstrdup(args_string(args, 0)); data->squash_groups = !args_has(args, 'G'); + data->hide_preview_this_pane = args_has(args, 'h'); if (args_has(args, 'y')) data->prompt_flags = PROMPT_ACCEPT;