aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornicm <nicm>2015-12-13 17:55:14 +0000
committernicm <nicm>2015-12-13 17:55:14 +0000
commit9f5aca62a94f46be9c7637ebd3269d012c9346a5 (patch)
tree90be91151129e3d3089020f9c988af0d614b2dc5
parent9b7697db62dc1c809955e8f8fea2868c230cc503 (diff)
downloadrtmux-9f5aca62a94f46be9c7637ebd3269d012c9346a5.tar.gz
rtmux-9f5aca62a94f46be9c7637ebd3269d012c9346a5.tar.bz2
rtmux-9f5aca62a94f46be9c7637ebd3269d012c9346a5.zip
Use struct cmd_find_state directly and remove cmd_state_flag, also
change so that winlink is set even if an index is too.
-rw-r--r--cmd-find.c20
-rw-r--r--cmd-new-window.c7
-rw-r--r--tmux.h61
3 files changed, 40 insertions, 48 deletions
diff --git a/cmd-find.c b/cmd-find.c
index 139ec069..582f1759 100644
--- a/cmd-find.c
+++ b/cmd-find.c
@@ -467,11 +467,10 @@ cmd_find_get_window(struct cmd_find_state *fs, const char *window)
/* Otherwise try as a session itself. */
if (cmd_find_get_session(fs, window) == 0) {
- if (~fs->flags & CMD_FIND_WINDOW_INDEX) {
- fs->wl = fs->s->curw;
- fs->w = fs->wl->window;
+ fs->wl = fs->s->curw;
+ fs->w = fs->wl->window;
+ if (~fs->flags & CMD_FIND_WINDOW_INDEX)
fs->idx = fs->wl->idx;
- }
return (0);
}
@@ -493,6 +492,13 @@ cmd_find_get_window_with_session(struct cmd_find_state *fs, const char *window)
log_debug("%s: %s", __func__, window);
exact = (fs->flags & CMD_FIND_EXACT_WINDOW);
+ /*
+ * Start with the current window as the default. So if only an index is
+ * found, the window will be the current.
+ */
+ fs->wl = fs->s->curw;
+ fs->w = fs->wl->window;
+
/* Check for window ids starting with @. */
if (*window == '@') {
fs->w = window_find_by_id_str(window);
@@ -976,8 +982,7 @@ cmd_find_target(struct cmd_find_state *fs, struct cmd_q *cmdq,
/* This will fill in winlink and window. */
if (cmd_find_get_window_with_session(fs, window) != 0)
goto no_window;
- if (~flags & CMD_FIND_WINDOW_INDEX)
- fs->wp = fs->wl->window->active;
+ fs->wp = fs->wl->window->active;
goto found;
}
@@ -1017,8 +1022,7 @@ cmd_find_target(struct cmd_find_state *fs, struct cmd_q *cmdq,
/* This will fill in session, winlink and window. */
if (cmd_find_get_window(fs, window) != 0)
goto no_window;
- if (~flags & CMD_FIND_WINDOW_INDEX)
- fs->wp = fs->wl->window->active;
+ fs->wp = fs->wl->window->active;
goto found;
}
diff --git a/cmd-new-window.c b/cmd-new-window.c
index 8154bdfb..18d2952b 100644
--- a/cmd-new-window.c
+++ b/cmd-new-window.c
@@ -39,12 +39,7 @@ const struct cmd_entry cmd_new_window_entry = {
"ac:dF:kn:Pt:", 0, -1,
"[-adkP] [-c start-directory] [-F format] [-n window-name] "
CMD_TARGET_WINDOW_USAGE " [command]",
- /*
- * Using PREP_CANFAIL here ensures that the wl is filled in
- * regardless; making PREP_INDEX the thing we want -t to be used for
- * in the specific case.
- */
- CMD_INDEX_T|CMD_CANFAIL,
+ CMD_INDEX_T,
cmd_new_window_exec
};
diff --git a/tmux.h b/tmux.h
index e6fb521e..5724b536 100644
--- a/tmux.h
+++ b/tmux.h
@@ -1293,18 +1293,37 @@ struct args {
char **argv;
};
-/* Context for a command about to be executed. */
-struct cmd_state_flag {
- struct session *s;
- struct winlink *wl;
- struct window_pane *wp;
- int idx;
+/* Command find structures. */
+enum cmd_find_type {
+ CMD_FIND_PANE,
+ CMD_FIND_WINDOW,
+ CMD_FIND_SESSION,
+};
+struct cmd_find_state {
+ struct cmd_q *cmdq;
+ int flags;
+ struct cmd_find_state *current;
+ struct session *s;
+ struct winlink *wl;
+ struct window *w;
+ struct window_pane *wp;
+ int idx;
};
+
+/* Command find flags. */
+#define CMD_FIND_PREFER_UNATTACHED 0x1
+#define CMD_FIND_QUIET 0x2
+#define CMD_FIND_WINDOW_INDEX 0x4
+#define CMD_FIND_DEFAULT_MARKED 0x8
+#define CMD_FIND_EXACT_SESSION 0x10
+#define CMD_FIND_EXACT_WINDOW 0x20
+
+/* Context for command being executed. */
struct cmd_state {
struct client *c;
- struct cmd_state_flag tflag;
- struct cmd_state_flag sflag;
+ struct cmd_find_state tflag;
+ struct cmd_find_state sflag;
};
/* Command and list of commands. */
@@ -1407,32 +1426,6 @@ struct cmd_entry {
#define CMD_ALL_S (CMD_SESSION_S|CMD_WINDOW_S|CMD_PANE_S|CMD_INDEX_S| \
CMD_PANE_MARKED_S|CMD_WINDOW_MARKED_S)
-/* Command find structures. */
-enum cmd_find_type {
- CMD_FIND_PANE,
- CMD_FIND_WINDOW,
- CMD_FIND_SESSION,
-};
-struct cmd_find_state {
- struct cmd_q *cmdq;
- int flags;
- struct cmd_find_state *current;
-
- struct session *s;
- struct winlink *wl;
- struct window *w;
- struct window_pane *wp;
- int idx;
-};
-
-/* Command fine flags. */
-#define CMD_FIND_PREFER_UNATTACHED 0x1
-#define CMD_FIND_QUIET 0x2
-#define CMD_FIND_WINDOW_INDEX 0x4
-#define CMD_FIND_DEFAULT_MARKED 0x8
-#define CMD_FIND_EXACT_SESSION 0x10
-#define CMD_FIND_EXACT_WINDOW 0x20
-
/* Key binding and key table. */
struct key_binding {
key_code key;