summaryrefslogtreecommitdiffstats
path: root/window.c
diff options
context:
space:
mode:
Diffstat (limited to 'window.c')
-rw-r--r--window.c56
1 files changed, 55 insertions, 1 deletions
diff --git a/window.c b/window.c
index dfece2ee..38af88f9 100644
--- a/window.c
+++ b/window.c
@@ -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)