diff options
author | Nicholas Marriott <nicm@cvs.openbsd.org> | 2012-12-24 12:34:33 +0000 |
---|---|---|
committer | Nicholas Marriott <nicm@cvs.openbsd.org> | 2012-12-24 12:34:33 +0000 |
commit | 8114c656726aa7d6c8b0182a06a59f377f0c2a2a (patch) | |
tree | e04ffb1cd44c28d55a3e661a31f4f5f903e6d2e5 /usr.bin/tmux/cmd-select-window.c | |
parent | a97098c9a8e97f9b9d33743618a8fb7bec24877e (diff) |
Add -T option to select-window to toggle to last window if already
current, from Raghavendra D Prabhu.
Diffstat (limited to 'usr.bin/tmux/cmd-select-window.c')
-rw-r--r-- | usr.bin/tmux/cmd-select-window.c | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/usr.bin/tmux/cmd-select-window.c b/usr.bin/tmux/cmd-select-window.c index 9f06cdedeaa..5b85a179293 100644 --- a/usr.bin/tmux/cmd-select-window.c +++ b/usr.bin/tmux/cmd-select-window.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cmd-select-window.c,v 1.8 2012/07/11 07:10:15 nicm Exp $ */ +/* $OpenBSD: cmd-select-window.c,v 1.9 2012/12/24 12:34:32 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -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(); |