diff options
author | Nicholas Marriott <nicm@openbsd.org> | 2012-04-01 13:18:38 +0000 |
---|---|---|
committer | Nicholas Marriott <nicm@openbsd.org> | 2012-04-01 13:18:38 +0000 |
commit | 85f5485cb5e46d6d574b7a1b8c1357c85b528e2b (patch) | |
tree | 302c5d6ffd1bc655d2ab33c808df7d0cc1e2acf2 /cmd-select-layout.c | |
parent | b831f8635409883e2ad2b6feedf05821f8f2ea84 (diff) | |
download | rtmux-85f5485cb5e46d6d574b7a1b8c1357c85b528e2b.tar.gz rtmux-85f5485cb5e46d6d574b7a1b8c1357c85b528e2b.tar.bz2 rtmux-85f5485cb5e46d6d574b7a1b8c1357c85b528e2b.zip |
Add a layout history which can be stepped through with select-layout -u
and -U commands (bound to 'u' and 'U' by default).
Diffstat (limited to 'cmd-select-layout.c')
-rw-r--r-- | cmd-select-layout.c | 47 |
1 files changed, 36 insertions, 11 deletions
diff --git a/cmd-select-layout.c b/cmd-select-layout.c index e1f20a4e..d2352fb4 100644 --- a/cmd-select-layout.c +++ b/cmd-select-layout.c @@ -29,8 +29,8 @@ int cmd_select_layout_exec(struct cmd *, struct cmd_ctx *); const struct cmd_entry cmd_select_layout_entry = { "select-layout", "selectl", - "npt:", 0, 1, - "[-np] " CMD_TARGET_WINDOW_USAGE " [layout-name]", + "nprut:", 0, 1, + "[-npUu] " CMD_TARGET_WINDOW_USAGE " [layout-name]", 0, cmd_select_layout_key_binding, NULL, @@ -76,6 +76,14 @@ cmd_select_layout_key_binding(struct cmd *self, int key) case '5' | KEYC_ESCAPE: self->args = args_create(1, "tiled"); break; + case 'u': + self->args = args_create(0); + args_set(self->args, 'u', NULL); + break; + case 'U': + self->args = args_create(0); + args_set(self->args, 'U', NULL); + break; default: self->args = args_create(0); break; @@ -87,11 +95,13 @@ cmd_select_layout_exec(struct cmd *self, struct cmd_ctx *ctx) { struct args *args = self->args; struct winlink *wl; + struct window *w; const char *layoutname; int next, previous, layout; if ((wl = cmd_find_window(ctx, args_get(args, 't'), NULL)) == NULL) return (-1); + w = wl->window; next = self->entry == &cmd_next_layout_entry; if (args_has(self->args, 'n')) @@ -100,6 +110,21 @@ cmd_select_layout_exec(struct cmd *self, struct cmd_ctx *ctx) if (args_has(self->args, 'p')) previous = 1; + layout_list_add(w); + if (args_has(self->args, 'U')) { + if ((layoutname = layout_list_redo(w)) == NULL) { + ctx->error(ctx, "no more layout history"); + return (-1); + } + goto set_layout; + } else if (args_has(self->args, 'u')) { + if ((layoutname = layout_list_undo(w)) == NULL) { + ctx->error(ctx, "no more layout history"); + return (-1); + } + goto set_layout; + } + if (next || previous) { if (next) layout = layout_set_next(wl->window); @@ -121,16 +146,16 @@ cmd_select_layout_exec(struct cmd *self, struct cmd_ctx *ctx) return (0); } - if (args->argc != 0) { - layoutname = args->argv[0]; - if (layout_parse(wl->window, layoutname) == -1) { - ctx->error(ctx, "can't set layout: %s", layoutname); - return (-1); - } - server_redraw_window(wl->window); - ctx->info(ctx, "arranging in: %s", layoutname); + if (args->argc == 0) return (0); - } + layoutname = args->argv[0]; +set_layout: + if (layout_parse(wl->window, layoutname) == -1) { + ctx->error(ctx, "can't set layout: %s", layoutname); + return (-1); + } + server_redraw_window(wl->window); + ctx->info(ctx, "arranging in: %s", layoutname); return (0); } |