Merge branch 'obsd-master'

This commit is contained in:
Thomas Adam
2015-04-20 15:44:27 +01:00
30 changed files with 1106 additions and 661 deletions

151
tmux.h
View File

@ -93,10 +93,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,
@ -145,15 +174,13 @@ enum key_code {
KEYC_KP_ENTER,
KEYC_KP_ZERO,
KEYC_KP_PERIOD,
KEYC_FOCUS_IN,
KEYC_FOCUS_OUT,
};
/* Termcap codes. */
enum tty_code_code {
TTYC_AX = 0,
TTYC_ACSC, /* acs_chars, ac */
TTYC_BCE, /* back_color_erase, ut */
TTYC_BEL, /* bell, bl */
TTYC_BLINK, /* enter_blink_mode, mb */
TTYC_BOLD, /* enter_bold_mode, md */
@ -815,16 +842,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 *);
};
@ -900,6 +926,8 @@ struct window_pane {
struct input_ctx ictx;
struct grid_cell colgc;
int pipe_fd;
struct bufferevent *pipe_event;
size_t pipe_off;
@ -1109,54 +1137,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;
int key;
int statusat;
u_int x;
u_int lx;
u_int sx;
u_int y;
u_int b;
u_int lx;
u_int ly;
u_int sy;
u_int lb;
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 */
int s;
int w;
int wp;
u_int button;
u_int clicks;
u_int scroll;
int wheel;
int event;
int flags;
u_int sgr_type;
u_int sgr_b;
};
struct tty {
@ -1202,6 +1211,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;
@ -1377,6 +1391,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);
@ -1604,7 +1621,8 @@ void environ_push(struct environ *);
/* tty.c */
void tty_init_termios(int, struct termios *, struct bufferevent *);
void tty_raw(struct tty *, const char *);
void tty_attributes(struct tty *, const struct grid_cell *);
void tty_attributes(struct tty *, const struct grid_cell *,
const struct window_pane *);
void tty_reset(struct tty *);
void tty_region_pane(struct tty *, const struct tty_ctx *, u_int, u_int);
void tty_region(struct tty *, u_int, u_int);
@ -1628,7 +1646,10 @@ void tty_stop_tty(struct tty *);
void tty_set_title(struct tty *, const char *);
void tty_update_mode(struct tty *, int, struct screen *);
void tty_force_cursor_colour(struct tty *, const char *);
void tty_draw_line(struct tty *, struct screen *, u_int, u_int, u_int);
void tty_draw_pane(struct tty *, const struct window_pane *, u_int, u_int,
u_int);
void tty_draw_line(struct tty *, const struct window_pane *, struct screen *,
u_int, u_int, u_int);
int tty_open(struct tty *, char **);
void tty_close(struct tty *);
void tty_free(struct tty *);
@ -1714,6 +1735,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);
@ -1830,8 +1856,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 *);
@ -1853,7 +1881,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 *);
@ -1921,7 +1950,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 *);
@ -1942,9 +1971,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);
@ -2109,6 +2136,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);
@ -2139,9 +2167,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 *);
@ -2177,7 +2204,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);
@ -2206,6 +2232,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;