version 1.26, 2020/04/13 10:59:58 |
version 1.27, 2020/07/04 14:24:02 |
|
|
{ |
{ |
struct args *args = cmd_get_args(self); |
struct args *args = cmd_get_args(self); |
struct cmd_find_state *target = cmdq_get_target(item); |
struct cmd_find_state *target = cmdq_get_target(item); |
struct winlink *wl = target->wl, *wl2, *wl3; |
struct winlink *wl = target->wl, *loop; |
struct window *w = wl->window; |
struct window *w = wl->window; |
struct session *s = target->s; |
struct session *s = target->s; |
|
u_int found; |
|
|
if (cmd_get_entry(self) == &cmd_unlink_window_entry) { |
if (cmd_get_entry(self) == &cmd_unlink_window_entry) { |
if (!args_has(args, 'k') && !session_is_linked(s, w)) { |
if (!args_has(args, 'k') && !session_is_linked(s, w)) { |
|
|
return (CMD_RETURN_ERROR); |
return (CMD_RETURN_ERROR); |
} |
} |
server_unlink_window(s, wl); |
server_unlink_window(s, wl); |
} else { |
recalculate_sizes(); |
if (args_has(args, 'a')) { |
return (CMD_RETURN_NORMAL); |
RB_FOREACH_SAFE(wl2, winlinks, &s->windows, wl3) { |
} |
if (wl != wl2) |
|
server_kill_window(wl2->window); |
if (args_has(args, 'a')) { |
|
if (RB_PREV(winlinks, &s->windows, wl) == NULL && |
|
RB_NEXT(winlinks, &s->windows, wl) == NULL) |
|
return (CMD_RETURN_NORMAL); |
|
|
|
/* Kill all windows except the current one. */ |
|
do { |
|
found = 0; |
|
RB_FOREACH(loop, winlinks, &s->windows) { |
|
if (loop->window != wl->window) { |
|
server_kill_window(loop->window, 0); |
|
found++; |
|
break; |
|
} |
} |
} |
} else |
} while (found != 0); |
server_kill_window(wl->window); |
|
|
/* |
|
* If the current window appears in the session more than once, |
|
* kill it as well. |
|
*/ |
|
found = 0; |
|
RB_FOREACH(loop, winlinks, &s->windows) { |
|
if (loop->window == wl->window) |
|
found++; |
|
} |
|
if (found > 1) |
|
server_kill_window(wl->window, 0); |
|
|
|
server_renumber_all(); |
|
return (CMD_RETURN_NORMAL); |
} |
} |
|
|
recalculate_sizes(); |
server_kill_window(wl->window, 1); |
return (CMD_RETURN_NORMAL); |
return (CMD_RETURN_NORMAL); |
} |
} |