Use struct cmd_find_state directly and remove cmd_state_flag, also

change so that winlink is set even if an index is too.
This commit is contained in:
nicm 2015-12-13 17:55:14 +00:00
parent 9b7697db62
commit 9f5aca62a9
3 changed files with 41 additions and 49 deletions

View File

@ -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;
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,7 +982,6 @@ 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;
goto found;
}
@ -1017,7 +1022,6 @@ 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;
goto found;
}

View File

@ -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
};

55
tmux.h
View File

@ -1293,18 +1293,37 @@ struct args {
char **argv;
};
/* Context for a command about to be executed. */
struct cmd_state_flag {
/* 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;