Hi,
please comment on this.
- sends keyboard UP/DOWN sequences per mouse wheel event
- active in alternate screen mode (like xterm)
- also active when pressing SHIFT outside alternate screen (like
previous iteration)
- scrolls 3 lines per event (like f.e. konsole)
- or single lines when SHIFT is held
- holding CTRL, META each gives triple speedup
- doesn't interfere with copy mode.

- Does it need a switch? option name suggestions?
- Should the "speed factor" be configurable? option name suggestions?

#Regards!MPartap
>From 8282f4878f08a6220144bd531b87f129c9ba2c55 Mon Sep 17 00:00:00 2001
From: Marcel Partap <mpar...@gmx.net>
Date: Mon, 17 Feb 2014 22:02:14 +0100
Subject: [PATCH] Implement simple mouse wheel emulation.

---
 input-keys.c | 15 +++++++++++++++
 tmux.h       |  5 +++++
 2 files changed, 20 insertions(+)

diff --git a/input-keys.c b/input-keys.c
index 7582a63..5c5e105 100644
--- a/input-keys.c
+++ b/input-keys.c
@@ -204,6 +204,21 @@ input_mouse(struct window_pane *wp, struct session *s, struct mouse_event *m)
 	char			 buf[40];
 	size_t			 len;
 	struct paste_buffer	*pb;
+	int			 i, lines, factor;
+
+	if (m->event == MOUSE_EVENT_WHEEL) {
+		/* Alternate screen is active, or shift is pressed. */
+		if (wp->saved_grid || m->xb & MOUSE_SHIFT) {
+			factor = 3;
+                        /* wheel + SHIFT: scroll single line, else three. */
+			lines = (m->xb & MOUSE_SHIFT) ? 1 : factor;
+                        /* wheel + META or CTRL: speed up by factor 3. */
+			lines *= (m->xb & MOUSE_ESCAPE) ? factor : 1;
+			lines *= (m->xb & MOUSE_CTRL) ? factor : 1;
+			for (i = 0; i < lines; i++)
+				input_key(wp, m->wheel == MOUSE_WHEEL_UP ? KEYC_UP : KEYC_DOWN);
+		}
+	}
 
 	if (wp->screen->mode & ALL_MOUSE_MODES) {
 		/*
diff --git a/tmux.h b/tmux.h
index 7d5f230..d78e2a7 100644
--- a/tmux.h
+++ b/tmux.h
@@ -1125,6 +1125,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_ESCAPE 8
+#define MOUSE_CTRL 16
+
 /* Mouse flags. */
 #define MOUSE_RESIZE_PANE (1 << 0)
 
-- 
1.9.0.rc3

------------------------------------------------------------------------------
Managing the Performance of Cloud-Based Applications
Take advantage of what the Cloud has to offer - Avoid Common Pitfalls.
Read the Whitepaper.
http://pubads.g.doubleclick.net/gampad/clk?id=121054471&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