aboutsummaryrefslogtreecommitdiff
path: root/layout.c
diff options
context:
space:
mode:
authorNicholas Marriott <nicholas.marriott@gmail.com>2009-05-16 11:48:47 +0000
committerNicholas Marriott <nicholas.marriott@gmail.com>2009-05-16 11:48:47 +0000
commit100190214314cbcbdcf5cf4bb462e218a460b88e (patch)
treeb3db7d4b7db806803d5beef7b2a4b3f67c0bc782 /layout.c
parent03af7c99b58d65cd9ec0a95e02658c152e18f41e (diff)
downloadrtmux-100190214314cbcbdcf5cf4bb462e218a460b88e.tar.gz
rtmux-100190214314cbcbdcf5cf4bb462e218a460b88e.tar.bz2
rtmux-100190214314cbcbdcf5cf4bb462e218a460b88e.zip
select-layout command and some key bindings.
Diffstat (limited to 'layout.c')
-rw-r--r--layout.c37
1 files changed, 36 insertions, 1 deletions
diff --git a/layout.c b/layout.c
index 1b80628e..a97cecf9 100644
--- a/layout.c
+++ b/layout.c
@@ -1,4 +1,4 @@
-/* $Id: layout.c,v 1.6 2009-05-04 17:58:27 nicm Exp $ */
+/* $Id: layout.c,v 1.7 2009-05-16 11:48:47 nicm Exp $ */
/*
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -18,6 +18,8 @@
#include <sys/types.h>
+#include <string.h>
+
#include "tmux.h"
/*
@@ -48,6 +50,39 @@ layout_name(struct window *w)
return (layouts[w->layout].name);
}
+int
+layout_lookup(const char *name)
+{
+ u_int i;
+ int matched = -1;
+
+ for (i = 0; i < nitems(layouts); i++) {
+ if (strncmp(layouts[i].name, name, strlen(name)) == 0) {
+ if (matched != -1) /* ambiguous */
+ return (-1);
+ matched = i;
+ }
+ }
+
+ return (matched);
+}
+
+int
+layout_select(struct window *w, u_int layout)
+{
+ if (layout > nitems(layouts) - 1 || layout == w->layout)
+ return (-1);
+ w->layout = layout;
+
+ if (w->layout == 0) {
+ /* XXX Special-case manual. */
+ window_fit_panes(w);
+ window_update_panes(w);
+ }
+ layout_refresh(w, 0);
+ return (0);
+}
+
void
layout_next(struct window *w)
{