version 1.14, 2012/01/21 06:13:16 |
version 1.15, 2012/07/11 07:10:15 |
|
|
* Switch client to a different session. |
* Switch client to a different session. |
*/ |
*/ |
|
|
void cmd_switch_client_key_binding(struct cmd *, int); |
void cmd_switch_client_key_binding(struct cmd *, int); |
int cmd_switch_client_exec(struct cmd *, struct cmd_ctx *); |
enum cmd_retval cmd_switch_client_exec(struct cmd *, struct cmd_ctx *); |
|
|
const struct cmd_entry cmd_switch_client_entry = { |
const struct cmd_entry cmd_switch_client_entry = { |
"switch-client", "switchc", |
"switch-client", "switchc", |
|
|
} |
} |
} |
} |
|
|
int |
enum cmd_retval |
cmd_switch_client_exec(struct cmd *self, struct cmd_ctx *ctx) |
cmd_switch_client_exec(struct cmd *self, struct cmd_ctx *ctx) |
{ |
{ |
struct args *args = self->args; |
struct args *args = self->args; |
|
|
struct session *s; |
struct session *s; |
|
|
if ((c = cmd_find_client(ctx, args_get(args, 'c'))) == NULL) |
if ((c = cmd_find_client(ctx, args_get(args, 'c'))) == NULL) |
return (-1); |
return (CMD_RETURN_ERROR); |
|
|
if (args_has(args, 'r')) { |
if (args_has(args, 'r')) { |
if (c->flags & CLIENT_READONLY) { |
if (c->flags & CLIENT_READONLY) { |
|
|
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) { |
ctx->error(ctx, "can't find next session"); |
ctx->error(ctx, "can't find next session"); |
return (-1); |
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) { |
ctx->error(ctx, "can't find previous session"); |
ctx->error(ctx, "can't find previous session"); |
return (-1); |
return (CMD_RETURN_ERROR); |
} |
} |
} else if (args_has(args, 'l')) { |
} else if (args_has(args, 'l')) { |
if (c->last_session != NULL && session_alive(c->last_session)) |
if (c->last_session != NULL && session_alive(c->last_session)) |
s = c->last_session; |
s = c->last_session; |
if (s == NULL) { |
if (s == NULL) { |
ctx->error(ctx, "can't find last session"); |
ctx->error(ctx, "can't find last session"); |
return (-1); |
return (CMD_RETURN_ERROR); |
} |
} |
} else |
} else |
s = cmd_find_session(ctx, args_get(args, 't'), 0); |
s = cmd_find_session(ctx, args_get(args, 't'), 0); |
if (s == NULL) |
if (s == NULL) |
return (-1); |
return (CMD_RETURN_ERROR); |
|
|
if (c->session != NULL) |
if (c->session != NULL) |
c->last_session = c->session; |
c->last_session = c->session; |
|
|
server_redraw_client(c); |
server_redraw_client(c); |
s->curw->flags &= ~WINLINK_ALERTFLAGS; |
s->curw->flags &= ~WINLINK_ALERTFLAGS; |
|
|
return (0); |
return (CMD_RETURN_NORMAL); |
} |
} |