mirror of
https://github.com/tmux/tmux.git
synced 2025-01-05 23:38:48 +00:00
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.
This commit is contained in:
parent
4d72b8fff7
commit
508e2f0b3a
@ -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,
|
||||
|
||||
|
@ -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",
|
||||
|
19
mode-tree.c
19
mode-tree.c
@ -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;
|
||||
@ -343,6 +344,19 @@ mode_tree_start(struct window_pane *wp, struct args *args,
|
||||
return (mtd);
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
@ -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);
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
12
tmux.1
12
tmux.1
@ -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"
|
||||
|
1
tmux.h
1
tmux.h
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user