diff options
author | Nicholas Marriott <nicm@cvs.openbsd.org> | 2017-08-23 09:39:12 +0000 |
---|---|---|
committer | Nicholas Marriott <nicm@cvs.openbsd.org> | 2017-08-23 09:39:12 +0000 |
commit | 192a189a1ad7a07d8e94c5502ba81184e09361cd (patch) | |
tree | a8f18a8424074ad9095c63052d9cd647f3f7ac04 /usr.bin | |
parent | fda53ca869881135d3e9cccad121fb87821f9a67 (diff) |
Key (v) and flag (-N) to toggle preview in choose modes.
Diffstat (limited to 'usr.bin')
-rw-r--r-- | usr.bin/tmux/cmd-choose-tree.c | 14 | ||||
-rw-r--r-- | usr.bin/tmux/mode-tree.c | 26 | ||||
-rw-r--r-- | usr.bin/tmux/tmux.1 | 17 |
3 files changed, 39 insertions, 18 deletions
diff --git a/usr.bin/tmux/cmd-choose-tree.c b/usr.bin/tmux/cmd-choose-tree.c index c88661c65f1..b33e1e90318 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.38 2017/08/09 11:43:45 nicm Exp $ */ +/* $OpenBSD: cmd-choose-tree.c,v 1.39 2017/08/23 09:39:11 nicm Exp $ */ /* * Copyright (c) 2012 Thomas Adam <thomas@xteddy.org> @@ -30,8 +30,8 @@ const struct cmd_entry cmd_choose_tree_entry = { .name = "choose-tree", .alias = NULL, - .args = { "F:f:O:st:w", 0, 1 }, - .usage = "[-sw] [-F format] [-f filter] [-O sort-order] " + .args = { "F:f:NO:st:w", 0, 1 }, + .usage = "[-Nsw] [-F format] [-f filter] [-O sort-order] " CMD_TARGET_PANE_USAGE, .target = { 't', CMD_FIND_PANE, 0 }, @@ -44,8 +44,8 @@ const struct cmd_entry cmd_choose_client_entry = { .name = "choose-client", .alias = NULL, - .args = { "F:f:O:t:", 0, 1 }, - .usage = "[-F format] [-f filter] [-O sort-order] " + .args = { "F:f:NO:t:", 0, 1 }, + .usage = "[-N] [-F format] [-f filter] [-O sort-order] " CMD_TARGET_PANE_USAGE, .target = { 't', CMD_FIND_PANE, 0 }, @@ -58,8 +58,8 @@ const struct cmd_entry cmd_choose_buffer_entry = { .name = "choose-buffer", .alias = NULL, - .args = { "F:f:O:t:", 0, 1 }, - .usage = "[-F format] [-f filter] [-O sort-order] " + .args = { "F:f:NO:t:", 0, 1 }, + .usage = "[-N] [-F format] [-f filter] [-O sort-order] " CMD_TARGET_PANE_USAGE, .target = { 't', CMD_FIND_PANE, 0 }, diff --git a/usr.bin/tmux/mode-tree.c b/usr.bin/tmux/mode-tree.c index b1914b3113b..9a29e05e8b7 100644 --- a/usr.bin/tmux/mode-tree.c +++ b/usr.bin/tmux/mode-tree.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mode-tree.c,v 1.8 2017/07/12 14:31:06 nicm Exp $ */ +/* $OpenBSD: mode-tree.c,v 1.9 2017/08/23 09:39:11 nicm Exp $ */ /* * Copyright (c) 2017 Nicholas Marriott <nicholas.marriott@gmail.com> @@ -60,6 +60,7 @@ struct mode_tree_data { struct screen screen; + int preview; char *search; char *filter; }; @@ -295,6 +296,8 @@ mode_tree_start(struct window_pane *wp, struct args *args, mtd->sort_size = sort_size; mtd->sort_type = 0; + mtd->preview = !args_has(args, 'N'); + sort = args_get(args, 'O'); if (sort != NULL) { for (i = 0; i < sort_size; i++) { @@ -348,12 +351,15 @@ mode_tree_build(struct mode_tree_data *mtd) mode_tree_set_current(mtd, tag); mtd->width = screen_size_x(s); - mtd->height = (screen_size_y(s) / 3) * 2; - if (mtd->height > mtd->line_size) - mtd->height = screen_size_y(s) / 2; - if (mtd->height < 10) - mtd->height = screen_size_y(s); - if (screen_size_y(s) - mtd->height < 2) + if (mtd->preview) { + mtd->height = (screen_size_y(s) / 3) * 2; + if (mtd->height > mtd->line_size) + mtd->height = screen_size_y(s) / 2; + if (mtd->height < 10) + mtd->height = screen_size_y(s); + if (screen_size_y(s) - mtd->height < 2) + mtd->height = screen_size_y(s); + } else mtd->height = screen_size_y(s); } @@ -549,7 +555,7 @@ mode_tree_draw(struct mode_tree_data *mtd) } sy = screen_size_y(s); - if (sy <= 4 || h <= 4 || sy - h <= 4 || w <= 4) { + if (!mtd->preview || sy <= 4 || h <= 4 || sy - h <= 4 || w <= 4) { screen_write_stop(&ctx); return; } @@ -861,6 +867,10 @@ mode_tree_key(struct mode_tree_data *mtd, struct client *c, key_code *key, mode_tree_filter_callback, mode_tree_filter_free, mtd, PROMPT_NOFORMAT); break; + case 'v': + mtd->preview = !mtd->preview; + mode_tree_build(mtd); + break; } return (0); } diff --git a/usr.bin/tmux/tmux.1 b/usr.bin/tmux/tmux.1 index e62407f156e..15d3c3eabbe 100644 --- a/usr.bin/tmux/tmux.1 +++ b/usr.bin/tmux/tmux.1 @@ -1,4 +1,4 @@ -.\" $OpenBSD: tmux.1,v 1.575 2017/08/19 20:40:16 nicm Exp $ +.\" $OpenBSD: tmux.1,v 1.576 2017/08/23 09:39:11 nicm Exp $ .\" .\" Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com> .\" @@ -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: August 19 2017 $ +.Dd $Mdocdate: August 23 2017 $ .Dt TMUX 1 .Os .Sh NAME @@ -1354,6 +1354,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 N .Op Fl F Ar format .Op Fl f Ar filter .Op Fl O Ar sort-order @@ -1381,6 +1382,7 @@ The following keys may be used in client mode: .It Li "Z" Ta "Suspend tagged clients" .It Li "f" Ta "Enter a format to filter items" .It Li "O" Ta "Change sort order" +.It Li "v" Ta "Toggle preview" .It Li "q" Ta "Exit mode" .El .Pp @@ -1404,10 +1406,12 @@ or specifies an initial filter. .Fl F specifies the format for each item in the list. +.Fl N +starts without the preview. This command works only if at least one client is attached. .It Xo .Ic choose-tree -.Op Fl sw +.Op Fl Nsw .Op Fl F Ar format .Op Fl f Ar filter .Op Fl O Ar sort-order @@ -1436,6 +1440,7 @@ The following keys may be used in tree mode: .It Li "\&:" Ta "Run a command for each tagged item" .It Li "f" Ta "Enter a format to filter items" .It Li "O" Ta "Change sort order" +.It Li "v" Ta "Toggle preview" .It Li "q" Ta "Exit mode" .El .Pp @@ -1458,6 +1463,8 @@ or specifies an initial filter. .Fl F specifies the format for each item in the tree. +.Fl N +starts without the preview. This command works only if at least one client is attached. .It Xo .Ic display-panes @@ -4054,6 +4061,7 @@ The buffer commands are as follows: .Bl -tag -width Ds .It Xo .Ic choose-buffer +.Op Fl N .Op Fl F Ar format .Op Fl f Ar filter .Op Fl O Ar sort-order @@ -4077,6 +4085,7 @@ The following keys may be used in buffer mode: .It Li "D" Ta "Delete tagged buffers" .It Li "f" Ta "Enter a format to filter items" .It Li "O" Ta "Change sort order" +.It Li "v" Ta "Toggle preview" .It Li "q" Ta "Exit mode" .El .Pp @@ -4099,6 +4108,8 @@ or specifies an initial filter. .Fl F specifies the format for each item in the list. +.Fl N +starts without the preview. This command works only if at least one client is attached. .It Ic clear-history Op Fl t Ar target-pane .D1 (alias: Ic clearhist ) |