=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/tmux/window.c,v retrieving revision 1.52 retrieving revision 1.53 diff -u -r1.52 -r1.53 --- src/usr.bin/tmux/window.c 2010/06/21 01:46:36 1.52 +++ src/usr.bin/tmux/window.c 2010/07/14 18:37:49 1.53 @@ -1,4 +1,4 @@ -/* $OpenBSD: window.c,v 1.52 2010/06/21 01:46:36 nicm Exp $ */ +/* $OpenBSD: window.c,v 1.53 2010/07/14 18:37:49 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott @@ -173,22 +173,22 @@ } 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 @@ n++; } 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