version 1.6, 2009/11/13 19:53:29 |
version 1.7, 2011/01/04 00:42:47 |
|
|
* Move to previous window. |
* Move to previous window. |
*/ |
*/ |
|
|
void cmd_previous_window_init(struct cmd *, int); |
void cmd_previous_window_key_binding(struct cmd *, int); |
int cmd_previous_window_exec(struct cmd *, struct cmd_ctx *); |
int cmd_previous_window_exec(struct cmd *, struct cmd_ctx *); |
|
|
const struct cmd_entry cmd_previous_window_entry = { |
const struct cmd_entry cmd_previous_window_entry = { |
"previous-window", "prev", |
"previous-window", "prev", |
|
"at:", 0, 0, |
"[-a] " CMD_TARGET_SESSION_USAGE, |
"[-a] " CMD_TARGET_SESSION_USAGE, |
0, "a", |
0, |
cmd_previous_window_init, |
cmd_previous_window_key_binding, |
cmd_target_parse, |
NULL, |
cmd_previous_window_exec, |
cmd_previous_window_exec |
cmd_target_free, |
|
cmd_target_print |
|
}; |
}; |
|
|
void |
void |
cmd_previous_window_init(struct cmd *self, int key) |
cmd_previous_window_key_binding(struct cmd *self, int key) |
{ |
{ |
struct cmd_target_data *data; |
self->args = args_create(0); |
|
|
cmd_target_init(self, key); |
|
data = self->data; |
|
|
|
if (key == ('p' | KEYC_ESCAPE)) |
if (key == ('p' | KEYC_ESCAPE)) |
cmd_set_flag(&data->chflags, 'a'); |
args_set(self->args, 'a', NULL); |
} |
} |
|
|
int |
int |
cmd_previous_window_exec(struct cmd *self, struct cmd_ctx *ctx) |
cmd_previous_window_exec(struct cmd *self, struct cmd_ctx *ctx) |
{ |
{ |
struct cmd_target_data *data = self->data; |
struct args *args = self->args; |
struct session *s; |
struct session *s; |
int activity; |
int activity; |
|
|
if ((s = cmd_find_session(ctx, data->target)) == NULL) |
if ((s = cmd_find_session(ctx, args_get(args, 't'))) == NULL) |
return (-1); |
return (-1); |
|
|
activity = 0; |
activity = 0; |
if (cmd_check_flag(data->chflags, 'a')) |
if (args_has(self->args, 'a')) |
activity = 1; |
activity = 1; |
|
|
if (session_previous(s, activity) == 0) |
if (session_previous(s, activity) == 0) |