select-layout command and some key bindings.

This commit is contained in:
Nicholas Marriott
2009-05-16 11:48:47 +00:00
parent 03af7c99b5
commit 1001902143
7 changed files with 138 additions and 7 deletions

View File

@ -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)
{