mirror of
https://github.com/tmate-io/tmate.git
synced 2025-08-19 09:52:06 +02:00
Move the shuffle code from new-window -a into a function and add a -a
flag for move-window too. From Thomas Adam.
This commit is contained in:
25
window.c
25
window.c
@@ -1378,3 +1378,28 @@ winlink_clear_flags(struct winlink *wl)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
winlink_shuffle_up(struct session *s, struct winlink *wl)
|
||||
{
|
||||
int idx, last;
|
||||
|
||||
idx = wl->idx + 1;
|
||||
|
||||
/* Find the next free index. */
|
||||
for (last = idx; last < INT_MAX; last++) {
|
||||
if (winlink_find_by_index(&s->windows, last) == NULL)
|
||||
break;
|
||||
}
|
||||
if (last == INT_MAX)
|
||||
return (-1);
|
||||
|
||||
/* Move everything from last - 1 to idx up a bit. */
|
||||
for (; last > idx; last--) {
|
||||
wl = winlink_find_by_index(&s->windows, last - 1);
|
||||
server_link_window(s, wl, s, last, 0, 0, NULL);
|
||||
server_unlink_window(s, wl);
|
||||
}
|
||||
|
||||
return (idx);
|
||||
}
|
||||
|
Reference in New Issue
Block a user