version 1.23, 2019/04/26 11:38:51 |
version 1.24, 2020/04/13 08:26:27 |
|
|
static enum cmd_retval |
static enum cmd_retval |
cmd_select_window_exec(struct cmd *self, struct cmdq_item *item) |
cmd_select_window_exec(struct cmd *self, struct cmdq_item *item) |
{ |
{ |
|
struct args *args = cmd_get_args(self); |
struct cmd_find_state *current = &item->shared->current; |
struct cmd_find_state *current = &item->shared->current; |
struct winlink *wl = item->target.wl; |
struct winlink *wl = item->target.wl; |
struct session *s = item->target.s; |
struct session *s = item->target.s; |
int next, previous, last, activity; |
int next, previous, last, activity; |
|
|
next = self->entry == &cmd_next_window_entry; |
next = (cmd_get_entry(self) == &cmd_next_window_entry); |
if (args_has(self->args, 'n')) |
if (args_has(args, 'n')) |
next = 1; |
next = 1; |
previous = self->entry == &cmd_previous_window_entry; |
previous = (cmd_get_entry(self) == &cmd_previous_window_entry); |
if (args_has(self->args, 'p')) |
if (args_has(args, 'p')) |
previous = 1; |
previous = 1; |
last = self->entry == &cmd_last_window_entry; |
last = (cmd_get_entry(self) == &cmd_last_window_entry); |
if (args_has(self->args, 'l')) |
if (args_has(args, 'l')) |
last = 1; |
last = 1; |
|
|
if (next || previous || last) { |
if (next || previous || last) { |
activity = args_has(self->args, 'a'); |
activity = args_has(args, 'a'); |
if (next) { |
if (next) { |
if (session_next(s, activity) != 0) { |
if (session_next(s, activity) != 0) { |
cmdq_error(item, "no next window"); |
cmdq_error(item, "no next window"); |
|
|
* If -T and select-window is invoked on same window as |
* If -T and select-window is invoked on same window as |
* current, switch to previous window. |
* current, switch to previous window. |
*/ |
*/ |
if (args_has(self->args, 'T') && wl == s->curw) { |
if (args_has(args, 'T') && wl == s->curw) { |
if (session_last(s) != 0) { |
if (session_last(s) != 0) { |
cmdq_error(item, "no last window"); |
cmdq_error(item, "no last window"); |
return (-1); |
return (-1); |