version 1.43, 2016/10/10 21:51:39 |
version 1.44, 2016/10/16 19:04:05 |
|
|
* Switch client to a different session. |
* Switch client to a different session. |
*/ |
*/ |
|
|
static enum cmd_retval cmd_switch_client_exec(struct cmd *, struct cmd_q *); |
static enum cmd_retval cmd_switch_client_exec(struct cmd *, |
|
struct cmdq_item *); |
|
|
const struct cmd_entry cmd_switch_client_entry = { |
const struct cmd_entry cmd_switch_client_entry = { |
.name = "switch-client", |
.name = "switch-client", |
|
|
}; |
}; |
|
|
static enum cmd_retval |
static enum cmd_retval |
cmd_switch_client_exec(struct cmd *self, struct cmd_q *cmdq) |
cmd_switch_client_exec(struct cmd *self, struct cmdq_item *item) |
{ |
{ |
struct args *args = self->args; |
struct args *args = self->args; |
struct cmd_state *state = &cmdq->state; |
struct cmd_state *state = &item->state; |
struct client *c = state->c; |
struct client *c = state->c; |
struct session *s = cmdq->state.tflag.s; |
struct session *s = item->state.tflag.s; |
struct window_pane *wp; |
struct window_pane *wp; |
const char *tablename, *update; |
const char *tablename, *update; |
struct key_table *table; |
struct key_table *table; |
|
|
if (tablename != NULL) { |
if (tablename != NULL) { |
table = key_bindings_get_table(tablename, 0); |
table = key_bindings_get_table(tablename, 0); |
if (table == NULL) { |
if (table == NULL) { |
cmdq_error(cmdq, "table %s doesn't exist", tablename); |
cmdq_error(item, "table %s doesn't exist", tablename); |
return (CMD_RETURN_ERROR); |
return (CMD_RETURN_ERROR); |
} |
} |
table->references++; |
table->references++; |
|
|
|
|
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(item, "can't find next session"); |
return (CMD_RETURN_ERROR); |
return (CMD_RETURN_ERROR); |
} |
} |
} else if (args_has(args, 'p')) { |
} else if (args_has(args, 'p')) { |
if ((s = session_previous_session(c->session)) == NULL) { |
if ((s = session_previous_session(c->session)) == NULL) { |
cmdq_error(cmdq, "can't find previous session"); |
cmdq_error(item, "can't find previous session"); |
return (CMD_RETURN_ERROR); |
return (CMD_RETURN_ERROR); |
} |
} |
} else if (args_has(args, 'l')) { |
} else if (args_has(args, 'l')) { |
|
|
else |
else |
s = NULL; |
s = NULL; |
if (s == NULL) { |
if (s == NULL) { |
cmdq_error(cmdq, "can't find last session"); |
cmdq_error(item, "can't find last session"); |
return (CMD_RETURN_ERROR); |
return (CMD_RETURN_ERROR); |
} |
} |
} else { |
} else { |
if (cmdq->client == NULL) |
if (item->client == NULL) |
return (CMD_RETURN_NORMAL); |
return (CMD_RETURN_NORMAL); |
if (state->tflag.wl != NULL) { |
if (state->tflag.wl != NULL) { |
wp = state->tflag.wp; |
wp = state->tflag.wp; |