summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--usr.bin/tmux/Makefile4
-rw-r--r--usr.bin/tmux/cmd-last-pane.c58
-rw-r--r--usr.bin/tmux/cmd.c3
-rw-r--r--usr.bin/tmux/key-bindings.c3
-rw-r--r--usr.bin/tmux/tmux.19
-rw-r--r--usr.bin/tmux/tmux.h4
-rw-r--r--usr.bin/tmux/window.c16
7 files changed, 85 insertions, 12 deletions
diff --git a/usr.bin/tmux/Makefile b/usr.bin/tmux/Makefile
index eb6eb9de669..8290b6b8246 100644
--- a/usr.bin/tmux/Makefile
+++ b/usr.bin/tmux/Makefile
@@ -1,4 +1,4 @@
-# $OpenBSD: Makefile,v 1.45 2010/09/11 16:19:22 nicm Exp $
+# $OpenBSD: Makefile,v 1.46 2010/10/23 13:04:34 nicm Exp $
PROG= tmux
SRCS= attributes.c cfg.c client.c clock.c \
@@ -9,7 +9,7 @@ SRCS= attributes.c cfg.c client.c clock.c \
cmd-choose-buffer.c cmd-delete-buffer.c cmd-detach-client.c \
cmd-find-window.c cmd-generic.c cmd-has-session.c cmd-kill-pane.c \
cmd-kill-server.c cmd-kill-session.c cmd-kill-window.c \
- cmd-last-window.c cmd-link-window.c cmd-list-buffers.c \
+ cmd-last-pane.c cmd-last-window.c cmd-link-window.c cmd-list-buffers.c \
cmd-list-clients.c cmd-list-commands.c cmd-list-keys.c \
cmd-list-sessions.c cmd-list-windows.c cmd-list-panes.c \
cmd-list.c cmd-load-buffer.c cmd-join-pane.c \
diff --git a/usr.bin/tmux/cmd-last-pane.c b/usr.bin/tmux/cmd-last-pane.c
new file mode 100644
index 00000000000..b3888129bf0
--- /dev/null
+++ b/usr.bin/tmux/cmd-last-pane.c
@@ -0,0 +1,58 @@
+/* $OpenBSD: cmd-last-pane.c,v 1.1 2010/10/23 13:04:34 nicm Exp $ */
+
+/*
+ * Copyright (c) 2010 Nicholas Marriott <nicm@users.sourceforge.net>
+ *
+ * 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);
+}
diff --git a/usr.bin/tmux/cmd.c b/usr.bin/tmux/cmd.c
index 929bb55b5c6..280dd9cffd6 100644
--- a/usr.bin/tmux/cmd.c
+++ b/usr.bin/tmux/cmd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: cmd.c,v 1.44 2010/10/16 07:57:42 nicm Exp $ */
+/* $OpenBSD: cmd.c,v 1.45 2010/10/23 13:04:34 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -54,6 +54,7 @@ const struct cmd_entry *cmd_table[] = {
&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,
diff --git a/usr.bin/tmux/key-bindings.c b/usr.bin/tmux/key-bindings.c
index c4047da7cb0..65ba02d9ab3 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.24 2010/09/08 22:02:28 nicm Exp $ */
+/* $OpenBSD: key-bindings.c,v 1.25 2010/10/23 13:04:34 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -124,6 +124,7 @@ key_bindings_init(void)
{ '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 },
diff --git a/usr.bin/tmux/tmux.1 b/usr.bin/tmux/tmux.1
index c435e4df464..c4b2ad71363 100644
--- a/usr.bin/tmux/tmux.1
+++ b/usr.bin/tmux/tmux.1
@@ -1,4 +1,4 @@
-.\" $OpenBSD: tmux.1,v 1.186 2010/10/14 00:30:03 nicm Exp $
+.\" $OpenBSD: tmux.1,v 1.187 2010/10/23 13:04:34 nicm Exp $
.\"
.\" Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
.\"
@@ -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 @@ Select windows 0 to 9.
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 @@ option kills all but the pane given with
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.
diff --git a/usr.bin/tmux/tmux.h b/usr.bin/tmux/tmux.h
index 4b53ed0e435..35bd23b8b18 100644
--- a/usr.bin/tmux/tmux.h
+++ b/usr.bin/tmux/tmux.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: tmux.h,v 1.243 2010/10/18 20:00:03 nicm Exp $ */
+/* $OpenBSD: tmux.h,v 1.244 2010/10/23 13:04:34 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -832,6 +832,7 @@ struct window {
struct event name_timer;
struct window_pane *active;
+ struct window_pane *last;
struct window_panes panes;
int lastlayout;
@@ -1507,6 +1508,7 @@ extern const struct cmd_entry cmd_kill_pane_entry;
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;
diff --git a/usr.bin/tmux/window.c b/usr.bin/tmux/window.c
index 6aeee96294a..9d02a5a8c9e 100644
--- a/usr.bin/tmux/window.c
+++ b/usr.bin/tmux/window.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: window.c,v 1.57 2010/10/23 12:51:51 nicm Exp $ */
+/* $OpenBSD: window.c,v 1.58 2010/10/23 13:04:34 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -325,6 +325,7 @@ window_resize(struct window *w, u_int sx, u_int sy)
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);
@@ -369,10 +370,15 @@ void
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);