diff options
author | Tiago Cunha <tcunha@gmx.com> | 2010-07-17 14:38:13 +0000 |
---|---|---|
committer | Tiago Cunha <tcunha@gmx.com> | 2010-07-17 14:38:13 +0000 |
commit | 11f81e8134c238c399539c4eec125e891256acd9 (patch) | |
tree | 3a3aa89f8c953572ac78fb12d07171225e510251 /window.c | |
parent | ad6a528f611bf793f0c3d4f832f34a1c778068e3 (diff) | |
download | rtmux-11f81e8134c238c399539c4eec125e891256acd9.tar.gz rtmux-11f81e8134c238c399539c4eec125e891256acd9.tar.bz2 rtmux-11f81e8134c238c399539c4eec125e891256acd9.zip |
Sync OpenBSD patchset 735:
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 | 33 |
1 files changed, 28 insertions, 5 deletions
@@ -1,4 +1,4 @@ -/* $Id: window.c,v 1.133 2010-06-22 23:29:05 tcunha Exp $ */ +/* $Id: window.c,v 1.134 2010-07-17 14:38:13 tcunha Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -171,22 +171,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); @@ -389,6 +389,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) { |