diff options
author | Tatsuya Kinoshita <tats@debian.org> | 2013-04-08 12:56:49 +0000 |
---|---|---|
committer | Tatsuya Kinoshita <tats@debian.org> | 2013-04-08 12:56:49 +0000 |
commit | f1d51e933e2a3b4dfb65d329d15bf782bd8f86bd (patch) | |
tree | 40091a2df83aa6b205265fd43cb5bb18b0cb6971 | |
parent | Merge from upstream on 2012-05-22 (diff) | |
parent | Support SGR 1006 mouse reporting (diff) | |
download | w3m-f1d51e933e2a3b4dfb65d329d15bf782bd8f86bd.tar.gz w3m-f1d51e933e2a3b4dfb65d329d15bf782bd8f86bd.zip |
Merge branch 'feature/sgrmouse'
-rw-r--r-- | keybind.c | 2 | ||||
-rw-r--r-- | main.c | 52 | ||||
-rw-r--r-- | proto.h | 1 | ||||
-rw-r--r-- | terms.c | 4 |
4 files changed, 56 insertions, 3 deletions
@@ -91,7 +91,7 @@ unsigned char EscBKeymap[128] = { /* 0 1 2 3 4 5 6 7 */ nulcmd, nulcmd, nulcmd, nulcmd, nulcmd, nulcmd, nulcmd, nulcmd, /* 8 9 : ; < = > ? */ - nulcmd, nulcmd, nulcmd, nulcmd, nulcmd, nulcmd, nulcmd, nulcmd, + nulcmd, nulcmd, nulcmd, nulcmd, sgrmouse, nulcmd, nulcmd, nulcmd, /* @ A B C D E F G */ nulcmd, movU, movD, movR, movL, nulcmd, goLineL, pgFore, /* H I J K L M N O */ @@ -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) @@ -685,6 +685,7 @@ extern void reMark(void); #ifdef USE_MOUSE extern void mouse(void); +extern void sgrmouse(void); extern void mouse_init(void); extern void mouse_end(void); extern void mouse_active(void); @@ -2027,8 +2027,8 @@ sleep_till_anykey(int sec, int purge) #ifdef USE_MOUSE -#define XTERM_ON {fputs("\033[?1001s\033[?1000h",ttyf); flush_tty();} -#define XTERM_OFF {fputs("\033[?1000l\033[?1001r",ttyf); flush_tty();} +#define XTERM_ON {fputs("\033[?1001s\033[?1000h\033[?1006h",ttyf); flush_tty();} +#define XTERM_OFF {fputs("\033[?1006l\033[?1000l\033[?1001r",ttyf); flush_tty();} #define CYGWIN_ON {fputs("\033[?1000h",ttyf); flush_tty();} #define CYGWIN_OFF {fputs("\033[?1000l",ttyf); flush_tty();} |