diff options
author | Thomas Adam <thomas@xteddy.org> | 2014-01-31 21:39:56 +0000 |
---|---|---|
committer | Thomas Adam <thomas@xteddy.org> | 2014-01-31 21:39:56 +0000 |
commit | d50e47fc4ab5cbbdbe6bbebdc2c36ce3aae6e987 (patch) | |
tree | 397f4999444c2eef367f884b815bec2a14697c3c /cmd-switch-client.c | |
parent | cbf9224c5f7bcf07352f6ea128c90c12cb0af22e (diff) | |
parent | 9f02feb9d089b1a4639afb52ab0e8212eeb55a7c (diff) | |
download | rtmux-d50e47fc4ab5cbbdbe6bbebdc2c36ce3aae6e987.tar.gz rtmux-d50e47fc4ab5cbbdbe6bbebdc2c36ce3aae6e987.tar.bz2 rtmux-d50e47fc4ab5cbbdbe6bbebdc2c36ce3aae6e987.zip |
Merge branch 'obsd-master'
Conflicts:
Makefile
cmd-server-info.c
cmd-start-server.c
Diffstat (limited to 'cmd-switch-client.c')
-rw-r--r-- | cmd-switch-client.c | 43 |
1 files changed, 35 insertions, 8 deletions
diff --git a/cmd-switch-client.c b/cmd-switch-client.c index d101c52b..3d97c5b7 100644 --- a/cmd-switch-client.c +++ b/cmd-switch-client.c @@ -59,9 +59,13 @@ cmd_switch_client_key_binding(struct cmd *self, int key) enum cmd_retval cmd_switch_client_exec(struct cmd *self, struct cmd_q *cmdq) { - struct args *args = self->args; - struct client *c; - struct session *s; + struct args *args = self->args; + struct client *c; + struct session *s; + struct winlink *wl = NULL; + struct window *w = NULL; + struct window_pane *wp = NULL; + const char *tflag; if ((c = cmd_find_client(cmdq, args_get(args, 'c'), 0)) == NULL) return (CMD_RETURN_ERROR); @@ -76,7 +80,7 @@ cmd_switch_client_exec(struct cmd *self, struct cmd_q *cmdq) } } - s = NULL; + tflag = args_get(args, 't'); if (args_has(args, 'n')) { if ((s = session_next_session(c->session)) == NULL) { cmdq_error(cmdq, "can't find next session"); @@ -94,10 +98,33 @@ cmd_switch_client_exec(struct cmd *self, struct cmd_q *cmdq) cmdq_error(cmdq, "can't find last session"); return (CMD_RETURN_ERROR); } - } else - s = cmd_find_session(cmdq, args_get(args, 't'), 0); - if (s == NULL) - return (CMD_RETURN_ERROR); + } else { + if (tflag == NULL) { + if ((s = cmd_find_session(cmdq, tflag, 1)) == NULL) + return (CMD_RETURN_ERROR); + } else if (tflag[strcspn(tflag, ":.")] != '\0') { + if ((wl = cmd_find_pane(cmdq, tflag, &s, &wp)) == NULL) + return (CMD_RETURN_ERROR); + } else { + if ((s = cmd_find_session(cmdq, tflag, 1)) == NULL) + return (CMD_RETURN_ERROR); + w = cmd_lookup_windowid(tflag); + if (w == NULL && + (wp = cmd_lookup_paneid(tflag)) != NULL) + w = wp->window; + if (w != NULL) + wl = winlink_find_by_window(&s->windows, w); + } + + if (cmdq->client == NULL) + return (CMD_RETURN_NORMAL); + + if (wl != NULL) { + if (wp != NULL) + window_set_active_pane(wp->window, wp); + session_set_current(s, wl); + } + } if (c->session != NULL) c->last_session = c->session; |