aboutsummaryrefslogtreecommitdiff
path: root/tmux.h
diff options
context:
space:
mode:
authornicm <nicm>2015-12-13 14:32:38 +0000
committernicm <nicm>2015-12-13 14:32:38 +0000
commit4a4daf13031673870341c68b990e20c314140118 (patch)
tree2457218fe3b49af2401cb78cde064b2a7ff62916 /tmux.h
parent5ed17e84faed0a7655ec1eb3de291b60839dcb12 (diff)
downloadrtmux-4a4daf13031673870341c68b990e20c314140118.tar.gz
rtmux-4a4daf13031673870341c68b990e20c314140118.tar.bz2
rtmux-4a4daf13031673870341c68b990e20c314140118.zip
Instead of every command resolving the target (-t or -s) itself, prepare
the state (client, session, winlink, pane) for it it before entering the command. Each command provides some flags that tell the prepare step what it is expecting. This is a requirement for having hooks on commands (for example, if you hook "select-window -t1:2", the hook command should to operate on window 1:2 not whatever it thinks is the current window), and should allow some other target improvements. The old cmd_find_* functions remain for the moment but that layer will be dropped later. Joint work with Thomas Adam.
Diffstat (limited to 'tmux.h')
-rw-r--r--tmux.h42
1 files changed, 40 insertions, 2 deletions
diff --git a/tmux.h b/tmux.h
index e10fbcdf..5924470e 100644
--- a/tmux.h
+++ b/tmux.h
@@ -1293,6 +1293,20 @@ 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;
+
+};
+struct cmd_state {
+ struct client *c;
+ struct cmd_state_flag tflag;
+ struct cmd_state_flag sflag;
+};
+
/* Command and list of commands. */
struct cmd {
const struct cmd_entry *entry;
@@ -1343,6 +1357,8 @@ struct cmd_q {
struct cmd_q_item *item;
struct cmd *cmd;
+ struct cmd_state state;
+
time_t time;
u_int number;
@@ -1365,10 +1381,31 @@ struct cmd_entry {
#define CMD_STARTSERVER 0x1
#define CMD_READONLY 0x2
+#define CMD_SESSION_T 0x4
+#define CMD_SESSION_S 0x8
+#define CMD_WINDOW_T 0x10
+#define CMD_WINDOW_S 0x20
+#define CMD_PANE_T 0x40
+#define CMD_PANE_S 0x80
+#define CMD_CLIENT_T 0x100
+#define CMD_CLIENT_C 0x200
+#define CMD_INDEX_T 0x400
+#define CMD_INDEX_S 0x800
+#define CMD_CANFAIL 0x1000
+#define CMD_PREFERUNATTACHED 0x2000
+#define CMD_MOVEW_R 0x4000 /* for movew -r only */
+#define CMD_PANE_MARKED_S 0x8000
+#define CMD_PANE_MARKED_T 0x10000
+#define CMD_WINDOW_MARKED_T 0x20000
+#define CMD_WINDOW_MARKED_S 0x40000
int flags;
enum cmd_retval (*exec)(struct cmd *, struct cmd_q *);
};
+#define CMD_ALL_T (CMD_SESSION_T|CMD_WINDOW_T|CMD_PANE_T|CMD_INDEX_T| \
+ CMD_MOVEW_R|CMD_PANE_MARKED_T|CMD_WINDOW_MARKED_T)
+#define CMD_ALL_S (CMD_SESSION_S|CMD_WINDOW_S|CMD_PANE_S|CMD_INDEX_S| \
+ CMD_PANE_MARKED_S|CMD_WINDOW_MARKED_S)
/* Key binding and key table. */
struct key_binding {
@@ -1718,6 +1755,7 @@ char **cmd_copy_argv(int, char **);
void cmd_free_argv(int, char **);
char *cmd_stringify_argv(int, char **);
struct cmd *cmd_parse(int, char **, const char *, u_int, char **);
+int cmd_prepare_state(struct cmd *, struct cmd_q *);
char *cmd_print(struct cmd *);
int cmd_mouse_at(struct window_pane *, struct mouse_event *,
u_int *, u_int *, int);
@@ -1728,8 +1766,8 @@ char *cmd_template_replace(const char *, const char *, int);
extern const struct cmd_entry *cmd_table[];
/* cmd-attach-session.c */
-enum cmd_retval cmd_attach_session(struct cmd_q *, const char *, int, int,
- const char *, int);
+enum cmd_retval cmd_attach_session(struct cmd_q *, int, int, const char *,
+ int);
/* cmd-list.c */
struct cmd_list *cmd_list_parse(int, char **, const char *, u_int, char **);