commit 94da2d2b15ecb4274f2ac2da91807c56743b15a8
Author: Jan Klemkow <[email protected]>
AuthorDate: Thu Apr 2 22:20:33 2020 +0200
Commit: Jan Klemkow <[email protected]>
CommitDate: Thu Apr 2 22:20:33 2020 +0200
add second esc seq. string for mouse events
diff --git a/config.def.h b/config.def.h
index 0b61bed..4a2a385 100644
--- a/config.def.h
+++ b/config.def.h
@@ -1,2 +1,9 @@
-#define SCROLL_UP "\033[5;2~"
-#define SCROLL_DOWN "\033[6;2~"
+/*
+ * Define ESC seqences to use for scroll events.
+ * Use "cat -v" to figure out favorit key combination.
+ */
+#define KB_SCROLL_UP "\033[5;2~" /* [Shift] + [PageUP] */
+#define KB_SCROLL_DOWN "\033[6;2~" /* [Shift] + [PageDown] */
+
+#define MS_SCROLL_UP "\031" /* mouse wheel up */
+#define MS_SCROLL_DOWN "\005" /* mouse wheel Down */
diff --git a/scroll.c b/scroll.c
index 1b864a0..76b6324 100644
--- a/scroll.c
+++ b/scroll.c
@@ -390,9 +390,11 @@ main(int argc, char *argv[])
if (n <= 0 && errno != EINTR)
die("read:");
- if (strncmp(SCROLL_UP, input, n) == 0)
+ if (strncmp(KB_SCROLL_UP, input, n) == 0 ||
+ strncmp(MS_SCROLL_UP, input, n) == 0)
scrollup();
- else if (strncmp(SCROLL_DOWN, input, n) == 0)
+ else if (strncmp(KB_SCROLL_DOWN, input, n) == 0 ||
+ strncmp(MS_SCROLL_DOWN, input, n) == 0)
scrolldown(buf, pos);
else if (write(mfd, input, n) == -1)
die("write:");