diff options
author | nicm <nicm> | 2015-06-17 16:50:28 +0000 |
---|---|---|
committer | nicm <nicm> | 2015-06-17 16:50:28 +0000 |
commit | 0ff335961eec019d776f19bd8c26cce7cde0effa (patch) | |
tree | c45e265253049e3e04755c09eac03006fa3f5f55 /window.c | |
parent | 021cdbe1c0111951a1f63b09b41c9e3db3793db5 (diff) | |
download | rtmux-0ff335961eec019d776f19bd8c26cce7cde0effa.tar.gz rtmux-0ff335961eec019d776f19bd8c26cce7cde0effa.tar.bz2 rtmux-0ff335961eec019d776f19bd8c26cce7cde0effa.zip |
Move the shuffle code from new-window -a into a function and add a -a
flag for move-window too. From Thomas Adam.
Diffstat (limited to 'window.c')
-rw-r--r-- | window.c | 25 |
1 files changed, 25 insertions, 0 deletions
@@ -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); +} |