diff options
Diffstat (limited to 'layout.c')
-rw-r--r-- | layout.c | 37 |
1 files changed, 36 insertions, 1 deletions
@@ -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) { |