From 8d3b726396d3f5124d31a792a5f3358357f2e105 Mon Sep 17 00:00:00 2001 From: Tiago Cunha Date: Tue, 22 Jun 2010 23:29:05 +0000 Subject: Sync OpenBSD patchset 725: 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 | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) (limited to 'window.c') diff --git a/window.c b/window.c index 9e6a3500..d02178c1 100644 --- a/window.c +++ b/window.c @@ -1,4 +1,4 @@ -/* $Id: window.c,v 1.132 2010-05-22 21:56:04 micahcowan Exp $ */ +/* $Id: window.c,v 1.133 2010-06-22 23:29:05 tcunha Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott @@ -170,6 +170,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