From 386849edc1d7d322d6a48d334f83298ff7cb5501 Mon Sep 17 00:00:00 2001 From: Nicholas Marriott Date: Mon, 21 Jun 2010 01:46:36 +0000 Subject: Extend the -t:+ and -t:- window targets for next and previous window to accept an offset such as -t:+2. From Tiago Cunha. --- window.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'window.c') diff --git a/window.c b/window.c index 36ad4adb..320da2a2 100644 --- a/window.c +++ b/window.c @@ -172,6 +172,28 @@ winlink_previous(struct winlink *wl) return (RB_PREV(winlinks, wwl, wl)); } +struct winlink * +winlink_next_by_number(struct winlink *wl, int n) +{ + for (; n > 0; n--) { + if ((wl = RB_NEXT(winlinks, wwl, wl)) == NULL) + break; + } + + return (wl); +} + +struct winlink * +winlink_previous_by_number(struct winlink *wl, int n) +{ + for (; n > 0; n--) { + if ((wl = RB_PREV(winlinks, wwl, wl)) == NULL) + break; + } + + return (wl); +} + void winlink_stack_push(struct winlink_stack *stack, struct winlink *wl) { -- cgit