version 1.18, 2013/10/10 12:00:24 |
version 1.19, 2014/01/09 14:28:14 |
|
|
enum cmd_retval |
enum cmd_retval |
cmd_switch_client_exec(struct cmd *self, struct cmd_q *cmdq) |
cmd_switch_client_exec(struct cmd *self, struct cmd_q *cmdq) |
{ |
{ |
struct args *args = self->args; |
struct args *args = self->args; |
struct client *c; |
struct client *c; |
struct session *s; |
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) |
if ((c = cmd_find_client(cmdq, args_get(args, 'c'), 0)) == NULL) |
return (CMD_RETURN_ERROR); |
return (CMD_RETURN_ERROR); |
|
|
} |
} |
} |
} |
|
|
s = NULL; |
tflag = args_get(args, 't'); |
if (args_has(args, 'n')) { |
if (args_has(args, 'n')) { |
if ((s = session_next_session(c->session)) == NULL) { |
if ((s = session_next_session(c->session)) == NULL) { |
cmdq_error(cmdq, "can't find next session"); |
cmdq_error(cmdq, "can't find next session"); |
|
|
cmdq_error(cmdq, "can't find last session"); |
cmdq_error(cmdq, "can't find last session"); |
return (CMD_RETURN_ERROR); |
return (CMD_RETURN_ERROR); |
} |
} |
} else |
} else { |
s = cmd_find_session(cmdq, args_get(args, 't'), 0); |
if (tflag == NULL) { |
if (s == NULL) |
if ((s = cmd_find_session(cmdq, tflag, 1)) == NULL) |
return (CMD_RETURN_ERROR); |
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) |
if (c->session != NULL) |
c->last_session = c->session; |
c->last_session = c->session; |