summaryrefslogtreecommitdiff
path: root/usr.bin/tmux
diff options
context:
space:
mode:
authorTed Unangst <tedu@cvs.openbsd.org>2010-06-29 05:24:50 +0000
committerTed Unangst <tedu@cvs.openbsd.org>2010-06-29 05:24:50 +0000
commita8513a0222af62280ad0380a2efdcbe0c97fd2f9 (patch)
tree4ef00237c2b4254c67a68ce13d85fb0c9c32c75b /usr.bin/tmux
parente0a3b8e51d24b584910ba4006b8df28b77437df3 (diff)
replace some magic mouse constants with defines for clarity. ok nicm
Diffstat (limited to 'usr.bin/tmux')
-rw-r--r--usr.bin/tmux/tmux.h16
-rw-r--r--usr.bin/tmux/window-copy.c21
2 files changed, 21 insertions, 16 deletions
diff --git a/usr.bin/tmux/tmux.h b/usr.bin/tmux/tmux.h
index f8dd044d80b..09397cd8e58 100644
--- a/usr.bin/tmux/tmux.h
+++ b/usr.bin/tmux/tmux.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: tmux.h,v 1.232 2010/06/29 03:30:14 nicm Exp $ */
+/* $OpenBSD: tmux.h,v 1.233 2010/06/29 05:24:49 tedu Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -1050,9 +1050,23 @@ struct tty_ctx {
u_int last_width;
};
+/*
+ * xterm mouse mode is fairly silly. Buttons are in the bottom two
+ * bits: 0 button 1; 1 button 2; 2 button 3; 3 buttons released.
+ *
+ * Bit 3 is shift; bit 4 is meta; bit 5 control.
+ *
+ * Bit 6 is added for mouse buttons 4 and 5.
+ */
/* Mouse input. */
struct mouse_event {
u_char b;
+#define MOUSE_1 0
+#define MOUSE_2 1
+#define MOUSE_3 2
+#define MOUSE_UP 3
+#define MOUSE_BUTTON 3
+#define MOUSE_45 64
u_char x;
u_char y;
};
diff --git a/usr.bin/tmux/window-copy.c b/usr.bin/tmux/window-copy.c
index 351ff2b529e..97b71afc319 100644
--- a/usr.bin/tmux/window-copy.c
+++ b/usr.bin/tmux/window-copy.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: window-copy.c,v 1.59 2010/06/06 19:00:13 nicm Exp $ */
+/* $OpenBSD: window-copy.c,v 1.60 2010/06/29 05:24:49 tedu Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -762,26 +762,17 @@ window_copy_mouse(
struct screen *s = &data->screen;
u_int i;
- /*
- * xterm mouse mode is fairly silly. Buttons are in the bottom two
- * bits: 0 button 1; 1 button 2; 2 button 3; 3 buttons released.
- *
- * Bit 3 is shift; bit 4 is meta; bit 5 control.
- *
- * Bit 6 is added for mouse buttons 4 and 5.
- */
-
if (m->x >= screen_size_x(s))
return;
if (m->y >= screen_size_y(s))
return;
/* If mouse wheel (buttons 4 and 5), scroll. */
- if ((m->b & 64) == 64) {
- if ((m->b & 3) == 0) {
+ if ((m->b & MOUSE_45)) {
+ if ((m->b & MOUSE_BUTTON) == MOUSE_1) {
for (i = 0; i < 5; i++)
window_copy_cursor_up(wp, 0);
- } else if ((m->b & 3) == 1) {
+ } else if ((m->b & MOUSE_BUTTON) == MOUSE_2) {
for (i = 0; i < 5; i++)
window_copy_cursor_down(wp, 0);
}
@@ -793,7 +784,7 @@ window_copy_mouse(
* pressed, or stop the selection on their release.
*/
if (s->mode & MODE_MOUSEMOTION) {
- if ((m->b & 3) != 3) {
+ if ((m->b & MOUSE_BUTTON) != MOUSE_UP) {
window_copy_update_cursor(wp, m->x, m->y);
if (window_copy_update_selection(wp))
window_copy_redraw_screen(wp);
@@ -808,7 +799,7 @@ window_copy_mouse(
}
/* Otherwise i other buttons pressed, start selection and motion. */
- if ((m->b & 3) != 3) {
+ if ((m->b & MOUSE_BUTTON) != MOUSE_UP) {
s->mode |= MODE_MOUSEMOTION;
window_copy_update_cursor(wp, m->x, m->y);