diff options
author | Nicholas Marriott <nicm@openbsd.org> | 2010-07-14 18:37:49 +0000 |
---|---|---|
committer | Nicholas Marriott <nicm@openbsd.org> | 2010-07-14 18:37:49 +0000 |
commit | 43355fa75c067e4dda8e4f1aa5370bb3bddc3bf4 (patch) | |
tree | 37c3892d9ec362c7736898eb58beba209a02acff /window.c | |
parent | b9c873cdaa3256f95a007d501fcab8375930bd94 (diff) | |
download | rtmux-43355fa75c067e4dda8e4f1aa5370bb3bddc3bf4.tar.gz rtmux-43355fa75c067e4dda8e4f1aa5370bb3bddc3bf4.tar.bz2 rtmux-43355fa75c067e4dda8e4f1aa5370bb3bddc3bf4.zip |
Make pane/window wrapping more logical (so with 10 windows, +10 from
window 5 stays in the same place), and tidy the code. From Tiago Cunha.
Diffstat (limited to 'window.c')
-rw-r--r-- | window.c | 31 |
1 files changed, 27 insertions, 4 deletions
@@ -173,22 +173,22 @@ winlink_previous(struct winlink *wl) } struct winlink * -winlink_next_by_number(struct winlink *wl, int n) +winlink_next_by_number(struct winlink *wl, struct session *s, int n) { for (; n > 0; n--) { if ((wl = RB_NEXT(winlinks, wwl, wl)) == NULL) - break; + wl = RB_MIN(winlinks, &s->windows); } return (wl); } struct winlink * -winlink_previous_by_number(struct winlink *wl, int n) +winlink_previous_by_number(struct winlink *wl, struct session *s, int n) { for (; n > 0; n--) { if ((wl = RB_PREV(winlinks, wwl, wl)) == NULL) - break; + wl = RB_MAX(winlinks, &s->windows); } return (wl); @@ -391,6 +391,29 @@ window_pane_at_index(struct window *w, u_int idx) return (NULL); } +struct window_pane * +window_pane_next_by_number(struct window *w, struct window_pane *wp, u_int n) +{ + for (; n > 0; n--) { + if ((wp = TAILQ_NEXT(wp, entry)) == NULL) + wp = TAILQ_FIRST(&w->panes); + } + + return (wp); +} + +struct window_pane * +window_pane_previous_by_number(struct window *w, struct window_pane *wp, + u_int n) +{ + for (; n > 0; n--) { + if ((wp = TAILQ_PREV(wp, window_panes, entry)) == NULL) + wp = TAILQ_LAST(&w->panes, window_panes); + } + + return (wp); +} + u_int window_pane_index(struct window *w, struct window_pane *wp) { |