aboutsummaryrefslogtreecommitdiffstats
path: root/menu.c
diff options
context:
space:
mode:
authorIWAMOTO Kouichi <sue@iwmt.org>2015-08-08 21:36:25 +0000
committerTatsuya Kinoshita <tats@debian.org>2015-08-08 21:36:25 +0000
commit30fdb96f39f9e4488a36e64205533f0a4fd05290 (patch)
tree18619dd4892e94d8ffff59dcfb1276f604955ca5 /menu.c
parentUpdate ChangeLog (diff)
downloadw3m-30fdb96f39f9e4488a36e64205533f0a4fd05290.tar.gz
w3m-30fdb96f39f9e4488a36e64205533f0a4fd05290.zip
Support SGR style mouse handler for menu
cf. https://github.com/tats/w3m/issues/5 Origin: https://gist.github.com/ttdoda/83fbcf676a21da28432b Bug: https://sourceforge.net/p/w3m/patches/65/
Diffstat (limited to '')
-rw-r--r--menu.c46
1 files changed, 45 insertions, 1 deletions
diff --git a/menu.c b/menu.c
index 0f66583..7c08703 100644
--- a/menu.c
+++ b/menu.c
@@ -57,6 +57,7 @@ static int mCancel(char c);
static int mClose(char c);
static int mSusp(char c);
static int mMouse(char c);
+static int mSgrMouse(char c);
static int mSrchF(char c);
static int mSrchB(char c);
static int mSrchN(char c);
@@ -137,7 +138,8 @@ static int (*MenuEscBKeymap[128]) (char c) = {
mNull, mNull, mNull, mNull, mNull, mNull, mNull, mNull,
mNull, mNull, mNull, mNull, mNull, mNull, mNull, mNull,
mNull, mNull, mNull, mNull, mNull, mNull, mNull, mNull,
- mNull, mNull, mNull, mNull, mNull, mNull, mNull, mNull,
+/* 8 9 : ; < = > ? */
+ mNull, mNull, mNull, mNull, mSgrMouse,mNull,mNull, mNull,
/* A B C D E */
mNull, mUp, mDown, mOk, mCancel,mClose, mNull, mNull,
/* L M */
@@ -1203,6 +1205,48 @@ mMouse(char c)
return process_mMouse(btn, x, y);
}
+static int
+mSgrMouse(char c)
+{
+ int btn = 0, x = 0, y = 0;
+ unsigned char ch;
+
+ for (ch = getch(); IS_DIGIT(ch); ch = getch())
+ btn = btn * 10 + ch - '0';
+ if (ch != ';')
+ return MENU_NOTHING;
+
+#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
+
+ for (ch = getch(); IS_DIGIT(ch); ch = getch())
+ x = x * 10 + ch - '0';
+ if (ch != ';')
+ return MENU_NOTHING;
+ if (x > 0)
+ x--;
+
+ for (ch = getch(); IS_DIGIT(ch); ch = getch())
+ y = y * 10 + ch - '0';
+ if (ch == 'm')
+ btn |= 3;
+ else if (ch != 'M' && ch != ';')
+ return MENU_NOTHING;
+ if (y > 0)
+ y--;
+
+ if (x < 0 || x >= COLS || y < 0 || y > LASTLINE)
+ return MENU_NOTHING;
+
+ return process_mMouse(btn, x, y);
+}
+
#ifdef USE_GPM
static int
gpm_process_menu_mouse(Gpm_Event * event, void *data)