diff options
author | Tiago Cunha <tcunha@gmx.com> | 2012-04-10 09:52:45 +0000 |
---|---|---|
committer | Tiago Cunha <tcunha@gmx.com> | 2012-04-10 09:52:45 +0000 |
commit | f99de22808b8e3c2b8aabf70b945f768ae892dda (patch) | |
tree | 07e7ba338344d6dbecb6d0af381f47a8dc6672df /cmd-select-layout.c | |
parent | b58d7f78a1c7c6755321e97046307db1d295c2d6 (diff) | |
download | rtmux-f99de22808b8e3c2b8aabf70b945f768ae892dda.tar.gz rtmux-f99de22808b8e3c2b8aabf70b945f768ae892dda.tar.bz2 rtmux-f99de22808b8e3c2b8aabf70b945f768ae892dda.zip |
Sync OpenBSD patchset 1084:
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 0ae63b8a..658f3309 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); } |