> I usually find it helpful to compile with clang in these situations
> (CC=/usr/bin/clang and CXX=/usr/bin/clang++). The error messages are
> usually much more helpful.
Sheesh that was helpful indeed THANKS :)
> # CC=clang ./configure --enable-debug
> ...
> depbase=`echo tty-term.o | sed 's|[^/]*$|.deps/&|;s|\.o$||'`;\
> /usr/bin/clang -DPACKAGE_NAME=\"tmux\" -DPACKAGE_TARNAME=\"tmux\"
> -DPACKAGE_VERSION=\"1.10\" -DPACKAGE_STRING=\"tmux\ 1.10\"
> -DPACKAGE_BUGREPORT=\"\" -DPACKAGE_URL=\"\" -DPACKAGE=\"tmux\"
> -DVERSION=\"1.10\" -DSTDC_HEADERS=1 -DHAVE_SYS_TYPES_H=1
> -DHAVE_SYS_STAT_H=1 -DHAVE_STDLIB_H=1 -DHAVE_STRING_H=1
> -DHAVE_MEMORY_H=1 -DHAVE_STRINGS_H=1 -DHAVE_INTTYPES_H=1
> -DHAVE_STDINT_H=1 -DHAVE_UNISTD_H=1 -DHAVE_CURSES_H=1
> -DHAVE_DIRENT_H=1 -DHAVE_FCNTL_H=1 -DHAVE_INTTYPES_H=1
> -DHAVE_NCURSES_H=1 -DHAVE_PATHS_H=1 -DHAVE_PTY_H=1 -DHAVE_STDINT_H=1
> -DHAVE_SYS_DIR_H=1 -DHAVE_TERM_H=1 -DHAVE_B64_NTOP=1 -DHAVE_FORKPTY=1
> -DHAVE_DAEMON=1 -DHAVE_SETENV=1 -DHAVE_ASPRINTF=1 -DHAVE_STRCASESTR=1
> -DHAVE_STRSEP=1 -DHAVE_CFMAKERAW=1 -DHAVE_OPENAT=1
> -DHAVE_DECL_OPTARG=1 -DHAVE_DECL_OPTIND=1 -DHAVE_DECL_OPTRESET=0
> -DHAVE_BZERO=1 -DHAVE_DIRFD=1 -DHAVE_SYSCONF=1 -DHAVE_CFMAKERAW=1
> -DHAVE_BSD_TYPES=1 -DHAVE___PROGNAME=1 -DHAVE_PROC_PID=1 -I.
> -DTMUX_CONF="\"/etc/tmux.conf\"" -DDEBUG -iquote.
> -I/usr/local/include     -D_GNU_SOURCE -std=gnu99 -O0 -g
> -Wno-long-long -Wall -W -Wnested-externs -Wformat=2
> -Wmissing-prototypes -Wstrict-prototypes -Wmissing-declarations
> -Wwrite-strings -Wshadow -Wpointer-arith -Wsign-compare -Wundef
> -Wbad-function-cast -Winline -Wcast-align
> -Wdeclaration-after-statement  -Wno-pointer-sign  -MT tty-term.o -MD
> -MP -MF $depbase.Tpo -c -o tty-term.o tty-term.c &&\
>         mv -f $depbase.Tpo $depbase.Po
> In file included from tty-term.c:31:
> ./tmux.h:1168:8: error: expected ';' at end of declaration list
>         u_int   lines;
>                 ^
> /usr/include/term.h:166:40: note: expanded from macro 'lines'
> #define lines                          CUR Numbers[2]
>                                        ^
> /usr/include/term.h:125:21: note: expanded from macro 'CUR'
> #define CUR cur_term->type.
>                     ^
> 1 error generated.
> make: *** [tty-term.o] Error 1


Turns out "lines" is being defined as a macro in term.h.. well not too
big an issue.
here's another roll.
>From f0edcc6f5ea56ea5f036d85ec4e28bf74a19730a Mon Sep 17 00:00:00 2001
From: Nicholas Marriott <nicholas.marri...@gmail.com>
Date: Wed, 26 Feb 2014 23:04:23 +0000
Subject: [PATCH] Implement simple mouse wheel emulation, 5th.

---
 input-keys.c    | 16 ++++++++++++++++
 server-fn.c     |  1 +
 tmux.h          |  6 ++++++
 tty-keys.c      | 17 ++++++++++++++++-
 window-choose.c | 10 +++++++++-
 window-copy.c   | 16 +++++++---------
 6 files changed, 55 insertions(+), 11 deletions(-)

diff --git a/input-keys.c b/input-keys.c
index 7582a63..656816e 100644
--- a/input-keys.c
+++ b/input-keys.c
@@ -204,6 +204,22 @@ input_mouse(struct window_pane *wp, struct session *s, struct mouse_event *m)
 	char			 buf[40];
 	size_t			 len;
 	struct paste_buffer	*pb;
+	u_int			 i;
+
+	/*
+	 * Mouse wheel used while alternate screen is active and not mouse
+	 * aware, or shift is pressed.
+	 */
+	if (((wp->saved_grid != NULL && !(wp->screen->mode & ALL_MOUSE_MODES)) ||
+	    m->xb & MOUSE_SHIFT)) {
+		for (i = 0; i < m->scroll; i++) {
+			if (m->wheel == MOUSE_WHEEL_UP)
+				input_key(wp, KEYC_UP);
+			else
+				input_key(wp, KEYC_DOWN);
+		}
+		return;
+	}
 
 	if (wp->screen->mode & ALL_MOUSE_MODES) {
 		/*
diff --git a/server-fn.c b/server-fn.c
index 3062698..47e1cee 100644
--- a/server-fn.c
+++ b/server-fn.c
@@ -609,3 +609,4 @@ server_unzoom_window(struct window *w)
 	server_redraw_window(w);
 	server_status_window(w);
 }
+
diff --git a/tmux.h b/tmux.h
index 23b1b46..c288a79 100644
--- a/tmux.h
+++ b/tmux.h
@@ -1129,6 +1129,11 @@ LIST_HEAD(tty_terms, tty_term);
 #define MOUSE_EVENT_CLICK (1 << 3)
 #define MOUSE_EVENT_WHEEL (1 << 4)
 
+/* Mouse modifier key states. */
+#define MOUSE_SHIFT 4
+#define MOUSE_META 8
+#define MOUSE_CTRL 16
+
 /* Mouse flags. */
 #define MOUSE_RESIZE_PANE (1 << 0)
 
@@ -1160,6 +1165,7 @@ struct mouse_event {
 
 	u_int	button;
 	u_int	clicks;
+	u_int	scroll;
 
 	int	wheel;
 	int     event;
diff --git a/tty-keys.c b/tty-keys.c
index 7fb91a8..3e3bb85 100644
--- a/tty-keys.c
+++ b/tty-keys.c
@@ -748,13 +748,28 @@ 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;
+	m->scroll = 0;
 	if (b & 64) { /* wheel button */
+		m->event = MOUSE_EVENT_WHEEL;
+		/*
+		 * figure out number of lines to scroll, shift is a single
+		 * line, meta and ctrl multiply exponentially.
+		 */
+		if (b & MOUSE_SHIFT)
+			m->scroll = 1;
+		else
+			m->scroll = 3;
+
+		if (b & MOUSE_META)
+			m->scroll *= 3;
+		if (b & MOUSE_CTRL)
+			m->scroll *= 3;
+
 		b &= 3;
 		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) {
 		if (~m->event & MOUSE_EVENT_DRAG && x == m->x && y == m->y) {
 			m->event = MOUSE_EVENT_CLICK;
diff --git a/window-choose.c b/window-choose.c
index 7b2b32b..9d91994 100644
--- a/window-choose.c
+++ b/window-choose.c
@@ -698,7 +698,15 @@ window_choose_mouse(
 	struct window_choose_mode_data	*data = wp->modedata;
 	struct screen			*s = &data->screen;
 	struct window_choose_mode_item	*item;
-	u_int				 idx;
+	u_int				 i, idx;
+
+	for (i = 0; i < m->scroll; i++) {
+		if (m->wheel == MOUSE_WHEEL_UP)
+			window_choose_key(wp, sess, KEYC_UP);
+		else
+			window_choose_key(wp, sess, KEYC_DOWN);
+		return;
+	}
 
 	if (~m->event & MOUSE_EVENT_CLICK)
 		return;
diff --git a/window-copy.c b/window-copy.c
index 527c95c..70dbe63 100644
--- a/window-copy.c
+++ b/window-copy.c
@@ -862,16 +862,14 @@ window_copy_mouse(
 		return;
 
 	/* If mouse wheel (buttons 4 and 5), scroll. */
-	if (m->event == MOUSE_EVENT_WHEEL) {
-		if (m->wheel == MOUSE_WHEEL_UP) {
-			for (i = 0; i < 5; i++)
-				window_copy_cursor_up(wp, 1);
-		} else if (m->wheel == MOUSE_WHEEL_DOWN) {
-			for (i = 0; i < 5; i++)
-				window_copy_cursor_down(wp, 1);
+	for (i = 0; i < m->scroll; i++) {
+		if (m->wheel == MOUSE_WHEEL_UP)
+			window_copy_cursor_up(wp, 1);
+		else {
+			window_copy_cursor_down(wp, 1);
 			/*
-			 * We reached the bottom, leave copy mode,
-			 * but only if no selection is in progress.
+			 * We reached the bottom, leave copy mode, but only if
+			 * no selection is in progress.
 			 */
 			if (data->oy == 0 && !s->sel.flag)
 			    goto reset_mode;
-- 
1.9.0

------------------------------------------------------------------------------
Flow-based real-time traffic analytics software. Cisco certified tool.
Monitor traffic, SLAs, QoS, Medianet, WAAS etc. with NetFlow Analyzer
Customize your own dashboards, set traffic alerts and generate reports.
Network behavioral analysis & security monitoring. All-in-one tool.
http://pubads.g.doubleclick.net/gampad/clk?id=126839071&iu=/4140/ostg.clktrk
_______________________________________________
tmux-users mailing list
tmux-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/tmux-users

Reply via email to