The branch, master has been updated via 23e944c91d45e49a3c924712c234e7db6891ad98 (commit) via f15fcb6a1d79b67db0aa65a8c0a40c1c15e49720 (commit) from 8c0edcbfa3bd78bb8adaba13aad29a06d8988de8 (commit)
- Log ----------------------------------------------------------------- commit 23e944c91d45e49a3c924712c234e7db6891ad98 Author: Nicholas Marriott <nicholas.marri...@gmail.com> Commit: Nicholas Marriott <nicholas.marri...@gmail.com> Add names for mouse button bits rather than using magic numbers, from Marcel Partap. --- tmux.h | 12 ++++++++++-- tty-keys.c | 10 +++++----- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/tmux.h b/tmux.h index 28351d0..fe6bad2 100644 --- a/tmux.h +++ b/tmux.h @@ -1125,18 +1125,26 @@ struct tty_term { }; LIST_HEAD(tty_terms, tty_term); +/* Mouse button masks. */ +#define MOUSE_MASK_BUTTONS 3 +#define MOUSE_MASK_SHIFT 4 +#define MOUSE_MASK_META 8 +#define MOUSE_MASK_CTRL 16 +#define MOUSE_MASK_DRAG 32 +#define MOUSE_MASK_WHEEL 64 + /* Mouse wheel states. */ #define MOUSE_WHEEL_UP 0 #define MOUSE_WHEEL_DOWN 1 -/* Mouse events. */ +/* 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 flags. */ +/* Mouse flag bits. */ #define MOUSE_RESIZE_PANE 0x1 /* diff --git a/tty-keys.c b/tty-keys.c index 7fb91a8..9dbe450 100644 --- a/tty-keys.c +++ b/tty-keys.c @@ -748,21 +748,21 @@ tty_keys_mouse(struct tty *tty, const char *buf, size_t len, size_t *size) m->sgr_rel = sgr_rel; m->x = x; m->y = y; - if (b & 64) { /* wheel button */ - b &= 3; + if (b & MOUSE_MASK_WHEEL) { + b &= MOUSE_MASK_BUTTONS; if (b == 0) m->wheel = MOUSE_WHEEL_UP; else if (b == 1) m->wheel = MOUSE_WHEEL_DOWN; m->event = MOUSE_EVENT_WHEEL; - } else if ((b & 3) == 3) { + } else if ((b & MOUSE_MASK_BUTTONS) == 3) { if (~m->event & MOUSE_EVENT_DRAG && x == m->x && y == m->y) { m->event = MOUSE_EVENT_CLICK; } else m->event = MOUSE_EVENT_DRAG; m->event |= MOUSE_EVENT_UP; } else { - if (b & 32) /* drag motion */ + if (b & MOUSE_MASK_DRAG) m->event = MOUSE_EVENT_DRAG; else { if (m->event & MOUSE_EVENT_UP && x == m->x && y == m->y) @@ -773,7 +773,7 @@ tty_keys_mouse(struct tty *tty, const char *buf, size_t len, size_t *size) m->sy = y; m->event = MOUSE_EVENT_DOWN; } - m->button = (b & 3); + m->button = (b & MOUSE_MASK_BUTTONS); } return (0); commit f15fcb6a1d79b67db0aa65a8c0a40c1c15e49720 Author: Nicholas Marriott <nicholas.marri...@gmail.com> Commit: Nicholas Marriott <nicholas.marri...@gmail.com> Use hex constants rather than shifts for mouse events and flags, pointed out by Marcel Partap. --- tmux.h | 12 ++++++------ 1 files changed, 6 insertions(+), 6 deletions(-) diff --git a/tmux.h b/tmux.h index 68790a0..28351d0 100644 --- a/tmux.h +++ b/tmux.h @@ -1130,14 +1130,14 @@ LIST_HEAD(tty_terms, tty_term); #define MOUSE_WHEEL_DOWN 1 /* Mouse events. */ -#define MOUSE_EVENT_DOWN (1 << 0) -#define MOUSE_EVENT_DRAG (1 << 1) -#define MOUSE_EVENT_UP (1 << 2) -#define MOUSE_EVENT_CLICK (1 << 3) -#define MOUSE_EVENT_WHEEL (1 << 4) +#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 flags. */ -#define MOUSE_RESIZE_PANE (1 << 0) +#define MOUSE_RESIZE_PANE 0x1 /* * Mouse input. When sent by xterm: ----------------------------------------------------------------------- Summary of changes: tmux.h | 24 ++++++++++++++++-------- tty-keys.c | 10 +++++----- 2 files changed, 21 insertions(+), 13 deletions(-) hooks/post-receive -- tmux ------------------------------------------------------------------------------ Subversion Kills Productivity. Get off Subversion & Make the Move to Perforce. With Perforce, you get hassle-free workflows. Merge that actually works. Faster operations. Version large binaries. Built-in WAN optimization and the freedom to use Git, Perforce or both. Make the move to Perforce. http://pubads.g.doubleclick.net/gampad/clk?id=122218951&iu=/4140/ostg.clktrk _______________________________________________ tmux-cvs mailing list tmux-cvs@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/tmux-cvs