summaryrefslogtreecommitdiffstats
path: root/cmd-select-window.c
diff options
context:
space:
mode:
authorNicholas Marriott <nicm@openbsd.org>2012-12-24 12:34:32 +0000
committerNicholas Marriott <nicm@openbsd.org>2012-12-24 12:34:32 +0000
commit3e6d45acf67e37db3614a581ab5aaa3b9509a430 (patch)
treefafd0c806244f95f2b8953df8cc6002ee2affc88 /cmd-select-window.c
parenta2c8af97e9b1f2ade071de31d97eccc3219949d9 (diff)
Add -T option to select-window to toggle to last window if already
current, from Raghavendra D Prabhu.
Diffstat (limited to 'cmd-select-window.c')
-rw-r--r--cmd-select-window.c16
1 files changed, 13 insertions, 3 deletions
diff --git a/cmd-select-window.c b/cmd-select-window.c
index eaa3e889..70d60bed 100644
--- a/cmd-select-window.c
+++ b/cmd-select-window.c
@@ -31,8 +31,8 @@ enum cmd_retval cmd_select_window_exec(struct cmd *, struct cmd_ctx *);
const struct cmd_entry cmd_select_window_entry = {
"select-window", "selectw",
- "lnpt:", 0, 0,
- "[-lnp] " CMD_TARGET_WINDOW_USAGE,
+ "lnpTt:", 0, 0,
+ "[-lnpT] " CMD_TARGET_WINDOW_USAGE,
0,
cmd_select_window_key_binding,
NULL,
@@ -130,7 +130,17 @@ cmd_select_window_exec(struct cmd *self, struct cmd_ctx *ctx)
if (wl == NULL)
return (CMD_RETURN_ERROR);
- if (session_select(s, wl->idx) == 0)
+ /*
+ * If -T and select-window is invoked on same window as
+ * current, switch to previous window.
+ */
+ if (args_has(self->args, 'T') && wl == s->curw) {
+ if (session_last(s) != 0) {
+ ctx->error(ctx, "no last window");
+ return (-1);
+ }
+ server_redraw_session(s);
+ } else if (session_select(s, wl->idx) == 0)
server_redraw_session(s);
}
recalculate_sizes();