diff options
author | Nicholas Marriott <nicm@cvs.openbsd.org> | 2017-04-21 17:22:21 +0000 |
---|---|---|
committer | Nicholas Marriott <nicm@cvs.openbsd.org> | 2017-04-21 17:22:21 +0000 |
commit | 04877e5652edac75843874e33ac4423f07d88526 (patch) | |
tree | 2fd57bd181d5442ca1c862ae464768f762e53101 /usr.bin | |
parent | 5eeb5092b99bc138e408beb55615786e806da3ae (diff) |
Add cmd_find_from_winlink_pane and use it in a couple of places, and
make functions that can't fail void.
Diffstat (limited to 'usr.bin')
-rw-r--r-- | usr.bin/tmux/cmd-find.c | 24 | ||||
-rw-r--r-- | usr.bin/tmux/cmd-split-window.c | 9 | ||||
-rw-r--r-- | usr.bin/tmux/server-client.c | 8 | ||||
-rw-r--r-- | usr.bin/tmux/tmux.h | 8 |
4 files changed, 28 insertions, 21 deletions
diff --git a/usr.bin/tmux/cmd-find.c b/usr.bin/tmux/cmd-find.c index dafab9ac574..c7331c627ca 100644 --- a/usr.bin/tmux/cmd-find.c +++ b/usr.bin/tmux/cmd-find.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cmd-find.c,v 1.46 2017/04/21 14:09:44 nicm Exp $ */ +/* $OpenBSD: cmd-find.c,v 1.47 2017/04/21 17:22:20 nicm Exp $ */ /* * Copyright (c) 2015 Nicholas Marriott <nicholas.marriott@gmail.com> @@ -879,7 +879,7 @@ cmd_find_log_state(const char *prefix, struct cmd_find_state *fs) } /* Find state from a session. */ -int +void cmd_find_from_session(struct cmd_find_state *fs, struct session *s) { cmd_find_clear_state(fs, NULL, 0); @@ -890,11 +890,10 @@ cmd_find_from_session(struct cmd_find_state *fs, struct session *s) fs->wp = fs->w->active; cmd_find_log_state(__func__, fs); - return (0); } /* Find state from a winlink. */ -int +void cmd_find_from_winlink(struct cmd_find_state *fs, struct winlink *wl) { cmd_find_clear_state(fs, NULL, 0); @@ -905,7 +904,6 @@ cmd_find_from_winlink(struct cmd_find_state *fs, struct winlink *wl) fs->wp = wl->window->active; cmd_find_log_state(__func__, fs); - return (0); } /* Find state from a session and window. */ @@ -942,6 +940,22 @@ cmd_find_from_window(struct cmd_find_state *fs, struct window *w) return (0); } +/* Find state from a winlink and pane. */ +void +cmd_find_from_winlink_pane(struct cmd_find_state *fs, struct winlink *wl, + struct window_pane *wp) +{ + cmd_find_clear_state(fs, NULL, 0); + + fs->s = wl->session; + fs->wl = wl; + fs->idx = fs->wl->idx; + fs->w = fs->wl->window; + fs->wp = wp; + + cmd_find_log_state(__func__, fs); +} + /* Find state from a pane. */ int cmd_find_from_pane(struct cmd_find_state *fs, struct window_pane *wp) diff --git a/usr.bin/tmux/cmd-split-window.c b/usr.bin/tmux/cmd-split-window.c index fcf915742cc..94bd1b676e7 100644 --- a/usr.bin/tmux/cmd-split-window.c +++ b/usr.bin/tmux/cmd-split-window.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cmd-split-window.c,v 1.80 2017/03/09 17:02:38 nicm Exp $ */ +/* $OpenBSD: cmd-split-window.c,v 1.81 2017/04/21 17:22:20 nicm Exp $ */ /* * Copyright (c) 2009 Nicholas Marriott <nicholas.marriott@gmail.com> @@ -172,12 +172,7 @@ cmd_split_window_exec(struct cmd *self, struct cmdq_item *item) if (to_free != NULL) free((void *)to_free); - cmd_find_clear_state(&fs, NULL, 0); - fs.s = s; - fs.wl = wl; - fs.w = w; - fs.wp = new_wp; - cmd_find_log_state(__func__, &fs); + cmd_find_from_winlink_pane(&fs, wl, new_wp); hooks_insert(s->hooks, item, &fs, "after-split-window"); return (CMD_RETURN_NORMAL); diff --git a/usr.bin/tmux/server-client.c b/usr.bin/tmux/server-client.c index 5912ae57b00..08b4b11f4b0 100644 --- a/usr.bin/tmux/server-client.c +++ b/usr.bin/tmux/server-client.c @@ -1,4 +1,4 @@ -/* $OpenBSD: server-client.c,v 1.223 2017/04/21 16:04:18 nicm Exp $ */ +/* $OpenBSD: server-client.c,v 1.224 2017/04/21 17:22:20 nicm Exp $ */ /* * Copyright (c) 2009 Nicholas Marriott <nicholas.marriott@gmail.com> @@ -946,11 +946,7 @@ retry: /* Find default state if the pane is known. */ if (KEYC_IS_MOUSE(key) && m->valid && wp != NULL) { - cmd_find_clear_state(&fs, NULL, 0); - fs.s = s; - fs.wl = fs.s->curw; - fs.w = fs.wl->window; - fs.wp = wp; + cmd_find_from_winlink_pane(&fs, s->curw, wp); cmd_find_log_state(__func__, &fs); if (!cmd_find_valid_state(&fs)) diff --git a/usr.bin/tmux/tmux.h b/usr.bin/tmux/tmux.h index 655070d9bcf..10ddb3f24d9 100644 --- a/usr.bin/tmux/tmux.h +++ b/usr.bin/tmux/tmux.h @@ -1,4 +1,4 @@ -/* $OpenBSD: tmux.h,v 1.747 2017/04/21 16:04:18 nicm Exp $ */ +/* $OpenBSD: tmux.h,v 1.748 2017/04/21 17:22:20 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com> @@ -1744,15 +1744,17 @@ int cmd_find_valid_state(struct cmd_find_state *); void cmd_find_copy_state(struct cmd_find_state *, struct cmd_find_state *); void cmd_find_log_state(const char *, struct cmd_find_state *); -int cmd_find_from_session(struct cmd_find_state *, +void cmd_find_from_session(struct cmd_find_state *, struct session *); -int cmd_find_from_winlink(struct cmd_find_state *, +void cmd_find_from_winlink(struct cmd_find_state *, struct winlink *); int cmd_find_from_session_window(struct cmd_find_state *, struct session *, struct window *); int cmd_find_from_window(struct cmd_find_state *, struct window *); int cmd_find_from_pane(struct cmd_find_state *, struct window_pane *); +void cmd_find_from_winlink_pane(struct cmd_find_state *, + struct winlink *, struct window_pane *); /* cmd.c */ int cmd_pack_argv(int, char **, char *, size_t); |