diff options
author | 2013-03-22 16:00:26 +0000 | |
---|---|---|
committer | 2013-03-22 16:00:26 +0000 | |
commit | 9627e48c3ccfa9e75133bef7a9aff465640cc004 (patch) | |
tree | f08736f5ef65a86e5aaa69d6dac6d1fe8bfe1e59 /usr.bin/tmux/session.c | |
parent | Add -C and -J to capture pane to escape control sequences and to join (diff) | |
download | wireguard-openbsd-9627e48c3ccfa9e75133bef7a9aff465640cc004.tar.xz wireguard-openbsd-9627e48c3ccfa9e75133bef7a9aff465640cc004.zip |
Add session_set_current helper function, extracted from a diff from
Aaron Jensen.
Diffstat (limited to 'usr.bin/tmux/session.c')
-rw-r--r-- | usr.bin/tmux/session.c | 40 |
1 files changed, 16 insertions, 24 deletions
diff --git a/usr.bin/tmux/session.c b/usr.bin/tmux/session.c index 1511ebf4169..c3bd592bb4a 100644 --- a/usr.bin/tmux/session.c +++ b/usr.bin/tmux/session.c @@ -1,4 +1,4 @@ -/* $OpenBSD: session.c,v 1.36 2012/07/10 11:53:01 nicm Exp $ */ +/* $OpenBSD: session.c,v 1.37 2013/03/22 16:00:26 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -346,13 +346,7 @@ session_next(struct session *s, int alert) if (alert && ((wl = session_next_alert(wl)) == NULL)) return (-1); } - if (wl == s->curw) - return (1); - winlink_stack_remove(&s->lastw, wl); - winlink_stack_push(&s->lastw, s->curw); - s->curw = wl; - winlink_clear_flags(wl); - return (0); + return (session_set_current(s, wl)); } struct winlink * @@ -383,13 +377,7 @@ session_previous(struct session *s, int alert) if (alert && (wl = session_previous_alert(wl)) == NULL) return (-1); } - if (wl == s->curw) - return (1); - winlink_stack_remove(&s->lastw, wl); - winlink_stack_push(&s->lastw, s->curw); - s->curw = wl; - winlink_clear_flags(wl); - return (0); + return (session_set_current(s, wl)); } /* Move session to specific window. */ @@ -399,15 +387,7 @@ session_select(struct session *s, int idx) struct winlink *wl; wl = winlink_find_by_index(&s->windows, idx); - if (wl == NULL) - return (-1); - if (wl == s->curw) - return (1); - winlink_stack_remove(&s->lastw, wl); - winlink_stack_push(&s->lastw, s->curw); - s->curw = wl; - winlink_clear_flags(wl); - return (0); + return (session_set_current(s, wl)); } /* Move session to last used window. */ @@ -422,6 +402,18 @@ session_last(struct session *s) if (wl == s->curw) return (1); + return (session_set_current(s, wl)); +} + +/* Set current winlink to wl .*/ +int +session_set_current(struct session *s, struct winlink *wl) +{ + if (wl == NULL) + return (-1); + if (wl == s->curw) + return (1); + winlink_stack_remove(&s->lastw, wl); winlink_stack_push(&s->lastw, s->curw); s->curw = wl; |