diff options
author | Nicholas Marriott <nicm@cvs.openbsd.org> | 2010-06-21 01:46:37 +0000 |
---|---|---|
committer | Nicholas Marriott <nicm@cvs.openbsd.org> | 2010-06-21 01:46:37 +0000 |
commit | eca92101cb7e08d7427eee989b3c1b75a481d077 (patch) | |
tree | e124aae4282869c4b807275b90a988176f7bb4a2 /usr.bin/tmux/window.c | |
parent | f2c6767bd66943273e2e2e2aed0648d412f50e13 (diff) |
Extend the -t:+ and -t:- window targets for next and previous window to
accept an offset such as -t:+2. From Tiago Cunha.
Diffstat (limited to 'usr.bin/tmux/window.c')
-rw-r--r-- | usr.bin/tmux/window.c | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/usr.bin/tmux/window.c b/usr.bin/tmux/window.c index b0ae5694919..48e4e645ab5 100644 --- a/usr.bin/tmux/window.c +++ b/usr.bin/tmux/window.c @@ -1,4 +1,4 @@ -/* $OpenBSD: window.c,v 1.51 2010/05/23 19:42:19 nicm Exp $ */ +/* $OpenBSD: window.c,v 1.52 2010/06/21 01:46:36 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -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) { |