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.
This commit is contained in:
Nicholas Marriott
2013-03-24 09:57:59 +00:00
parent a05b8c4143
commit c71844de63
16 changed files with 108 additions and 10 deletions

View File

@ -319,7 +319,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");
@ -348,6 +348,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);
@ -470,6 +472,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)
{
@ -600,6 +650,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';
@ -1027,6 +1079,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)