diff options
Diffstat (limited to 'tmux.h')
-rw-r--r-- | tmux.h | 140 |
1 files changed, 80 insertions, 60 deletions
@@ -95,10 +95,39 @@ extern char **environ; #define KEYC_MASK_MOD (KEYC_ESCAPE|KEYC_CTRL|KEYC_SHIFT|KEYC_PREFIX) #define KEYC_MASK_KEY (~KEYC_MASK_MOD) -/* Other key codes. */ +/* Is this a mouse key? */ +#define KEYC_IS_MOUSE(key) (((key) & KEYC_MASK_KEY) >= KEYC_MOUSE && \ + ((key) & KEYC_MASK_KEY) < KEYC_BSPACE) + +/* Mouse key codes. */ +#define KEYC_MOUSE_KEY(name) \ + KEYC_ ## name ## _PANE, \ + KEYC_ ## name ## _STATUS, \ + KEYC_ ## name ## _BORDER +#define KEYC_MOUSE_STRING(name, s) \ + { #s "Pane", KEYC_ ## name ## _PANE }, \ + { #s "Status", KEYC_ ## name ## _STATUS }, \ + { #s "Border", KEYC_ ## name ## _BORDER } + +/* Special key codes. */ enum key_code { - /* Mouse key. */ - KEYC_MOUSE = KEYC_BASE, + /* Focus events. */ + KEYC_FOCUS_IN = KEYC_BASE, + KEYC_FOCUS_OUT, + + /* Mouse keys. */ + KEYC_MOUSE, /* unclassified mouse event */ + KEYC_MOUSE_KEY(MOUSEDOWN1), + KEYC_MOUSE_KEY(MOUSEDOWN2), + KEYC_MOUSE_KEY(MOUSEDOWN3), + KEYC_MOUSE_KEY(MOUSEUP1), + KEYC_MOUSE_KEY(MOUSEUP2), + KEYC_MOUSE_KEY(MOUSEUP3), + KEYC_MOUSE_KEY(MOUSEDRAG1), + KEYC_MOUSE_KEY(MOUSEDRAG2), + KEYC_MOUSE_KEY(MOUSEDRAG3), + KEYC_MOUSE_KEY(WHEELUP), + KEYC_MOUSE_KEY(WHEELDOWN), /* Backspace key. */ KEYC_BSPACE, @@ -147,9 +176,6 @@ enum key_code { KEYC_KP_ENTER, KEYC_KP_ZERO, KEYC_KP_PERIOD, - - KEYC_FOCUS_IN, - KEYC_FOCUS_OUT, }; /* Termcap codes. */ @@ -818,16 +844,15 @@ struct input_ctx { * Window mode. Windows can be in several modes and this is used to call the * right function to handle input and output. */ +struct client; struct session; -struct window; struct mouse_event; struct window_mode { struct screen *(*init)(struct window_pane *); void (*free)(struct window_pane *); void (*resize)(struct window_pane *, u_int, u_int); - void (*key)(struct window_pane *, struct session *, int); - void (*mouse)(struct window_pane *, - struct session *, struct mouse_event *); + void (*key)(struct window_pane *, struct client *, struct session *, + int, struct mouse_event *); void (*timer)(struct window_pane *); }; @@ -1114,54 +1139,35 @@ LIST_HEAD(tty_terms, tty_term); /* Mouse wheel states. */ #define MOUSE_WHEEL_UP 0 -#define MOUSE_WHEEL_DOWN 1 +#define MOUSE_WHEEL_DOWN 64 -/* Mouse wheel multipler. */ -#define MOUSE_WHEEL_SCALE 3 +/* Mouse helpers. */ +#define MOUSE_BUTTONS(b) ((b) & MOUSE_MASK_BUTTONS) +#define MOUSE_WHEEL(b) ((b) & MOUSE_MASK_WHEEL) +#define MOUSE_DRAG(b) ((b) & MOUSE_MASK_DRAG) +#define MOUSE_RELEASE(b) (((b) & MOUSE_MASK_BUTTONS) == 3) -/* Mouse event bits. */ -#define MOUSE_EVENT_DOWN 0x1 -#define MOUSE_EVENT_DRAG 0x2 -#define MOUSE_EVENT_UP 0x4 -#define MOUSE_EVENT_CLICK 0x8 -#define MOUSE_EVENT_WHEEL 0x10 - -/* Mouse flag bits. */ -#define MOUSE_RESIZE_PANE 0x1 - -/* - * Mouse input. When sent by xterm: - * - * - buttons are in the bottom two bits: 0 = b1; 1 = b2; 2 = b3; 3 = released - * - bits 3, 4 and 5 are for keys - * - bit 6 is set for dragging - * - bit 7 for buttons 4 and 5 - * - * With the SGR 1006 extension the released button becomes known. Store these - * in separate fields and store the value converted to the old format in xb. - */ +/* Mouse input. */ struct mouse_event { - u_int xb; + int valid; - u_int x; - u_int lx; - u_int sx; + int key; + int statusat; + u_int x; u_int y; - u_int ly; - u_int sy; + u_int b; - u_int sgr; /* whether the input arrived in SGR format */ - u_int sgr_xb; /* only for SGR: the unmangled button */ - u_int sgr_rel; /* only for SGR: if it is a release event */ + u_int lx; + u_int ly; + u_int lb; - u_int button; - u_int clicks; - u_int scroll; + int s; + int w; + int wp; - int wheel; - int event; - int flags; + u_int sgr_type; + u_int sgr_b; }; struct tty { @@ -1207,6 +1213,11 @@ struct tty { int term_flags; struct mouse_event mouse; + int mouse_drag_flag; + void (*mouse_drag_update)(struct client *, + struct mouse_event *); + void (*mouse_drag_release)(struct client *, + struct mouse_event *); struct event key_timer; struct tty_key *key_tree; @@ -1382,6 +1393,9 @@ enum cmd_retval { /* Command queue entry. */ struct cmd_q_item { struct cmd_list *cmdlist; + + struct mouse_event mouse; + TAILQ_ENTRY(cmd_q_item) qentry; }; TAILQ_HEAD(cmd_q_items, cmd_q_item); @@ -1723,6 +1737,11 @@ void cmd_free_argv(int, char **); char *cmd_stringify_argv(int, char **); struct cmd *cmd_parse(int, char **, const char *, u_int, char **); size_t cmd_print(struct cmd *, char *, size_t); +int cmd_mouse_at(struct window_pane *, struct mouse_event *, + u_int *, u_int *, int); +struct winlink *cmd_mouse_window(struct mouse_event *, struct session **); +struct window_pane *cmd_mouse_pane(struct mouse_event *, struct session **, + struct winlink **); struct session *cmd_current_session(struct cmd_q *, int); struct client *cmd_current_client(struct cmd_q *); struct client *cmd_find_client(struct cmd_q *, const char *, int); @@ -1839,8 +1858,10 @@ int cmdq_free(struct cmd_q *); void printflike(2, 3) cmdq_print(struct cmd_q *, const char *, ...); void printflike(2, 3) cmdq_error(struct cmd_q *, const char *, ...); void cmdq_guard(struct cmd_q *, const char *, int); -void cmdq_run(struct cmd_q *, struct cmd_list *); -void cmdq_append(struct cmd_q *, struct cmd_list *); +void cmdq_run(struct cmd_q *, struct cmd_list *, + struct mouse_event *); +void cmdq_append(struct cmd_q *, struct cmd_list *, + struct mouse_event *); int cmdq_continue(struct cmd_q *); void cmdq_flush(struct cmd_q *); @@ -1862,7 +1883,8 @@ struct key_binding *key_bindings_lookup(int); void key_bindings_add(int, int, struct cmd_list *); void key_bindings_remove(int); void key_bindings_init(void); -void key_bindings_dispatch(struct key_binding *, struct client *); +void key_bindings_dispatch(struct key_binding *, struct client *, + struct mouse_event *); /* key-string.c */ int key_string_lookup_string(const char *); @@ -1930,7 +1952,7 @@ RB_PROTOTYPE(status_out_tree, status_out, entry, status_out_cmp); int status_at_line(struct client *); void status_free_jobs(struct status_out_tree *); void status_update_jobs(struct client *); -void status_set_window_at(struct client *, u_int); +struct window *status_get_window_at(struct client *, u_int); int status_redraw(struct client *); void printflike(2, 3) status_message_set(struct client *, const char *, ...); void status_message_clear(struct client *); @@ -1951,9 +1973,7 @@ void input_free(struct window_pane *); void input_parse(struct window_pane *); /* input-key.c */ -void input_key(struct window_pane *, int); -void input_mouse(struct window_pane *, struct session *, - struct mouse_event *); +void input_key(struct window_pane *, int, struct mouse_event *); /* xterm-keys.c */ char *xterm_keys_lookup(int); @@ -2118,6 +2138,7 @@ void window_destroy(struct window *); struct window_pane *window_get_active_at(struct window *, u_int, u_int); void window_set_active_at(struct window *, u_int, u_int); struct window_pane *window_find_string(struct window *, const char *); +int window_has_pane(struct window *, struct window_pane *); int window_set_active_pane(struct window *, struct window_pane *); struct window_pane *window_add_pane(struct window *, u_int); void window_resize(struct window *, u_int, u_int); @@ -2148,9 +2169,8 @@ void window_pane_alternate_off(struct window_pane *, int window_pane_set_mode( struct window_pane *, const struct window_mode *); void window_pane_reset_mode(struct window_pane *); -void window_pane_key(struct window_pane *, struct session *, int); -void window_pane_mouse(struct window_pane *, - struct session *, struct mouse_event *); +void window_pane_key(struct window_pane *, struct client *, + struct session *, int, struct mouse_event *); int window_pane_visible(struct window_pane *); char *window_pane_search( struct window_pane *, const char *, u_int *); @@ -2186,7 +2206,6 @@ void layout_resize_pane(struct window_pane *, enum layout_type, int); void layout_resize_pane_to(struct window_pane *, enum layout_type, u_int); -void layout_resize_pane_mouse(struct client *); void layout_assign_pane(struct layout_cell *, struct window_pane *); struct layout_cell *layout_split_pane( struct window_pane *, enum layout_type, int, int); @@ -2215,6 +2234,7 @@ void window_copy_init_for_output(struct window_pane *); void printflike(2, 3) window_copy_add(struct window_pane *, const char *, ...); void window_copy_vadd(struct window_pane *, const char *, va_list); void window_copy_pageup(struct window_pane *); +void window_copy_start_drag(struct client *, struct mouse_event *); /* window-choose.c */ extern const struct window_mode window_choose_mode; |