aboutsummaryrefslogtreecommitdiffstats
path: root/main.c
diff options
context:
space:
mode:
authorTatsuya Kinoshita <tats@debian.org>2013-04-08 12:56:49 +0000
committerTatsuya Kinoshita <tats@debian.org>2013-04-08 12:56:49 +0000
commitf1d51e933e2a3b4dfb65d329d15bf782bd8f86bd (patch)
tree40091a2df83aa6b205265fd43cb5bb18b0cb6971 /main.c
parentMerge from upstream on 2012-05-22 (diff)
parentSupport SGR 1006 mouse reporting (diff)
downloadw3m-f1d51e933e2a3b4dfb65d329d15bf782bd8f86bd.tar.gz
w3m-f1d51e933e2a3b4dfb65d329d15bf782bd8f86bd.zip
Merge branch 'feature/sgrmouse'
Diffstat (limited to 'main.c')
-rw-r--r--main.c52
1 files changed, 52 insertions, 0 deletions
diff --git a/main.c b/main.c
index 7dcfd74..185ca55 100644
--- a/main.c
+++ b/main.c
@@ -5418,6 +5418,58 @@ DEFUN(mouse, MOUSE, "mouse operation")
process_mouse(btn, x, y);
}
+DEFUN(sgrmouse, SGRMOUSE, "SGR 1006 mouse operation")
+{
+ int btn = 0, x = 0, y = 0;
+ unsigned char c;
+
+ do {
+ c = getch();
+ if (IS_DIGIT(c))
+ btn = btn * 10 + c - '0';
+ else if (c == ';')
+ break;
+ else
+ return;
+ } while (1);
+
+#if defined(__CYGWIN__) && CYGWIN_VERSION_DLL_MAJOR < 1005
+ if (cygwin_mouse_btn_swapped) {
+ if (btn == MOUSE_BTN2_DOWN)
+ btn = MOUSE_BTN3_DOWN;
+ else if (btn == MOUSE_BTN3_DOWN)
+ btn = MOUSE_BTN2_DOWN;
+ };
+#endif
+
+ do {
+ c = getch();
+ if (IS_DIGIT(c))
+ x = x * 10 + c - '0';
+ else if (c == ';')
+ break;
+ else
+ return;
+ } while (1);
+
+ do {
+ c = getch();
+ if (IS_DIGIT(c))
+ y = y * 10 + c - '0';
+ else if (c == 'M')
+ break;
+ else if (c == 'm') {
+ btn |= 3;
+ break;
+ } else
+ return;
+ } while (1);
+
+ if (x < 0 || x >= COLS || y < 0 || y > LASTLINE)
+ return;
+ process_mouse(btn, x, y);
+}
+
#ifdef USE_GPM
int
gpm_process_mouse(Gpm_Event * event, void *data)