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/
This commit is contained in:
committed by
Tatsuya Kinoshita
parent
a558c94a9c
commit
30fdb96f39
46
menu.c
46
menu.c
@@ -57,6 +57,7 @@ static int mCancel(char c);
|
|||||||
static int mClose(char c);
|
static int mClose(char c);
|
||||||
static int mSusp(char c);
|
static int mSusp(char c);
|
||||||
static int mMouse(char c);
|
static int mMouse(char c);
|
||||||
|
static int mSgrMouse(char c);
|
||||||
static int mSrchF(char c);
|
static int mSrchF(char c);
|
||||||
static int mSrchB(char c);
|
static int mSrchB(char c);
|
||||||
static int mSrchN(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,
|
||||||
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 */
|
/* A B C D E */
|
||||||
mNull, mUp, mDown, mOk, mCancel,mClose, mNull, mNull,
|
mNull, mUp, mDown, mOk, mCancel,mClose, mNull, mNull,
|
||||||
/* L M */
|
/* L M */
|
||||||
@@ -1203,6 +1205,48 @@ mMouse(char c)
|
|||||||
return process_mMouse(btn, x, y);
|
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
|
#ifdef USE_GPM
|
||||||
static int
|
static int
|
||||||
gpm_process_menu_mouse(Gpm_Event * event, void *data)
|
gpm_process_menu_mouse(Gpm_Event * event, void *data)
|
||||||
|
Reference in New Issue
Block a user