summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicholas Marriott <nicm@cvs.openbsd.org>2013-03-24 09:58:00 +0000
committerNicholas Marriott <nicm@cvs.openbsd.org>2013-03-24 09:58:00 +0000
commit047a733e6947034ce62a51ab1301d5cfb3bd0abe (patch)
tree877a049ef2934bc136505a98ed24a2e8e2dedb7f
parente6e3e05e33040b1ac0ab0fd4e1a39aa94323411d (diff)
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.
-rw-r--r--usr.bin/tmux/cmd-break-pane.c6
-rw-r--r--usr.bin/tmux/cmd-join-pane.c4
-rw-r--r--usr.bin/tmux/cmd-kill-pane.c3
-rw-r--r--usr.bin/tmux/cmd-resize-pane.c23
-rw-r--r--usr.bin/tmux/cmd-respawn-window.c4
-rw-r--r--usr.bin/tmux/cmd-select-layout.c3
-rw-r--r--usr.bin/tmux/cmd-select-pane.c4
-rw-r--r--usr.bin/tmux/cmd-split-window.c3
-rw-r--r--usr.bin/tmux/cmd-swap-pane.c4
-rw-r--r--usr.bin/tmux/input-keys.c5
-rw-r--r--usr.bin/tmux/key-bindings.c3
-rw-r--r--usr.bin/tmux/layout.c6
-rw-r--r--usr.bin/tmux/resize.c10
-rw-r--r--usr.bin/tmux/server-client.c3
-rw-r--r--usr.bin/tmux/server-fn.c11
-rw-r--r--usr.bin/tmux/tmux.19
-rw-r--r--usr.bin/tmux/tmux.h11
-rw-r--r--usr.bin/tmux/window.c58
18 files changed, 140 insertions, 30 deletions
diff --git a/usr.bin/tmux/cmd-break-pane.c b/usr.bin/tmux/cmd-break-pane.c
index 201ee8ed74e..ddb967e1906 100644
--- a/usr.bin/tmux/cmd-break-pane.c
+++ b/usr.bin/tmux/cmd-break-pane.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: cmd-break-pane.c,v 1.20 2013/03/24 09:54:10 nicm Exp $ */
+/* $OpenBSD: cmd-break-pane.c,v 1.21 2013/03/24 09:57:59 nicm Exp $ */
/*
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -63,6 +63,8 @@ cmd_break_pane_exec(struct cmd *self, struct cmd_q *cmdq)
}
w = wl->window;
+ server_unzoom_window(w);
+
TAILQ_REMOVE(&w->panes, wp, entry);
if (wp == w->active) {
w->active = w->last;
@@ -82,7 +84,7 @@ cmd_break_pane_exec(struct cmd *self, struct cmd_q *cmdq)
name = default_window_name(w);
window_set_name(w, name);
free(name);
- layout_init(w);
+ layout_init(w, wp);
base_idx = options_get_number(&s->options, "base-index");
wl = session_attach(s, w, -1 - base_idx, &cause); /* can't fail */
diff --git a/usr.bin/tmux/cmd-join-pane.c b/usr.bin/tmux/cmd-join-pane.c
index f9c316e8d71..1cc07806b44 100644
--- a/usr.bin/tmux/cmd-join-pane.c
+++ b/usr.bin/tmux/cmd-join-pane.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: cmd-join-pane.c,v 1.13 2013/03/24 09:54:10 nicm Exp $ */
+/* $OpenBSD: cmd-join-pane.c,v 1.14 2013/03/24 09:57:59 nicm Exp $ */
/*
* Copyright (c) 2011 George Nachman <tmux@georgester.com>
@@ -92,11 +92,13 @@ join_pane(struct cmd *self, struct cmd_q *cmdq, int not_same_window)
return (CMD_RETURN_ERROR);
dst_w = dst_wl->window;
dst_idx = dst_wl->idx;
+ server_unzoom_window(dst_w);
src_wl = cmd_find_pane(cmdq, args_get(args, 's'), NULL, &src_wp);
if (src_wl == NULL)
return (CMD_RETURN_ERROR);
src_w = src_wl->window;
+ server_unzoom_window(src_w);
if (not_same_window && src_w == dst_w) {
cmdq_error(cmdq, "can't join a pane to its own window");
diff --git a/usr.bin/tmux/cmd-kill-pane.c b/usr.bin/tmux/cmd-kill-pane.c
index 3ace6259eda..a54e50efc33 100644
--- a/usr.bin/tmux/cmd-kill-pane.c
+++ b/usr.bin/tmux/cmd-kill-pane.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: cmd-kill-pane.c,v 1.13 2013/03/24 09:54:10 nicm Exp $ */
+/* $OpenBSD: cmd-kill-pane.c,v 1.14 2013/03/24 09:57:59 nicm Exp $ */
/*
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -47,6 +47,7 @@ cmd_kill_pane_exec(struct cmd *self, struct cmd_q *cmdq)
if ((wl = cmd_find_pane(cmdq, args_get(args, 't'), NULL, &wp)) == NULL)
return (CMD_RETURN_ERROR);
+ server_unzoom_window(wl->window);
if (window_count_panes(wl->window) == 1) {
/* Only one pane, kill the window. */
diff --git a/usr.bin/tmux/cmd-resize-pane.c b/usr.bin/tmux/cmd-resize-pane.c
index 0efc9d2ab23..b4ca8d6c39b 100644
--- a/usr.bin/tmux/cmd-resize-pane.c
+++ b/usr.bin/tmux/cmd-resize-pane.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: cmd-resize-pane.c,v 1.14 2013/03/24 09:54:10 nicm Exp $ */
+/* $OpenBSD: cmd-resize-pane.c,v 1.15 2013/03/24 09:57:59 nicm Exp $ */
/*
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -31,8 +31,8 @@ enum cmd_retval cmd_resize_pane_exec(struct cmd *, struct cmd_q *);
const struct cmd_entry cmd_resize_pane_entry = {
"resize-pane", "resizep",
- "DLRt:Ux:y:", 0, 1,
- "[-DLRU] [-x width] [-y height] " CMD_TARGET_PANE_USAGE " [adjustment]",
+ "DLRt:Ux:y:Z", 0, 1,
+ "[-DLRUZ] [-x width] [-y height] " CMD_TARGET_PANE_USAGE " [adjustment]",
0,
cmd_resize_pane_key_binding,
NULL,
@@ -75,6 +75,10 @@ cmd_resize_pane_key_binding(struct cmd *self, int key)
self->args = args_create(1, "5");
args_set(self->args, 'R', NULL);
break;
+ case 'z':
+ self->args = args_create(0);
+ args_set(self->args, 'Z', NULL);
+ break;
default:
self->args = args_create(0);
break;
@@ -86,6 +90,7 @@ cmd_resize_pane_exec(struct cmd *self, struct cmd_q *cmdq)
{
struct args *args = self->args;
struct winlink *wl;
+ struct window *w;
const char *errstr;
char *cause;
struct window_pane *wp;
@@ -94,6 +99,18 @@ cmd_resize_pane_exec(struct cmd *self, struct cmd_q *cmdq)
if ((wl = cmd_find_pane(cmdq, args_get(args, 't'), NULL, &wp)) == NULL)
return (CMD_RETURN_ERROR);
+ w = wl->window;
+
+ if (args_has(args, 'Z')) {
+ if (w->flags & WINDOW_ZOOMED)
+ window_unzoom(w);
+ else
+ window_zoom(wp);
+ server_redraw_window(w);
+ server_status_window(w);
+ return (CMD_RETURN_NORMAL);
+ }
+ server_unzoom_window(w);
if (args->argc == 0)
adjust = 1;
diff --git a/usr.bin/tmux/cmd-respawn-window.c b/usr.bin/tmux/cmd-respawn-window.c
index f236d057958..0c6e5e9f358 100644
--- a/usr.bin/tmux/cmd-respawn-window.c
+++ b/usr.bin/tmux/cmd-respawn-window.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: cmd-respawn-window.c,v 1.17 2013/03/24 09:54:10 nicm Exp $ */
+/* $OpenBSD: cmd-respawn-window.c,v 1.18 2013/03/24 09:57:59 nicm Exp $ */
/*
* Copyright (c) 2008 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -87,7 +87,7 @@ cmd_respawn_window_exec(struct cmd *self, struct cmd_q *cmdq)
server_destroy_pane(wp);
return (CMD_RETURN_ERROR);
}
- layout_init(w);
+ layout_init(w, wp);
window_pane_reset_mode(wp);
screen_reinit(&wp->base);
input_init(wp);
diff --git a/usr.bin/tmux/cmd-select-layout.c b/usr.bin/tmux/cmd-select-layout.c
index 06cbf748ef9..dceab05b3d2 100644
--- a/usr.bin/tmux/cmd-select-layout.c
+++ b/usr.bin/tmux/cmd-select-layout.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: cmd-select-layout.c,v 1.19 2013/03/24 09:54:10 nicm Exp $ */
+/* $OpenBSD: cmd-select-layout.c,v 1.20 2013/03/24 09:57:59 nicm Exp $ */
/*
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -92,6 +92,7 @@ cmd_select_layout_exec(struct cmd *self, struct cmd_q *cmdq)
if ((wl = cmd_find_window(cmdq, args_get(args, 't'), NULL)) == NULL)
return (CMD_RETURN_ERROR);
+ server_unzoom_window(wl->window);
next = self->entry == &cmd_next_layout_entry;
if (args_has(self->args, 'n'))
diff --git a/usr.bin/tmux/cmd-select-pane.c b/usr.bin/tmux/cmd-select-pane.c
index f000dfcadaa..3f9f8f2ac5f 100644
--- a/usr.bin/tmux/cmd-select-pane.c
+++ b/usr.bin/tmux/cmd-select-pane.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: cmd-select-pane.c,v 1.15 2013/03/24 09:54:10 nicm Exp $ */
+/* $OpenBSD: cmd-select-pane.c,v 1.16 2013/03/24 09:57:59 nicm Exp $ */
/*
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -80,6 +80,7 @@ cmd_select_pane_exec(struct cmd *self, struct cmd_q *cmdq)
return (CMD_RETURN_ERROR);
}
+ server_unzoom_window(wl->window);
window_set_active_pane(wl->window, wl->window->last);
server_status_window(wl->window);
server_redraw_window_borders(wl->window);
@@ -90,6 +91,7 @@ cmd_select_pane_exec(struct cmd *self, struct cmd_q *cmdq)
if ((wl = cmd_find_pane(cmdq, args_get(args, 't'), NULL, &wp)) == NULL)
return (CMD_RETURN_ERROR);
+ server_unzoom_window(wp->window);
if (!window_pane_visible(wp)) {
cmdq_error(cmdq, "pane not visible");
return (CMD_RETURN_ERROR);
diff --git a/usr.bin/tmux/cmd-split-window.c b/usr.bin/tmux/cmd-split-window.c
index 863d01bf87a..14f911cbebe 100644
--- a/usr.bin/tmux/cmd-split-window.c
+++ b/usr.bin/tmux/cmd-split-window.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: cmd-split-window.c,v 1.40 2013/03/24 09:54:10 nicm Exp $ */
+/* $OpenBSD: cmd-split-window.c,v 1.41 2013/03/24 09:57:59 nicm Exp $ */
/*
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -73,6 +73,7 @@ cmd_split_window_exec(struct cmd *self, struct cmd_q *cmdq)
if ((wl = cmd_find_pane(cmdq, args_get(args, 't'), &s, &wp)) == NULL)
return (CMD_RETURN_ERROR);
w = wl->window;
+ server_unzoom_window(w);
environ_init(&env);
environ_copy(&global_environ, &env);
diff --git a/usr.bin/tmux/cmd-swap-pane.c b/usr.bin/tmux/cmd-swap-pane.c
index 8999cb7fd02..75a7cce35c7 100644
--- a/usr.bin/tmux/cmd-swap-pane.c
+++ b/usr.bin/tmux/cmd-swap-pane.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: cmd-swap-pane.c,v 1.15 2013/03/24 09:54:10 nicm Exp $ */
+/* $OpenBSD: cmd-swap-pane.c,v 1.16 2013/03/24 09:57:59 nicm Exp $ */
/*
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -63,6 +63,7 @@ cmd_swap_pane_exec(struct cmd *self, struct cmd_q *cmdq)
if (dst_wl == NULL)
return (CMD_RETURN_ERROR);
dst_w = dst_wl->window;
+ server_unzoom_window(dst_w);
if (!args_has(args, 's')) {
src_w = dst_w;
@@ -82,6 +83,7 @@ cmd_swap_pane_exec(struct cmd *self, struct cmd_q *cmdq)
return (CMD_RETURN_ERROR);
src_w = src_wl->window;
}
+ server_unzoom_window(src_w);
if (src_wp == dst_wp)
return (CMD_RETURN_NORMAL);
diff --git a/usr.bin/tmux/input-keys.c b/usr.bin/tmux/input-keys.c
index c19244dce4d..fb36dfeb195 100644
--- a/usr.bin/tmux/input-keys.c
+++ b/usr.bin/tmux/input-keys.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: input-keys.c,v 1.31 2013/03/22 10:33:50 nicm Exp $ */
+/* $OpenBSD: input-keys.c,v 1.32 2013/03/24 09:57:59 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -219,7 +219,8 @@ input_mouse(struct window_pane *wp, struct session *s, struct mouse_event *m)
*/
if (m->sgr && (wp->screen->mode & MODE_MOUSE_SGR)) {
len = xsnprintf(buf, sizeof buf, "\033[<%d;%d;%d%c",
- m->sgr_xb, m->x + 1, m->y + 1, m->sgr_rel ? 'm' : 'M');
+ m->sgr_xb, m->x + 1, m->y + 1,
+ m->sgr_rel ? 'm' : 'M');
} else if (wp->screen->mode & MODE_MOUSE_UTF8) {
len = xsnprintf(buf, sizeof buf, "\033[M");
len += utf8_split2(m->xb + 32, &buf[len]);
diff --git a/usr.bin/tmux/key-bindings.c b/usr.bin/tmux/key-bindings.c
index 09cd2f39318..a9d7976aab2 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.38 2013/03/24 09:54:10 nicm Exp $ */
+/* $OpenBSD: key-bindings.c,v 1.39 2013/03/24 09:57:59 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -150,6 +150,7 @@ key_bindings_init(void)
{ 't', 0, &cmd_clock_mode_entry },
{ 'w', 0, &cmd_choose_window_entry },
{ 'x', 0, &cmd_confirm_before_entry },
+ { 'z', 0, &cmd_resize_pane_entry },
{ '{', 0, &cmd_swap_pane_entry },
{ '}', 0, &cmd_swap_pane_entry },
{ '~', 0, &cmd_show_messages_entry },
diff --git a/usr.bin/tmux/layout.c b/usr.bin/tmux/layout.c
index fe494fa7f9d..888e6ba6573 100644
--- a/usr.bin/tmux/layout.c
+++ b/usr.bin/tmux/layout.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: layout.c,v 1.17 2013/03/22 10:37:39 nicm Exp $ */
+/* $OpenBSD: layout.c,v 1.18 2013/03/24 09:57:59 nicm Exp $ */
/*
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -374,13 +374,13 @@ layout_destroy_cell(struct layout_cell *lc, struct layout_cell **lcroot)
}
void
-layout_init(struct window *w)
+layout_init(struct window *w, struct window_pane *wp)
{
struct layout_cell *lc;
lc = w->layout_root = layout_create_cell(NULL);
layout_set_size(lc, w->sx, w->sy, 0, 0);
- layout_make_leaf(lc, TAILQ_FIRST(&w->panes));
+ layout_make_leaf(lc, wp);
layout_fix_panes(w, w->sx, w->sy);
}
diff --git a/usr.bin/tmux/resize.c b/usr.bin/tmux/resize.c
index dd3ef31dee2..1f56a3a0972 100644
--- a/usr.bin/tmux/resize.c
+++ b/usr.bin/tmux/resize.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: resize.c,v 1.9 2013/03/21 18:46:12 nicm Exp $ */
+/* $OpenBSD: resize.c,v 1.10 2013/03/24 09:57:59 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -50,7 +50,7 @@ recalculate_sizes(void)
struct window *w;
struct window_pane *wp;
u_int i, j, ssx, ssy, has, limit;
- int flag, has_status;
+ int flag, has_status, is_zoomed;
RB_FOREACH(s, sessions, &sessions) {
has_status = options_get_number(&s->options, "status");
@@ -123,12 +123,16 @@ recalculate_sizes(void)
if (w->sx == ssx && w->sy == ssy)
continue;
-
log_debug("window size %u,%u (was %u,%u)", ssx, ssy, w->sx,
w->sy);
+ is_zoomed = w->flags & WINDOW_ZOOMED;
+ if (is_zoomed)
+ window_unzoom(w);
layout_resize(w, ssx, ssy);
window_resize(w, ssx, ssy);
+ if (is_zoomed && window_pane_visible(w->active))
+ window_zoom(w->active);
/*
* If the current pane is now not visible, move to the next
diff --git a/usr.bin/tmux/server-client.c b/usr.bin/tmux/server-client.c
index 88244dbc9e2..edadf6f45bd 100644
--- a/usr.bin/tmux/server-client.c
+++ b/usr.bin/tmux/server-client.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: server-client.c,v 1.94 2013/03/24 09:54:10 nicm Exp $ */
+/* $OpenBSD: server-client.c,v 1.95 2013/03/24 09:57:59 nicm Exp $ */
/*
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -384,6 +384,7 @@ server_client_handle_key(struct client *c, int key)
if (c->flags & CLIENT_IDENTIFY && key >= '0' && key <= '9') {
if (c->flags & CLIENT_READONLY)
return;
+ window_unzoom(w);
wp = window_pane_at_index(w, key - '0');
if (wp != NULL && window_pane_visible(wp))
window_set_active_pane(w, wp);
diff --git a/usr.bin/tmux/server-fn.c b/usr.bin/tmux/server-fn.c
index 22919ce8822..fcd55b0b311 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.65 2013/03/24 09:54:10 nicm Exp $ */
+/* $OpenBSD: server-fn.c,v 1.66 2013/03/24 09:57:59 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -377,6 +377,7 @@ server_destroy_pane(struct window_pane *wp)
return;
}
+ server_unzoom_window(w);
layout_close_pane(wp);
window_remove_pane(w, wp);
@@ -588,3 +589,11 @@ server_set_stdin_callback(struct client *c, void (*cb)(struct client *, int,
return (0);
}
+
+void
+server_unzoom_window(struct window *w)
+{
+ window_unzoom(w);
+ server_redraw_window(w);
+ server_status_window(w);
+}
diff --git a/usr.bin/tmux/tmux.1 b/usr.bin/tmux/tmux.1
index 7ea64491bf2..43b5ff6b34e 100644
--- a/usr.bin/tmux/tmux.1
+++ b/usr.bin/tmux/tmux.1
@@ -1,4 +1,4 @@
-.\" $OpenBSD: tmux.1,v 1.336 2013/03/24 09:55:02 nicm Exp $
+.\" $OpenBSD: tmux.1,v 1.337 2013/03/24 09:57:59 nicm Exp $
.\"
.\" Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
.\"
@@ -1568,7 +1568,7 @@ Rename the current window, or the window at
if specified, to
.Ar new-name .
.It Xo Ic resize-pane
-.Op Fl DLRU
+.Op Fl DLRUZ
.Op Fl t Ar target-pane
.Op Fl x Ar width
.Op Fl y Ar height
@@ -1592,6 +1592,11 @@ or
The
.Ar adjustment
is given in lines or cells (the default is 1).
+.Pp
+With
+.Fl Z ,
+the active pane is toggled between occupying the whole of the window and its
+normal position in the layout.
.It Xo Ic respawn-pane
.Op Fl k
.Op Fl t Ar target-pane
diff --git a/usr.bin/tmux/tmux.h b/usr.bin/tmux/tmux.h
index fe115090eff..194ca9d1804 100644
--- a/usr.bin/tmux/tmux.h
+++ b/usr.bin/tmux/tmux.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: tmux.h,v 1.397 2013/03/24 09:54:10 nicm Exp $ */
+/* $OpenBSD: tmux.h,v 1.398 2013/03/24 09:57:59 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -929,7 +929,9 @@ struct window_pane {
u_int id;
struct window *window;
+
struct layout_cell *layout_cell;
+ struct layout_cell *saved_layout_cell;
u_int sx;
u_int sy;
@@ -994,6 +996,7 @@ struct window {
int lastlayout;
struct layout_cell *layout_root;
+ struct layout_cell *saved_layout_root;
u_int sx;
u_int sy;
@@ -1003,6 +1006,7 @@ struct window {
#define WINDOW_ACTIVITY 0x2
#define WINDOW_REDRAW 0x4
#define WINDOW_SILENCE 0x8
+#define WINDOW_ZOOMED 0x10
struct options options;
@@ -1929,6 +1933,7 @@ void server_push_stdout(struct client *);
void server_push_stderr(struct client *);
int server_set_stdin_callback(struct client *, void (*)(struct client *,
int, void *), void *, char **);
+void server_unzoom_window(struct window *);
/* status.c */
int status_out_cmp(struct status_out *, struct status_out *);
@@ -2132,6 +2137,8 @@ struct window_pane *window_find_string(struct window *, const char *);
void window_set_active_pane(struct window *, struct window_pane *);
struct window_pane *window_add_pane(struct window *, u_int);
void window_resize(struct window *, u_int, u_int);
+int window_zoom(struct window_pane *);
+int window_unzoom(struct window *);
void window_remove_pane(struct window *, struct window_pane *);
struct window_pane *window_pane_at_index(struct window *, u_int);
struct window_pane *window_pane_next_by_number(struct window *,
@@ -2188,7 +2195,7 @@ void layout_fix_panes(struct window *, u_int, u_int);
u_int layout_resize_check(struct layout_cell *, enum layout_type);
void layout_resize_adjust(
struct layout_cell *, enum layout_type, int);
-void layout_init(struct window *);
+void layout_init(struct window *, struct window_pane *);
void layout_free(struct window *);
void layout_resize(struct window *, u_int, u_int);
void layout_resize_pane(struct window_pane *, enum layout_type,
diff --git a/usr.bin/tmux/window.c b/usr.bin/tmux/window.c
index f2e7c7dda74..8093ba8c5e6 100644
--- a/usr.bin/tmux/window.c
+++ b/usr.bin/tmux/window.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: window.c,v 1.92 2013/03/24 09:25:04 nicm Exp $ */
+/* $OpenBSD: window.c,v 1.93 2013/03/24 09:57:59 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -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)