Update of /cvsroot/tmux/tmux
In directory sfp-cvsdas-2.v30.ch3.sourceforge.com:/tmp/cvs-serv16728

Modified Files:
        cmd.c key-bindings.c tmux.1 tmux.h window.c 
Added Files:
        cmd-last-pane.c 
Log Message:
Sync OpenBSD patchset 780:

Add a last-pane command (bound to ; by default). Requested ages ago by
somebody whose name I have forgotten.


Index: cmd.c
===================================================================
RCS file: /cvsroot/tmux/tmux/cmd.c,v
retrieving revision 1.143
retrieving revision 1.144
diff -u -d -r1.143 -r1.144
--- cmd.c       24 Oct 2010 00:32:35 -0000      1.143
+++ cmd.c       24 Oct 2010 01:34:30 -0000      1.144
@@ -53,6 +53,7 @@
        &cmd_kill_server_entry,
        &cmd_kill_session_entry,
        &cmd_kill_window_entry,
+       &cmd_last_pane_entry,
        &cmd_last_window_entry,
        &cmd_link_window_entry,
        &cmd_list_buffers_entry,

Index: tmux.1
===================================================================
RCS file: /cvsroot/tmux/tmux/tmux.1,v
retrieving revision 1.268
retrieving revision 1.269
diff -u -d -r1.268 -r1.269
--- tmux.1      24 Oct 2010 00:29:57 -0000      1.268
+++ tmux.1      24 Oct 2010 01:34:30 -0000      1.269
@@ -14,7 +14,7 @@
 .\" IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
 .\" OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 .\"
-.Dd $Mdocdate: October 14 2010 $
+.Dd $Mdocdate: October 23 2010 $
 .Dt TMUX 1
 .Os
 .Sh NAME
@@ -248,6 +248,8 @@
 Enter the
 .Nm
 command prompt.
+.It ;
+Move to the previously active pane.
 .It =
 Choose which buffer to paste interactively from a list.
 .It \&?
@@ -1037,6 +1039,9 @@
 Kill the current window or the window at
 .Ar target-window ,
 removing it from any sessions to which it is linked.
+.It Ic last-pane Op Fl t Ar target-window
+.D1 (alias: Ic lastp )
+Select the last (previously selected) pane.
 .It Ic last-window Op Fl t Ar target-session
 .D1 (alias: Ic last )
 Select the last (previously selected) window.

--- NEW FILE: cmd-last-pane.c ---
/* $Id: cmd-last-pane.c,v 1.1 2010/10/24 01:34:30 tcunha Exp $ */

/*
 * Copyright (c) 2010 Nicholas Marriott <[email protected]>
 *
 * Permission to use, copy, modify, and distribute this software for any
 * purpose with or without fee is hereby granted, provided that the above
 * copyright notice and this permission notice appear in all copies.
 *
 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
 * WHATSOEVER RESULTING FROM LOSS OF MIND, USE, DATA OR PROFITS, WHETHER
 * IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
 * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 */

#include <sys/types.h>

#include "tmux.h"

/*
 * Move to last pane.
 */

int     cmd_last_pane_exec(struct cmd *, struct cmd_ctx *);

const struct cmd_entry cmd_last_pane_entry = {
        "last-pane", "lastp",
        CMD_TARGET_WINDOW_USAGE,
        0, "",
        cmd_target_init,
        cmd_target_parse,
        cmd_last_pane_exec,
        cmd_target_free,
        cmd_target_print
};

int
cmd_last_pane_exec(struct cmd *self, struct cmd_ctx *ctx)
{
        struct cmd_target_data  *data = self->data;
        struct winlink          *wl;
        struct window           *w;

        if ((wl = cmd_find_window(ctx, data->target, NULL)) == NULL)
                return (-1);
        w = wl->window;

        if (w->last == NULL) {
                ctx->error(ctx, "no last pane");
                return (-1);
        }
        window_set_active_pane(w, w->last);

        return (0);
}

Index: window.c
===================================================================
RCS file: /cvsroot/tmux/tmux/window.c,v
retrieving revision 1.139
retrieving revision 1.140
diff -u -d -r1.139 -r1.140
--- window.c    24 Oct 2010 01:32:35 -0000      1.139
+++ window.c    24 Oct 2010 01:34:30 -0000      1.140
@@ -322,6 +322,7 @@
 void
 window_set_active_pane(struct window *w, struct window_pane *wp)
 {
+       w->last = w->active;
        w->active = wp;
        while (!window_pane_visible(w->active)) {
                w->active = TAILQ_PREV(w->active, window_panes, entry);
@@ -366,10 +367,15 @@
 window_remove_pane(struct window *w, struct window_pane *wp)
 {
        if (wp == w->active) {
-               w->active = TAILQ_PREV(wp, window_panes, entry);
-               if (w->active == NULL)
-                       w->active = TAILQ_NEXT(wp, entry);
-       }
+               w->active = w->last;
+               w->last = NULL;
+               if (w->active == NULL) {
+                       w->active = TAILQ_PREV(wp, window_panes, entry);
+                       if (w->active == NULL)
+                               w->active = TAILQ_NEXT(wp, entry);
+               }
+       } else if (wp == w->last)
+               w->last = NULL;
 
        TAILQ_REMOVE(&w->panes, wp, entry);
        window_pane_destroy(wp);

Index: tmux.h
===================================================================
RCS file: /cvsroot/tmux/tmux/tmux.h,v
retrieving revision 1.580
retrieving revision 1.581
diff -u -d -r1.580 -r1.581
--- tmux.h      24 Oct 2010 01:31:08 -0000      1.580
+++ tmux.h      24 Oct 2010 01:34:30 -0000      1.581
@@ -830,6 +830,7 @@
        struct event     name_timer;
 
        struct window_pane *active;
+       struct window_pane *last;
        struct window_panes panes;
 
        int              lastlayout;
@@ -1505,6 +1506,7 @@
 extern const struct cmd_entry cmd_kill_server_entry;
 extern const struct cmd_entry cmd_kill_session_entry;
 extern const struct cmd_entry cmd_kill_window_entry;
+extern const struct cmd_entry cmd_last_pane_entry;
 extern const struct cmd_entry cmd_last_window_entry;
 extern const struct cmd_entry cmd_link_window_entry;
 extern const struct cmd_entry cmd_list_buffers_entry;

Index: key-bindings.c
===================================================================
RCS file: /cvsroot/tmux/tmux/key-bindings.c,v
retrieving revision 1.95
retrieving revision 1.96
diff -u -d -r1.95 -r1.96
--- key-bindings.c      10 Sep 2010 13:36:17 -0000      1.95
+++ key-bindings.c      24 Oct 2010 01:34:30 -0000      1.96
@@ -124,6 +124,7 @@
                { '8',                    0, &cmd_select_window_entry },
                { '9',                    0, &cmd_select_window_entry },
                { ':',                    0, &cmd_command_prompt_entry },
+               { ';',                    0, &cmd_last_pane_entry },
                { '=',                    0, &cmd_choose_buffer_entry },
                { '?',                    0, &cmd_list_keys_entry },
                { 'D',                    0, &cmd_choose_client_entry },


------------------------------------------------------------------------------
Nokia and AT&T present the 2010 Calling All Innovators-North America contest
Create new apps & games for the Nokia N8 for consumers in  U.S. and Canada
$10 million total in prizes - $4M cash, 500 devices, nearly $6M in marketing
Develop with Nokia Qt SDK, Web Runtime, or Java and Publish to Ovi Store 
http://p.sf.net/sfu/nokia-dev2dev
_______________________________________________
tmux-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/tmux-cvs

Reply via email to