diff options
author | Nicholas Marriott <nicholas.marriott@gmail.com> | 2013-02-24 00:25:03 +0000 |
---|---|---|
committer | Nicholas Marriott <nicholas.marriott@gmail.com> | 2013-02-24 00:25:03 +0000 |
commit | c5239c59846c2d09725d4b1db0e728b3376c3998 (patch) | |
tree | 1fedf6dcd02ec5c6b18ee45146dc21957d4b8c4e /window.c | |
parent | be13479f099749b2a199e17505797e51090caca0 (diff) | |
download | rtmux-c5239c59846c2d09725d4b1db0e728b3376c3998.tar.gz rtmux-c5239c59846c2d09725d4b1db0e728b3376c3998.tar.bz2 rtmux-c5239c59846c2d09725d4b1db0e728b3376c3998.zip |
Add resize-pane -Z to temporary zoom the active pane to occupy the full window
or unzoom (restored to the normal layout) if it already zoomed, bound to C-b z
by default. The pane is unzoomed on pretty much any excuse whatsoever.
We considered making this a new layout but the requirements are quite different
from layouts so decided it is better as a special case. Each current layout
cell is saved, a temporary one-cell layout generated and all except the active
pane set to NULL.
Prompted by suggestions and scripts from several. Thanks to Aaron Jensen and
Thiago Padilha for testing an earlier version.
Diffstat (limited to 'window.c')
-rw-r--r-- | window.c | 56 |
1 files changed, 55 insertions, 1 deletions
@@ -316,7 +316,7 @@ window_create(const char *name, const char *cmd, const char *shell, w = window_create1(sx, sy); wp = window_add_pane(w, hlimit); - layout_init(w); + layout_init(w, wp); if (*cmd != '\0') { prefix = options_get_string(&w->options, "command-prefix"); @@ -345,6 +345,8 @@ window_destroy(struct window *w) { u_int i; + window_unzoom(w); + if (window_index(w, &i) != 0) fatalx("index not found"); ARRAY_SET(&windows, i, NULL); @@ -467,6 +469,54 @@ window_find_string(struct window *w, const char *s) return (window_get_active_at(w, x, y)); } +int +window_zoom(struct window_pane *wp) +{ + struct window *w = wp->window; + struct window_pane *wp1; + + if (w->flags & WINDOW_ZOOMED) + return (-1); + + if (!window_pane_visible(wp)) + return (-1); + if (w->active != wp) + window_set_active_pane(w, wp); + + TAILQ_FOREACH(wp1, &w->panes, entry) { + wp1->saved_layout_cell = wp1->layout_cell; + wp1->layout_cell = NULL; + } + + w->saved_layout_root = w->layout_root; + layout_init(w, wp); + w->flags |= WINDOW_ZOOMED; + + return (0); +} + +int +window_unzoom(struct window *w) +{ + struct window_pane *wp, *wp1; + + if (!(w->flags & WINDOW_ZOOMED)) + return (-1); + wp = w->active; + + w->flags &= ~WINDOW_ZOOMED; + layout_free(w); + w->layout_root = w->saved_layout_root; + + TAILQ_FOREACH(wp1, &w->panes, entry) { + wp1->layout_cell = wp1->saved_layout_cell; + wp1->saved_layout_cell = NULL; + } + layout_fix_panes(w, w->sx, w->sy); + + return (0); +} + struct window_pane * window_add_pane(struct window *w, u_int hlimit) { @@ -597,6 +647,8 @@ window_printable_flags(struct session *s, struct winlink *wl) flags[pos++] = '*'; if (wl == TAILQ_FIRST(&s->lastw)) flags[pos++] = '-'; + if (wl->window->flags & WINDOW_ZOOMED) + flags[pos++] = 'Z'; if (pos == 0) flags[pos++] = ' '; flags[pos] = '\0'; @@ -1030,6 +1082,8 @@ window_pane_visible(struct window_pane *wp) { struct window *w = wp->window; + if (wp->layout_cell == NULL) + return (0); if (wp->xoff >= w->sx || wp->yoff >= w->sy) return (0); if (wp->xoff + wp->sx > w->sx || wp->yoff + wp->sy > w->sy) |