Преглед изворни кода

add second esc seq. string for mouse events

Jan Klemkow пре 5 година
родитељ
комит
94da2d2b15
2 измењених фајлова са 13 додато и 4 уклоњено
  1. 9 2
      config.def.h
  2. 4 2
      scroll.c

+ 9 - 2
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 */

+ 4 - 2
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:");