summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNicholas Marriott <nicholas.marriott@gmail.com>2009-04-30 21:17:06 +0000
committerNicholas Marriott <nicholas.marriott@gmail.com>2009-04-30 21:17:06 +0000
commit044e6f766017cb065fdd4f8db492e1b29cd8b87d (patch)
treecf7694b60ada53e488cd34e110857060dc533384
parenta6f2d8233569b4dcb6e26935b33b20f796ce958c (diff)
previous-layout command.
-rw-r--r--CHANGES3
-rw-r--r--GNUmakefile19
-rw-r--r--Makefile15
-rw-r--r--TODO1
-rw-r--r--cmd-next-layout.c3
-rw-r--r--cmd-previous-layout.c55
-rw-r--r--cmd.c3
-rw-r--r--layout.c17
-rw-r--r--tmux.h4
9 files changed, 96 insertions, 24 deletions
diff --git a/CHANGES b/CHANGES
index 78ce700f..0cd7b84f 100644
--- a/CHANGES
+++ b/CHANGES
@@ -1,5 +1,6 @@
30 April 2009
+* previous-layout command.
* Display the layout name in window lists.
* Merge resize-pane-up and resize-pane-down into resize-pane with -U and -D
flags.
@@ -1235,7 +1236,7 @@
(including mutt, emacs). No status bar yet and no key remapping or other
customisation.
-$Id: CHANGES,v 1.280 2009-04-30 20:54:52 nicm Exp $
+$Id: CHANGES,v 1.281 2009-04-30 21:17:06 nicm Exp $
LocalWords: showw utf UTF fulvio ciriaco joshe OSC APC gettime abc DEF OA clr
LocalWords: rivo nurges lscm Erdely eol smysession mysession ek dstname RB ms
diff --git a/GNUmakefile b/GNUmakefile
index ceb09989..58e39226 100644
--- a/GNUmakefile
+++ b/GNUmakefile
@@ -1,4 +1,4 @@
-# $Id: GNUmakefile,v 1.90 2009-04-30 06:01:23 nicm Exp $
+# $Id: GNUmakefile,v 1.91 2009-04-30 21:17:06 nicm Exp $
.PHONY: clean
@@ -16,8 +16,8 @@ SRCS= tmux.c server.c server-msg.c server-fn.c buffer.c buffer-poll.c status.c \
screen.c screen-write.c screen-redraw.c \
grid.c grid-view.c \
window.c session.c log.c client.c client-msg.c client-fn.c cfg.c \
- key-string.c key-bindings.c resize.c arg.c mode-key.c \
- layout.c cmd.c cmd-generic.c cmd-string.c cmd-list.c \
+ layout.c key-string.c key-bindings.c resize.c arg.c mode-key.c \
+ cmd.c cmd-generic.c cmd-string.c cmd-list.c \
cmd-detach-client.c cmd-list-sessions.c cmd-new-window.c cmd-bind-key.c \
cmd-unbind-key.c cmd-previous-window.c cmd-last-window.c cmd-list-keys.c \
cmd-set-option.c cmd-rename-window.c cmd-select-window.c \
@@ -31,14 +31,13 @@ SRCS= tmux.c server.c server-msg.c server-fn.c buffer.c buffer-poll.c status.c \
cmd-show-window-options.c cmd-command-prompt.c cmd-set-buffer.c \
cmd-show-buffer.c cmd-list-buffers.c cmd-delete-buffer.c \
cmd-list-commands.c cmd-move-window.c cmd-select-prompt.c \
- cmd-respawn-window.c cmd-source-file.c cmd-server-info.c \
- cmd-clock-mode.c cmd-lock-server.c cmd-set-password.c \
- cmd-save-buffer.c cmd-select-pane.c cmd-split-window.c \
- cmd-resize-pane.c cmd-kill-pane.c \
- cmd-up-pane.c cmd-down-pane.c cmd-choose-window.c cmd-choose-session.c \
+ cmd-respawn-window.c cmd-source-file.c cmd-server-info.c cmd-down-pane.c \
+ cmd-clock-mode.c cmd-lock-server.c cmd-set-password.c cmd-up-pane.c \
+ cmd-save-buffer.c cmd-select-pane.c cmd-split-window.c cmd-kill-pane.c \
+ cmd-resize-pane.c cmd-choose-window.c cmd-choose-session.c \
cmd-suspend-client.c cmd-find-window.c cmd-load-buffer.c \
- cmd-copy-buffer.c cmd-break-pane.c cmd-swap-pane.c cmd-next-layout.c \
- cmd-rotate-window.c cmd-confirm-before.c \
+ cmd-copy-buffer.c cmd-break-pane.c cmd-swap-pane.c cmd-rotate-window.c \
+ cmd-confirm-before.c cmd-next-layout.c cmd-previous-layout.c \
window-clock.c window-scroll.c window-more.c window-copy.c \
window-choose.c \
options.c options-cmd.c paste.c colour.c utf8.c clock.c \
diff --git a/Makefile b/Makefile
index ec2b385d..c4e71042 100644
--- a/Makefile
+++ b/Makefile
@@ -1,4 +1,4 @@
-# $Id: Makefile,v 1.128 2009-04-30 06:01:23 nicm Exp $
+# $Id: Makefile,v 1.129 2009-04-30 21:17:06 nicm Exp $
.SUFFIXES: .c .o .y .h
.PHONY: clean update-index.html upload-index.html
@@ -34,14 +34,13 @@ SRCS= tmux.c server.c server-msg.c server-fn.c buffer.c buffer-poll.c status.c \
cmd-show-window-options.c cmd-command-prompt.c cmd-set-buffer.c \
cmd-show-buffer.c cmd-list-buffers.c cmd-delete-buffer.c \
cmd-list-commands.c cmd-move-window.c cmd-select-prompt.c \
- cmd-respawn-window.c cmd-source-file.c cmd-server-info.c \
- cmd-clock-mode.c cmd-lock-server.c cmd-set-password.c \
- cmd-save-buffer.c cmd-select-pane.c cmd-split-window.c \
- cmd-resize-pane.c cmd-kill-pane.c \
- cmd-up-pane.c cmd-down-pane.c cmd-choose-window.c cmd-choose-session.c \
+ cmd-respawn-window.c cmd-source-file.c cmd-server-info.c cmd-down-pane.c \
+ cmd-clock-mode.c cmd-lock-server.c cmd-set-password.c cmd-up-pane.c \
+ cmd-save-buffer.c cmd-select-pane.c cmd-split-window.c cmd-kill-pane.c \
+ cmd-resize-pane.c cmd-choose-window.c cmd-choose-session.c \
cmd-suspend-client.c cmd-find-window.c cmd-load-buffer.c \
- cmd-copy-buffer.c cmd-break-pane.c cmd-swap-pane.c cmd-next-layout.c \
- cmd-rotate-window.c cmd-confirm-before.c \
+ cmd-copy-buffer.c cmd-break-pane.c cmd-swap-pane.c cmd-rotate-window.c \
+ cmd-confirm-before.c cmd-next-layout.c cmd-previous-layout.c \
window-clock.c window-scroll.c window-more.c window-copy.c \
window-choose.c \
options.c options-cmd.c paste.c colour.c utf8.c clock.c \
diff --git a/TODO b/TODO
index 30a38f63..db96eb7a 100644
--- a/TODO
+++ b/TODO
@@ -78,7 +78,6 @@
- attach should have a flag to create session if it doesn't exist
- layout/split stuff:
horiz split command, and similar resizing commands as for vert split
- previous-layout command
select-layout command
make manual layout a bit less of a hack and make it handle a grid
should the layout be a window option???
diff --git a/cmd-next-layout.c b/cmd-next-layout.c
index f5f611f6..98017978 100644
--- a/cmd-next-layout.c
+++ b/cmd-next-layout.c
@@ -1,4 +1,4 @@
-/* $Id: cmd-next-layout.c,v 1.1 2009-04-01 18:21:26 nicm Exp $ */
+/* $Id: cmd-next-layout.c,v 1.2 2009-04-30 21:17:06 nicm Exp $ */
/*
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -49,6 +49,7 @@ cmd_next_layout_exec(struct cmd *self, struct cmd_ctx *ctx)
return (-1);
layout_next(wl->window);
+ ctx->info(ctx, "layout now: %s", layout_name(wl->window));
return (0);
}
diff --git a/cmd-previous-layout.c b/cmd-previous-layout.c
new file mode 100644
index 00000000..d66a6cf4
--- /dev/null
+++ b/cmd-previous-layout.c
@@ -0,0 +1,55 @@
+/* $Id: cmd-previous-layout.c,v 1.1 2009-04-30 21:17:06 nicm Exp $ */
+
+/*
+ * Copyright (c) 2009 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"
+
+/*
+ * Switch window to previous layout.
+ */
+
+int cmd_previous_layout_exec(struct cmd *, struct cmd_ctx *);
+
+const struct cmd_entry cmd_previous_layout_entry = {
+ "previous-layout", "prevl",
+ CMD_TARGET_WINDOW_USAGE,
+ 0,
+ cmd_target_init,
+ cmd_target_parse,
+ cmd_previous_layout_exec,
+ cmd_target_send,
+ cmd_target_recv,
+ cmd_target_free,
+ cmd_target_print
+};
+
+int
+cmd_previous_layout_exec(struct cmd *self, struct cmd_ctx *ctx)
+{
+ struct cmd_target_data *data = self->data;
+ struct winlink *wl;
+
+ if ((wl = cmd_find_window(ctx, data->target, NULL)) == NULL)
+ return (-1);
+
+ layout_previous(wl->window);
+ ctx->info(ctx, "layout now: %s", layout_name(wl->window));
+
+ return (0);
+}
diff --git a/cmd.c b/cmd.c
index 34d499ba..789fc396 100644
--- a/cmd.c
+++ b/cmd.c
@@ -1,4 +1,4 @@
-/* $Id: cmd.c,v 1.91 2009-04-30 06:01:24 nicm Exp $ */
+/* $Id: cmd.c,v 1.92 2009-04-30 21:17:06 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -61,6 +61,7 @@ const struct cmd_entry *cmd_table[] = {
&cmd_next_layout_entry,
&cmd_next_window_entry,
&cmd_paste_buffer_entry,
+ &cmd_previous_layout_entry,
&cmd_previous_window_entry,
&cmd_refresh_client_entry,
&cmd_rename_session_entry,
diff --git a/layout.c b/layout.c
index ff5485eb..d10ccd2d 100644
--- a/layout.c
+++ b/layout.c
@@ -1,4 +1,4 @@
-/* $Id: layout.c,v 1.4 2009-04-30 16:27:29 nicm Exp $ */
+/* $Id: layout.c,v 1.5 2009-04-30 21:17:06 nicm Exp $ */
/*
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -62,6 +62,21 @@ layout_next(struct window *w)
}
void
+layout_previous(struct window *w)
+{
+ if (w->layout == 0)
+ w->layout = nitems(layouts) - 1;
+ else
+ w->layout--;
+ if (w->layout == 0) {
+ /* XXX Special-case manual. */
+ window_fit_panes(w);
+ window_update_panes(w);
+ }
+ layout_refresh(w, 0);
+}
+
+void
layout_refresh(struct window *w, unused int active_changed)
{
layouts[w->layout].fn(w, active_changed);
diff --git a/tmux.h b/tmux.h
index fd6ac814..211550cc 100644
--- a/tmux.h
+++ b/tmux.h
@@ -1,4 +1,4 @@
-/* $Id: tmux.h,v 1.308 2009-04-30 20:54:53 nicm Exp $ */
+/* $Id: tmux.h,v 1.309 2009-04-30 21:17:06 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -1216,6 +1216,7 @@ extern const struct cmd_entry cmd_new_window_entry;
extern const struct cmd_entry cmd_next_layout_entry;
extern const struct cmd_entry cmd_next_window_entry;
extern const struct cmd_entry cmd_paste_buffer_entry;
+extern const struct cmd_entry cmd_previous_layout_entry;
extern const struct cmd_entry cmd_previous_window_entry;
extern const struct cmd_entry cmd_refresh_client_entry;
extern const struct cmd_entry cmd_rename_session_entry;
@@ -1546,6 +1547,7 @@ void window_pane_mouse(struct window_pane *,
const char * layout_name(struct window *);
void layout_refresh(struct window *, int);
void layout_next(struct window *);
+void layout_previous(struct window *);
/* window-clock.c */
extern const struct window_mode window_clock_mode;