The branch, master has been updated
       via  c5239c59846c2d09725d4b1db0e728b3376c3998 (commit)
      from  be13479f099749b2a199e17505797e51090caca0 (commit)

- Log -----------------------------------------------------------------
commit c5239c59846c2d09725d4b1db0e728b3376c3998
Author: Nicholas Marriott <[email protected]>
Commit: Nicholas Marriott <[email protected]>

    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.
---
 cmd-break-pane.c     |    4 ++-
 cmd-join-pane.c      |    2 +
 cmd-kill-pane.c      |    1 +
 cmd-resize-pane.c    |   21 +++++++++++++++++-
 cmd-respawn-window.c |    2 +-
 cmd-select-layout.c  |    1 +
 cmd-select-pane.c    |    1 +
 cmd-split-window.c   |    1 +
 cmd-swap-pane.c      |    2 +
 input-keys.c         |    3 +-
 key-bindings.c       |    1 +
 layout.c             |    4 +-
 resize.c             |    8 +++++-
 server-client.c      |    1 +
 server-fn.c          |    9 ++++++++
 tmux.1               |    7 +++++-
 tmux.h               |    9 +++++++-
 window.c             |   56 +++++++++++++++++++++++++++++++++++++++++++++++++-
 18 files changed, 121 insertions(+), 12 deletions(-)

diff --git a/cmd-break-pane.c b/cmd-break-pane.c
index 957fe56..8ed9a1a 100644
--- a/cmd-break-pane.c
+++ b/cmd-break-pane.c
@@ -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/cmd-join-pane.c b/cmd-join-pane.c
index 78868cf..2cf587e 100644
--- a/cmd-join-pane.c
+++ b/cmd-join-pane.c
@@ -91,11 +91,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/cmd-kill-pane.c b/cmd-kill-pane.c
index 2b5d2fe..4076135 100644
--- a/cmd-kill-pane.c
+++ b/cmd-kill-pane.c
@@ -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/cmd-resize-pane.c b/cmd-resize-pane.c
index a97b8cd..ca2a6cd 100644
--- a/cmd-resize-pane.c
+++ b/cmd-resize-pane.c
@@ -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/cmd-respawn-window.c b/cmd-respawn-window.c
index 896de54..35bd347 100644
--- a/cmd-respawn-window.c
+++ b/cmd-respawn-window.c
@@ -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/cmd-select-layout.c b/cmd-select-layout.c
index f4e7a71..ae1be4c 100644
--- a/cmd-select-layout.c
+++ b/cmd-select-layout.c
@@ -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/cmd-select-pane.c b/cmd-select-pane.c
index 8921e15..d24d7b3 100644
--- a/cmd-select-pane.c
+++ b/cmd-select-pane.c
@@ -90,6 +90,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/cmd-split-window.c b/cmd-split-window.c
index 304d502..139f7e5 100644
--- a/cmd-split-window.c
+++ b/cmd-split-window.c
@@ -72,6 +72,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/cmd-swap-pane.c b/cmd-swap-pane.c
index 55fe44f..d484f4e 100644
--- a/cmd-swap-pane.c
+++ b/cmd-swap-pane.c
@@ -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/input-keys.c b/input-keys.c
index d57926a..faa7bd1 100644
--- a/input-keys.c
+++ b/input-keys.c
@@ -218,7 +218,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/key-bindings.c b/key-bindings.c
index 91de135..86048ea 100644
--- a/key-bindings.c
+++ b/key-bindings.c
@@ -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/layout.c b/layout.c
index 1f41506..b74bd78 100644
--- a/layout.c
+++ b/layout.c
@@ -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/resize.c b/resize.c
index a560958..5c365df 100644
--- a/resize.c
+++ b/resize.c
@@ -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/server-client.c b/server-client.c
index be880f1..fd729b7 100644
--- a/server-client.c
+++ b/server-client.c
@@ -383,6 +383,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/server-fn.c b/server-fn.c
index e3365db..b09415e 100644
--- a/server-fn.c
+++ b/server-fn.c
@@ -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/tmux.1 b/tmux.1
index 41e76c9..0f385fe 100644
--- a/tmux.1
+++ b/tmux.1
@@ -1572,7 +1572,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
@@ -1596,6 +1596,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 it's
+normal position in the layout.
 .It Xo Ic respawn-pane
 .Op Fl k
 .Op Fl t Ar target-pane
diff --git a/tmux.h b/tmux.h
index f104b74..c29e124 100644
--- a/tmux.h
+++ b/tmux.h
@@ -925,7 +925,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;
@@ -990,6 +992,7 @@ struct window {
 
        int              lastlayout;
        struct layout_cell *layout_root;
+       struct layout_cell *saved_layout_root;
 
        u_int            sx;
        u_int            sy;
@@ -999,6 +1002,7 @@ struct window {
 #define WINDOW_ACTIVITY 0x2
 #define WINDOW_REDRAW 0x4
 #define WINDOW_SILENCE 0x8
+#define WINDOW_ZOOMED 0x10
 
        struct options   options;
 
@@ -1925,6 +1929,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 *);
@@ -2128,6 +2133,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 *,
@@ -2184,7 +2191,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/window.c b/window.c
index 5ca1811..fc06e87 100644
--- a/window.c
+++ b/window.c
@@ -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)


-----------------------------------------------------------------------

Summary of changes:
 cmd-break-pane.c     |    4 ++-
 cmd-join-pane.c      |    2 +
 cmd-kill-pane.c      |    1 +
 cmd-resize-pane.c    |   21 +++++++++++++++++-
 cmd-respawn-window.c |    2 +-
 cmd-select-layout.c  |    1 +
 cmd-select-pane.c    |    1 +
 cmd-split-window.c   |    1 +
 cmd-swap-pane.c      |    2 +
 input-keys.c         |    3 +-
 key-bindings.c       |    1 +
 layout.c             |    4 +-
 resize.c             |    8 +++++-
 server-client.c      |    1 +
 server-fn.c          |    9 ++++++++
 tmux.1               |    7 +++++-
 tmux.h               |    9 +++++++-
 window.c             |   56 +++++++++++++++++++++++++++++++++++++++++++++++++-
 18 files changed, 121 insertions(+), 12 deletions(-)


hooks/post-receive
-- 
tmux

------------------------------------------------------------------------------
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_d2d_feb
_______________________________________________
tmux-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/tmux-cvs

Reply via email to