version 1.7, 2011/04/05 19:37:01 |
version 1.8, 2012/07/11 07:10:15 |
|
|
* Select window by index. |
* Select window by index. |
*/ |
*/ |
|
|
void cmd_select_window_key_binding(struct cmd *, int); |
void cmd_select_window_key_binding(struct cmd *, int); |
int cmd_select_window_exec(struct cmd *, struct cmd_ctx *); |
enum cmd_retval cmd_select_window_exec(struct cmd *, struct cmd_ctx *); |
|
|
const struct cmd_entry cmd_select_window_entry = { |
const struct cmd_entry cmd_select_window_entry = { |
"select-window", "selectw", |
"select-window", "selectw", |
|
|
args_set(self->args, 'a', NULL); |
args_set(self->args, 'a', NULL); |
} |
} |
|
|
int |
enum cmd_retval |
cmd_select_window_exec(struct cmd *self, struct cmd_ctx *ctx) |
cmd_select_window_exec(struct cmd *self, struct cmd_ctx *ctx) |
{ |
{ |
struct args *args = self->args; |
struct args *args = self->args; |
|
|
if (next || previous || last) { |
if (next || previous || last) { |
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); |
|
|
activity = args_has(self->args, 'a'); |
activity = args_has(self->args, 'a'); |
if (next) { |
if (next) { |
if (session_next(s, activity) != 0) { |
if (session_next(s, activity) != 0) { |
ctx->error(ctx, "no next window"); |
ctx->error(ctx, "no next window"); |
return (-1); |
return (CMD_RETURN_ERROR); |
} |
} |
} else if (previous) { |
} else if (previous) { |
if (session_previous(s, activity) != 0) { |
if (session_previous(s, activity) != 0) { |
ctx->error(ctx, "no previous window"); |
ctx->error(ctx, "no previous window"); |
return (-1); |
return (CMD_RETURN_ERROR); |
} |
} |
} else { |
} else { |
if (session_last(s) != 0) { |
if (session_last(s) != 0) { |
ctx->error(ctx, "no last window"); |
ctx->error(ctx, "no last window"); |
return (-1); |
return (CMD_RETURN_ERROR); |
} |
} |
} |
} |
|
|
|
|
} else { |
} else { |
wl = cmd_find_window(ctx, args_get(args, 't'), &s); |
wl = cmd_find_window(ctx, args_get(args, 't'), &s); |
if (wl == NULL) |
if (wl == NULL) |
return (-1); |
return (CMD_RETURN_ERROR); |
|
|
if (session_select(s, wl->idx) == 0) |
if (session_select(s, wl->idx) == 0) |
server_redraw_session(s); |
server_redraw_session(s); |
} |
} |
recalculate_sizes(); |
recalculate_sizes(); |
|
|
return (0); |
return (CMD_RETURN_NORMAL); |
} |
} |