diff options
author | Nicholas Marriott <nicm@cvs.openbsd.org> | 2018-02-28 08:55:45 +0000 |
---|---|---|
committer | Nicholas Marriott <nicm@cvs.openbsd.org> | 2018-02-28 08:55:45 +0000 |
commit | e2c0e1db5f2744114d240b5c3ce5763ad64798d5 (patch) | |
tree | bb35a1643247ef2313ec54e9df3524b3ca2e2659 | |
parent | 6ac34f77934c7bbb491991bea2af289e2b175dfc (diff) |
Add -Z flag to choose-tree, choose-client, choose-buffer to
automatically zoom the pane when the mode is entered and unzoom when it
exits, assuming the pane is not already zoomed. Add -Z to the default
key bindings.
-rw-r--r-- | usr.bin/tmux/cmd-choose-tree.c | 8 | ||||
-rw-r--r-- | usr.bin/tmux/key-bindings.c | 10 | ||||
-rw-r--r-- | usr.bin/tmux/mode-tree.c | 21 | ||||
-rw-r--r-- | usr.bin/tmux/server-fn.c | 6 | ||||
-rw-r--r-- | usr.bin/tmux/tmux.1 | 16 | ||||
-rw-r--r-- | usr.bin/tmux/tmux.h | 3 | ||||
-rw-r--r-- | usr.bin/tmux/window-buffer.c | 3 | ||||
-rw-r--r-- | usr.bin/tmux/window-client.c | 3 | ||||
-rw-r--r-- | usr.bin/tmux/window-tree.c | 3 |
9 files changed, 50 insertions, 23 deletions
diff --git a/usr.bin/tmux/cmd-choose-tree.c b/usr.bin/tmux/cmd-choose-tree.c index 8ba096952ef..1166383a239 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.40 2017/11/02 18:27:35 nicm Exp $ */ +/* $OpenBSD: cmd-choose-tree.c,v 1.41 2018/02/28 08:55:44 nicm Exp $ */ /* * Copyright (c) 2012 Thomas Adam <thomas@xteddy.org> @@ -30,7 +30,7 @@ const struct cmd_entry cmd_choose_tree_entry = { .name = "choose-tree", .alias = NULL, - .args = { "F:Gf:NO:st:w", 0, 1 }, + .args = { "F:Gf:NO:st:wZ", 0, 1 }, .usage = "[-GNsw] [-F format] [-f filter] [-O sort-order] " CMD_TARGET_PANE_USAGE, @@ -44,7 +44,7 @@ const struct cmd_entry cmd_choose_client_entry = { .name = "choose-client", .alias = NULL, - .args = { "F:f:NO:t:", 0, 1 }, + .args = { "F:f:NO:t:Z", 0, 1 }, .usage = "[-N] [-F format] [-f filter] [-O sort-order] " CMD_TARGET_PANE_USAGE, @@ -58,7 +58,7 @@ const struct cmd_entry cmd_choose_buffer_entry = { .name = "choose-buffer", .alias = NULL, - .args = { "F:f:NO:t:", 0, 1 }, + .args = { "F:f:NO:t:Z", 0, 1 }, .usage = "[-N] [-F format] [-f filter] [-O sort-order] " CMD_TARGET_PANE_USAGE, diff --git a/usr.bin/tmux/key-bindings.c b/usr.bin/tmux/key-bindings.c index 4bb01f36c66..b41fa391326 100644 --- a/usr.bin/tmux/key-bindings.c +++ b/usr.bin/tmux/key-bindings.c @@ -1,4 +1,4 @@ -/* $OpenBSD: key-bindings.c,v 1.84 2017/11/15 19:59:27 nicm Exp $ */ +/* $OpenBSD: key-bindings.c,v 1.85 2018/02/28 08:55:44 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com> @@ -183,9 +183,9 @@ key_bindings_init(void) "bind 9 select-window -t:=9", "bind : command-prompt", "bind \\; last-pane", - "bind = choose-buffer", + "bind = choose-buffer -Z", "bind ? list-keys", - "bind D choose-client", + "bind D choose-client -Z", "bind E select-layout -E", "bind L switch-client -l", "bind M select-pane -M", @@ -202,9 +202,9 @@ key_bindings_init(void) "bind p previous-window", "bind q display-panes", "bind r refresh-client", - "bind s choose-tree -s", + "bind s choose-tree -Zs", "bind t clock-mode", - "bind w choose-tree -w", + "bind w choose-tree -Zw", "bind x confirm-before -p\"kill-pane #P? (y/n)\" kill-pane", "bind z resize-pane -Z", "bind { swap-pane -U", diff --git a/usr.bin/tmux/mode-tree.c b/usr.bin/tmux/mode-tree.c index 1e46b266e12..8b6ba887252 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.22 2018/02/26 08:09:56 nicm Exp $ */ +/* $OpenBSD: mode-tree.c,v 1.23 2018/02/28 08:55:44 nicm Exp $ */ /* * Copyright (c) 2017 Nicholas Marriott <nicholas.marriott@gmail.com> @@ -31,6 +31,7 @@ TAILQ_HEAD(mode_tree_list, mode_tree_item); struct mode_tree_data { int dead; u_int references; + int zoomed; struct window_pane *wp; void *modedata; @@ -344,6 +345,19 @@ mode_tree_start(struct window_pane *wp, struct args *args, } void +mode_tree_zoom(struct mode_tree_data *mtd, struct args *args) +{ + struct window_pane *wp = mtd->wp; + + if (args_has(args, 'Z')) { + mtd->zoomed = (wp->window->flags & WINDOW_ZOOMED); + if (!mtd->zoomed && window_zoom(wp) == 0) + server_redraw_window(wp->window); + } else + mtd->zoomed = -1; +} + +void mode_tree_build(struct mode_tree_data *mtd) { struct screen *s = &mtd->screen; @@ -394,6 +408,11 @@ mode_tree_remove_ref(struct mode_tree_data *mtd) void mode_tree_free(struct mode_tree_data *mtd) { + struct window_pane *wp = mtd->wp; + + if (mtd->zoomed == 0) + server_unzoom_window(wp->window); + mode_tree_free_items(&mtd->children); mode_tree_clear_lines(mtd); screen_free(&mtd->screen); diff --git a/usr.bin/tmux/server-fn.c b/usr.bin/tmux/server-fn.c index b20654545d6..71a714e3b74 100644 --- a/usr.bin/tmux/server-fn.c +++ b/usr.bin/tmux/server-fn.c @@ -1,4 +1,4 @@ -/* $OpenBSD: server-fn.c,v 1.112 2017/10/12 11:32:27 nicm Exp $ */ +/* $OpenBSD: server-fn.c,v 1.113 2018/02/28 08:55:44 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com> @@ -455,8 +455,6 @@ server_set_stdin_callback(struct client *c, void (*cb)(struct client *, int, void server_unzoom_window(struct window *w) { - if (window_unzoom(w) == 0) { + if (window_unzoom(w) == 0) server_redraw_window(w); - server_status_window(w); - } } diff --git a/usr.bin/tmux/tmux.1 b/usr.bin/tmux/tmux.1 index 4fb28f77588..db8d3f604ec 100644 --- a/usr.bin/tmux/tmux.1 +++ b/usr.bin/tmux/tmux.1 @@ -1,4 +1,4 @@ -.\" $OpenBSD: tmux.1,v 1.592 2018/02/22 10:54:51 nicm Exp $ +.\" $OpenBSD: tmux.1,v 1.593 2018/02/28 08:55:44 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: February 22 2018 $ +.Dd $Mdocdate: February 28 2018 $ .Dt TMUX 1 .Os .Sh NAME @@ -1377,7 +1377,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 NZ .Op Fl F Ar format .Op Fl f Ar filter .Op Fl O Ar sort-order @@ -1386,6 +1386,8 @@ The default is to capture only the visible contents of the pane. .Xc Put a pane into client mode, allowing a client to be selected interactively from a list. +.Fl Z +zooms the pane. The following keys may be used in client mode: .Bl -column "Key" "Function" -offset indent .It Sy "Key" Ta Sy "Function" @@ -1436,7 +1438,7 @@ starts without the preview. This command works only if at least one client is attached. .It Xo .Ic choose-tree -.Op Fl GNsw +.Op Fl GNswZ .Op Fl F Ar format .Op Fl f Ar filter .Op Fl O Ar sort-order @@ -1449,6 +1451,8 @@ interactively from a list. starts with sessions collapsed and .Fl w with windows collapsed. +.Fl Z +zooms the pane. The following keys may be used in tree mode: .Bl -column "Key" "Function" -offset indent .It Sy "Key" Ta Sy "Function" @@ -4129,7 +4133,7 @@ The buffer commands are as follows: .Bl -tag -width Ds .It Xo .Ic choose-buffer -.Op Fl N +.Op Fl NZ .Op Fl F Ar format .Op Fl f Ar filter .Op Fl O Ar sort-order @@ -4138,6 +4142,8 @@ The buffer commands are as follows: .Xc Put a pane into buffer mode, where a buffer may be chosen interactively from a list. +.Fl Z +zooms the pane. The following keys may be used in buffer mode: .Bl -column "Key" "Function" -offset indent .It Sy "Key" Ta Sy "Function" diff --git a/usr.bin/tmux/tmux.h b/usr.bin/tmux/tmux.h index 919252e6c96..f8d2c32bccc 100644 --- a/usr.bin/tmux/tmux.h +++ b/usr.bin/tmux/tmux.h @@ -1,4 +1,4 @@ -/* $OpenBSD: tmux.h,v 1.819 2018/02/16 09:51:41 nicm Exp $ */ +/* $OpenBSD: tmux.h,v 1.820 2018/02/28 08:55:44 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com> @@ -2247,6 +2247,7 @@ void mode_tree_down(struct mode_tree_data *, int); struct mode_tree_data *mode_tree_start(struct window_pane *, struct args *, mode_tree_build_cb, mode_tree_draw_cb, mode_tree_search_cb, void *, const char **, u_int, struct screen **); +void mode_tree_zoom(struct mode_tree_data *, struct args *); void mode_tree_build(struct mode_tree_data *); void mode_tree_free(struct mode_tree_data *); void mode_tree_resize(struct mode_tree_data *, u_int, u_int); diff --git a/usr.bin/tmux/window-buffer.c b/usr.bin/tmux/window-buffer.c index 6d62830b4ba..f1fd8dcb2b6 100644 --- a/usr.bin/tmux/window-buffer.c +++ b/usr.bin/tmux/window-buffer.c @@ -1,4 +1,4 @@ -/* $OpenBSD: window-buffer.c,v 1.12 2017/11/03 17:02:33 nicm Exp $ */ +/* $OpenBSD: window-buffer.c,v 1.13 2018/02/28 08:55:44 nicm Exp $ */ /* * Copyright (c) 2017 Nicholas Marriott <nicholas.marriott@gmail.com> @@ -273,6 +273,7 @@ window_buffer_init(struct window_pane *wp, __unused struct cmd_find_state *fs, data->data = mode_tree_start(wp, args, window_buffer_build, window_buffer_draw, window_buffer_search, data, window_buffer_sort_list, nitems(window_buffer_sort_list), &s); + mode_tree_zoom(data->data, args); mode_tree_build(data->data); mode_tree_draw(data->data); diff --git a/usr.bin/tmux/window-client.c b/usr.bin/tmux/window-client.c index efd947dc64e..b586f4d4023 100644 --- a/usr.bin/tmux/window-client.c +++ b/usr.bin/tmux/window-client.c @@ -1,4 +1,4 @@ -/* $OpenBSD: window-client.c,v 1.13 2018/02/05 08:21:54 nicm Exp $ */ +/* $OpenBSD: window-client.c,v 1.14 2018/02/28 08:55:44 nicm Exp $ */ /* * Copyright (c) 2017 Nicholas Marriott <nicholas.marriott@gmail.com> @@ -256,6 +256,7 @@ window_client_init(struct window_pane *wp, __unused struct cmd_find_state *fs, data->data = mode_tree_start(wp, args, window_client_build, window_client_draw, NULL, data, window_client_sort_list, nitems(window_client_sort_list), &s); + mode_tree_zoom(data->data, args); mode_tree_build(data->data); mode_tree_draw(data->data); diff --git a/usr.bin/tmux/window-tree.c b/usr.bin/tmux/window-tree.c index dbe96d674b9..2dddb0a99a5 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.27 2017/11/03 17:02:33 nicm Exp $ */ +/* $OpenBSD: window-tree.c,v 1.28 2018/02/28 08:55:44 nicm Exp $ */ /* * Copyright (c) 2017 Nicholas Marriott <nicholas.marriott@gmail.com> @@ -841,6 +841,7 @@ window_tree_init(struct window_pane *wp, struct cmd_find_state *fs, data->data = mode_tree_start(wp, args, window_tree_build, window_tree_draw, window_tree_search, data, window_tree_sort_list, nitems(window_tree_sort_list), &s); + mode_tree_zoom(data->data, args); mode_tree_build(data->data); mode_tree_draw(data->data); |