mirror of
https://github.com/tmux/tmux.git
synced 2024-10-31 14:48:56 +00:00
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:
parent
9b7697db62
commit
9f5aca62a9
20
cmd-find.c
20
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. */
|
/* Otherwise try as a session itself. */
|
||||||
if (cmd_find_get_session(fs, window) == 0) {
|
if (cmd_find_get_session(fs, window) == 0) {
|
||||||
if (~fs->flags & CMD_FIND_WINDOW_INDEX) {
|
fs->wl = fs->s->curw;
|
||||||
fs->wl = fs->s->curw;
|
fs->w = fs->wl->window;
|
||||||
fs->w = fs->wl->window;
|
if (~fs->flags & CMD_FIND_WINDOW_INDEX)
|
||||||
fs->idx = fs->wl->idx;
|
fs->idx = fs->wl->idx;
|
||||||
}
|
|
||||||
return (0);
|
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);
|
log_debug("%s: %s", __func__, window);
|
||||||
exact = (fs->flags & CMD_FIND_EXACT_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 @. */
|
/* Check for window ids starting with @. */
|
||||||
if (*window == '@') {
|
if (*window == '@') {
|
||||||
fs->w = window_find_by_id_str(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. */
|
/* This will fill in winlink and window. */
|
||||||
if (cmd_find_get_window_with_session(fs, window) != 0)
|
if (cmd_find_get_window_with_session(fs, window) != 0)
|
||||||
goto no_window;
|
goto no_window;
|
||||||
if (~flags & CMD_FIND_WINDOW_INDEX)
|
fs->wp = fs->wl->window->active;
|
||||||
fs->wp = fs->wl->window->active;
|
|
||||||
goto found;
|
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. */
|
/* This will fill in session, winlink and window. */
|
||||||
if (cmd_find_get_window(fs, window) != 0)
|
if (cmd_find_get_window(fs, window) != 0)
|
||||||
goto no_window;
|
goto no_window;
|
||||||
if (~flags & CMD_FIND_WINDOW_INDEX)
|
fs->wp = fs->wl->window->active;
|
||||||
fs->wp = fs->wl->window->active;
|
|
||||||
goto found;
|
goto found;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -39,12 +39,7 @@ const struct cmd_entry cmd_new_window_entry = {
|
|||||||
"ac:dF:kn:Pt:", 0, -1,
|
"ac:dF:kn:Pt:", 0, -1,
|
||||||
"[-adkP] [-c start-directory] [-F format] [-n window-name] "
|
"[-adkP] [-c start-directory] [-F format] [-n window-name] "
|
||||||
CMD_TARGET_WINDOW_USAGE " [command]",
|
CMD_TARGET_WINDOW_USAGE " [command]",
|
||||||
/*
|
CMD_INDEX_T,
|
||||||
* 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_new_window_exec
|
cmd_new_window_exec
|
||||||
};
|
};
|
||||||
|
|
||||||
|
63
tmux.h
63
tmux.h
@ -1293,18 +1293,37 @@ struct args {
|
|||||||
char **argv;
|
char **argv;
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Context for a command about to be executed. */
|
/* Command find structures. */
|
||||||
struct cmd_state_flag {
|
enum cmd_find_type {
|
||||||
struct session *s;
|
CMD_FIND_PANE,
|
||||||
struct winlink *wl;
|
CMD_FIND_WINDOW,
|
||||||
struct window_pane *wp;
|
CMD_FIND_SESSION,
|
||||||
int idx;
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
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 cmd_state {
|
||||||
struct client *c;
|
struct client *c;
|
||||||
struct cmd_state_flag tflag;
|
struct cmd_find_state tflag;
|
||||||
struct cmd_state_flag sflag;
|
struct cmd_find_state sflag;
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Command and list of commands. */
|
/* 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| \
|
#define CMD_ALL_S (CMD_SESSION_S|CMD_WINDOW_S|CMD_PANE_S|CMD_INDEX_S| \
|
||||||
CMD_PANE_MARKED_S|CMD_WINDOW_MARKED_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. */
|
/* Key binding and key table. */
|
||||||
struct key_binding {
|
struct key_binding {
|
||||||
key_code key;
|
key_code key;
|
||||||
|
Loading…
Reference in New Issue
Block a user