aboutsummaryrefslogtreecommitdiff
path: root/cmd-find.c
diff options
context:
space:
mode:
authorThomas Adam <thomas@xteddy.org>2016-01-19 18:01:15 +0000
committerThomas Adam <thomas@xteddy.org>2016-01-19 18:01:15 +0000
commitdc42c35f1f04d3bd431c52dde0906965c6db2d6c (patch)
tree6b9e46226bd4ef64ab3e1c5c8bd65bdbc3cce3b9 /cmd-find.c
parent5d21faa99c9a005208e88be72ef2c1e02cf6d128 (diff)
parentb5b5221c13ded5b141fa35f60c707c9c403b83a6 (diff)
downloadrtmux-dc42c35f1f04d3bd431c52dde0906965c6db2d6c.tar.gz
rtmux-dc42c35f1f04d3bd431c52dde0906965c6db2d6c.tar.bz2
rtmux-dc42c35f1f04d3bd431c52dde0906965c6db2d6c.zip
Merge branch 'obsd-master'
Diffstat (limited to 'cmd-find.c')
-rw-r--r--cmd-find.c31
1 files changed, 18 insertions, 13 deletions
diff --git a/cmd-find.c b/cmd-find.c
index ff795427..f6094ced 100644
--- a/cmd-find.c
+++ b/cmd-find.c
@@ -1,7 +1,7 @@
/* $OpenBSD$ */
/*
- * Copyright (c) 2015 Nicholas Marriott <nicm@users.sourceforge.net>
+ * Copyright (c) 2015 Nicholas Marriott <nicholas.marriott@gmail.com>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
@@ -922,15 +922,27 @@ cmd_find_from_pane(struct cmd_find_state *fs, struct window_pane *wp)
return (0);
}
+/* Find current state. */
+int
+cmd_find_current(struct cmd_find_state *fs, struct cmd_q *cmdq, int flags)
+{
+ cmd_find_clear_state(fs, cmdq, flags);
+ if (cmd_find_current_session(fs) != 0) {
+ if (~flags & CMD_FIND_QUIET)
+ cmdq_error(cmdq, "no current session");
+ return (-1);
+ }
+ return (0);
+}
+
/*
* Split target into pieces and resolve for the given type. Fills in the given
* state. Returns 0 on success or -1 on error.
*/
int
-cmd_find_target(struct cmd_find_state *fs, struct cmd_q *cmdq,
- const char *target, enum cmd_find_type type, int flags)
+cmd_find_target(struct cmd_find_state *fs, struct cmd_find_state *current,
+ struct cmd_q *cmdq, const char *target, enum cmd_find_type type, int flags)
{
- struct cmd_find_state current;
struct mouse_event *m;
char *colon, *period, *copy = NULL;
const char *session, *window, *pane;
@@ -950,15 +962,8 @@ cmd_find_target(struct cmd_find_state *fs, struct cmd_q *cmdq,
fs->current = &marked_pane;
else if (cmd_find_valid_state(&cmdq->current))
fs->current = &cmdq->current;
- else {
- cmd_find_clear_state(&current, cmdq, flags);
- if (cmd_find_current_session(&current) != 0) {
- if (~flags & CMD_FIND_QUIET)
- cmdq_error(cmdq, "no current session");
- goto error;
- }
- fs->current = &current;
- }
+ else
+ fs->current = current;
/* An empty or NULL target is the current. */
if (target == NULL || *target == '\0')