To: vim-dev@vim.org Subject: Patch 6.1.184 (extra) Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit ------------ Patch 6.1.184 (extra) Problem: The extra mouse buttons found on some mice don't work. Solution: Support two extra buttons for MS-Windows. (Michael Geddes) Files: runtime/doc/term.txt, src/edit.c, src/ex_getln.c, src/gui.c, src/gui_w32.c, src/gui_w48.c, src/keymap.h, src/message.c, src/misc1.c, src/misc2.c, src/normal.c. src/vim.h *** ../vim61.183/runtime/doc/term.txt Fri Mar 22 21:18:39 2002 --- runtime/doc/term.txt Thu Sep 5 22:13:30 2002 *************** *** 759,764 **** --- 760,775 ---- right pressed extend selection right moved while pressed extend selection right released set selection end + X1 button pressed - *X1Mouse* + X1 moved while pressed - *X1Drag* + X1 button release - *X1Release* + X2 button pressed - *X2Mouse* + X2 moved while pressed - *X2Drag* + X2 button release - *X2Release* + + The X1 and X2 buttons refer to the extra buttons found on some mice. The + 'Microsoft Explorer' mouse has these buttons available to the right thumb. + Currently X1 and X2 only work on Win32 environments. Examples: > :noremap *************** *** 769,774 **** --- 780,790 ---- Immediately yank the selection, when using Visual mode. Note the use of ":noremap" instead of "map" to avoid a recursive mapping. + > + :map + :map + Map the X1 and X2 buttons to go forward and backwards in the jump list, see + |CTRL-O| and |CTRL-I|. *mouse-swap-buttons* To swap the meaning of the left and right mouse buttons: > *** ../vim61.183/src/edit.c Mon Sep 16 21:26:10 2002 --- src/edit.c Tue Sep 10 19:47:16 2002 *************** *** 966,971 **** --- 966,977 ---- case K_RIGHTMOUSE: case K_RIGHTDRAG: case K_RIGHTRELEASE: + case K_X1MOUSE: + case K_X1DRAG: + case K_X1RELEASE: + case K_X2MOUSE: + case K_X2DRAG: + case K_X2RELEASE: ins_mouse(c); break; *** ../vim61.183/src/ex_getln.c Sat Sep 7 15:05:56 2002 --- src/ex_getln.c Sat Sep 7 14:58:21 2002 *************** *** 1094,1099 **** --- 1095,1107 ---- /* Mouse scroll wheel: ignored here */ case K_MOUSEDOWN: case K_MOUSEUP: + /* Alternate buttons ignored here */ + case K_X1MOUSE: + case K_X1DRAG: + case K_X1RELEASE: + case K_X2MOUSE: + case K_X2DRAG: + case K_X2RELEASE: goto cmdline_not_changed; #endif /* FEAT_MOUSE */ *** ../vim61.183/src/gui.c Mon Sep 16 21:12:28 2002 --- src/gui.c Sat Sep 14 14:35:35 2002 *************** *** 2437,2442 **** --- 2443,2449 ---- * Generic mouse support function. Add a mouse event to the input buffer with * the given properties. * button --- may be any of MOUSE_LEFT, MOUSE_MIDDLE, MOUSE_RIGHT, + * MOUSE_X1, MOUSE_X2 * MOUSE_DRAG, or MOUSE_RELEASE. * MOUSE_4 and MOUSE_5 are used for a scroll wheel. * x, y --- Coordinates of mouse in pixels. *************** *** 2459,2464 **** --- 2466,2472 ---- static int prev_button = -1; static int num_clicks = 1; char_u string[6]; + char_u button_char; int row, col; #ifdef FEAT_CLIPBOARD int checkfor; *************** *** 2468,2498 **** /* * Scrolling may happen at any time, also while a selection is present. */ ! if (button == MOUSE_4 || button == MOUSE_5) { ! /* Don't put events in the input queue now. */ ! if (hold_gui_events) ! return; ! ! string[3] = CSI; ! string[4] = KS_EXTRA; ! string[5] = (int)(button == MOUSE_4 ? KE_MOUSEDOWN : KE_MOUSEUP); ! if (modifiers == 0) ! add_to_input_buf(string + 3, 3); ! else ! { ! string[0] = CSI; ! string[1] = KS_MODIFIER; ! string[2] = 0; ! if (modifiers & MOUSE_SHIFT) ! string[2] |= MOD_MASK_SHIFT; ! if (modifiers & MOUSE_CTRL) ! string[2] |= MOD_MASK_CTRL; ! if (modifiers & MOUSE_ALT) ! string[2] |= MOD_MASK_ALT; ! add_to_input_buf(string, 6); ! } ! return; } #ifdef FEAT_CLIPBOARD --- 2476,2520 ---- /* * Scrolling may happen at any time, also while a selection is present. */ ! switch (button) { ! case MOUSE_X1: ! button_char = KE_X1MOUSE; ! goto button_set; ! case MOUSE_X2: ! button_char = KE_X2MOUSE; ! goto button_set; ! case MOUSE_4: ! button_char = KE_MOUSEDOWN; ! goto button_set; ! case MOUSE_5: ! button_char = KE_MOUSEUP; ! button_set: ! { ! /* Don't put events in the input queue now. */ ! if (hold_gui_events) ! return; ! ! string[3] = CSI; ! string[4] = KS_EXTRA; ! string[5] = button_char; ! if (modifiers == 0) ! add_to_input_buf(string + 3, 3); ! else ! { ! string[0] = CSI; ! string[1] = KS_MODIFIER; ! string[2] = 0; ! if (modifiers & MOUSE_SHIFT) ! string[2] |= MOD_MASK_SHIFT; ! if (modifiers & MOUSE_CTRL) ! string[2] |= MOD_MASK_CTRL; ! if (modifiers & MOUSE_ALT) ! string[2] |= MOD_MASK_ALT; ! add_to_input_buf(string, 6); ! } ! return; ! } } #ifdef FEAT_CLIPBOARD *** ../vim61.183/src/gui_w32.c Sun Aug 4 20:56:30 2002 --- src/gui_w32.c Fri Sep 6 21:51:31 2002 *************** *** 24,29 **** --- 24,45 ---- */ /* + * These are new in Windows ME/XP, only defined in recent compilers. + */ + #ifndef HANDLE_WM_XBUTTONUP + # define HANDLE_WM_XBUTTONUP(hwnd, wParam, lParam, fn) \ + ((fn)((hwnd), (int)(short)LOWORD(lParam), (int)(short)HIWORD(lParam), (UINT)(wParam)), 0L) + #endif + #ifndef HANDLE_WM_XBUTTONDOWN + # define HANDLE_WM_XBUTTONDOWN(hwnd, wParam, lParam, fn) \ + ((fn)((hwnd), FALSE, (int)(short)LOWORD(lParam), (int)(short)HIWORD(lParam), (UINT)(wParam)), 0L) + #endif + #ifndef HANDLE_WM_XBUTTONDBLCLK + # define HANDLE_WM_XBUTTONDBLCLK(hwnd, wParam, lParam, fn) \ + ((fn)((hwnd), TRUE, (int)(short)LOWORD(lParam), (int)(short)HIWORD(lParam), (UINT)(wParam)), 0L) + #endif + + /* * Include the common stuff for MS-Windows GUI. */ #include "gui_w48.c" *** ../vim61.183/src/gui_w48.c Sun Jun 9 20:34:00 2002 --- src/gui_w48.c Fri Sep 6 21:49:30 2002 *************** *** 64,69 **** --- 64,77 ---- #define DLG_NONBUTTON_CONTROL 5000 /* First ID of non-button controls */ + #ifndef WM_XBUTTONDOWN // For Win2K / winME ONLY + # define WM_XBUTTONDOWN 0x020B + # define WM_XBUTTONUP 0x020C + # define WM_XBUTTONDBLCLK 0x020D + # define MK_XBUTTON1 0x0020 + # define MK_XBUTTON2 0x0040 + #endif + #ifdef PROTO /* * Define a few things for generating prototypes. This is just to avoid *************** *** 610,615 **** --- 618,630 ---- else if (s_uMsg == WM_RBUTTONDOWN || s_uMsg == WM_RBUTTONDBLCLK) button = MOUSE_RIGHT; #ifndef WIN16 // + else if (s_uMsg == WM_XBUTTONDOWN || s_uMsg == WM_XBUTTONDBLCLK) + { + #ifndef GET_XBUTTON_WPARAM + # define GET_XBUTTON_WPARAM(wParam) (HIWORD(wParam)) + #endif + button = ((GET_XBUTTON_WPARAM(s_wParam) == 1) ? MOUSE_X1 : MOUSE_X2); + } else if (s_uMsg == WM_CAPTURECHANGED) { /* on W95/NT4, somehow you get in here with an odd Msg *************** *** 700,706 **** * It's only a MOUSE_DRAG if one or more mouse buttons are being held * down. */ ! if (!(keyFlags & (MK_LBUTTON | MK_MBUTTON | MK_RBUTTON))) { gui_mouse_moved(x, y); return; --- 715,722 ---- * It's only a MOUSE_DRAG if one or more mouse buttons are being held * down. */ ! if (!(keyFlags & (MK_LBUTTON | MK_MBUTTON | MK_RBUTTON ! | MK_XBUTTON1 | MK_XBUTTON2))) { gui_mouse_moved(x, y); return; *************** *** 851,856 **** --- 867,874 ---- case WM_MBUTTONUP: case WM_RBUTTONDOWN: case WM_RBUTTONUP: + case WM_XBUTTONDOWN: + case WM_XBUTTONUP: case WM_NCMOUSEMOVE: case WM_NCLBUTTONDOWN: case WM_NCLBUTTONUP: *************** *** 898,903 **** --- 916,924 ---- HANDLE_MSG(hwnd, WM_RBUTTONDBLCLK,_OnMouseButtonDown); HANDLE_MSG(hwnd, WM_RBUTTONDOWN,_OnMouseButtonDown); HANDLE_MSG(hwnd, WM_RBUTTONUP, _OnMouseMoveOrRelease); + HANDLE_MSG(hwnd, WM_XBUTTONDBLCLK,_OnMouseButtonDown); + HANDLE_MSG(hwnd, WM_XBUTTONDOWN,_OnMouseButtonDown); + HANDLE_MSG(hwnd, WM_XBUTTONUP, _OnMouseMoveOrRelease); default: return DefWindowProc(hwnd, uMsg, wParam, lParam); *** ../vim61.183/src/keymap.h Sat Aug 4 14:47:07 2001 --- src/keymap.h Thu Sep 5 22:23:14 2002 *************** *** 228,233 **** --- 228,240 ---- , KE_C_RIGHT /* control-right */ , KE_C_HOME /* control-home */ , KE_C_END /* control-end */ + + , KE_X1MOUSE /* X1/X2 mouse-buttons */ + , KE_X1DRAG + , KE_X1RELEASE + , KE_X2MOUSE + , KE_X2DRAG + , KE_X2RELEASE }; /* *************** *** 258,263 **** --- 265,276 ---- #define K_XF3 TERMCAP2KEY(KS_EXTRA, KE_XF3) #define K_XF4 TERMCAP2KEY(KS_EXTRA, KE_XF4) + /* extra set of function keys F1-F4, for vt100 compatible xterm */ + #define K_XF1 TERMCAP2KEY(KS_EXTRA, KE_XF1) + #define K_XF2 TERMCAP2KEY(KS_EXTRA, KE_XF2) + #define K_XF3 TERMCAP2KEY(KS_EXTRA, KE_XF3) + #define K_XF4 TERMCAP2KEY(KS_EXTRA, KE_XF4) + #define K_F1 TERMCAP2KEY('k', '1') /* function keys */ #define K_F2 TERMCAP2KEY('k', '2') #define K_F3 TERMCAP2KEY('k', '3') *************** *** 419,424 **** --- 432,444 ---- #define K_RIGHTMOUSE TERMCAP2KEY(KS_EXTRA, KE_RIGHTMOUSE) #define K_RIGHTDRAG TERMCAP2KEY(KS_EXTRA, KE_RIGHTDRAG) #define K_RIGHTRELEASE TERMCAP2KEY(KS_EXTRA, KE_RIGHTRELEASE) + #define K_X1MOUSE TERMCAP2KEY(KS_EXTRA, KE_X1MOUSE) + #define K_X1MOUSE TERMCAP2KEY(KS_EXTRA, KE_X1MOUSE) + #define K_X1DRAG TERMCAP2KEY(KS_EXTRA, KE_X1DRAG) + #define K_X1RELEASE TERMCAP2KEY(KS_EXTRA, KE_X1RELEASE) + #define K_X2MOUSE TERMCAP2KEY(KS_EXTRA, KE_X2MOUSE) + #define K_X2DRAG TERMCAP2KEY(KS_EXTRA, KE_X2DRAG) + #define K_X2RELEASE TERMCAP2KEY(KS_EXTRA, KE_X2RELEASE) #define K_IGNORE TERMCAP2KEY(KS_EXTRA, KE_IGNORE) *** ../vim61.183/src/message.c Fri Aug 30 22:25:09 2002 --- src/message.c Thu Sep 5 22:17:32 2002 *************** *** 802,808 **** && mouse_row != Rows - 1 && (c == K_LEFTMOUSE || c == K_MIDDLEMOUSE ! || c == K_RIGHTMOUSE)) #endif ); ui_breakcheck(); --- 802,810 ---- && mouse_row != Rows - 1 && (c == K_LEFTMOUSE || c == K_MIDDLEMOUSE ! || c == K_RIGHTMOUSE ! || c == K_X1MOUSE ! || c == K_X2MOUSE)) #endif ); ui_breakcheck(); *************** *** 810,816 **** /* * Avoid that the mouse-up event causes visual mode to start. */ ! if (c == K_LEFTMOUSE || c == K_MIDDLEMOUSE || c == K_RIGHTMOUSE) (void)jump_to_mouse(MOUSE_SETPOS, NULL, 0); else #endif --- 812,818 ---- /* * Avoid that the mouse-up event causes visual mode to start. */ ! if (c == K_LEFTMOUSE || c == K_MIDDLEMOUSE || c == K_RIGHTMOUSE || c== K_X1MOUSE || c == K_X2MOUSE) (void)jump_to_mouse(MOUSE_SETPOS, NULL, 0); else #endif *** ../vim61.183/src/misc1.c Fri Aug 30 22:36:15 2002 --- src/misc1.c Thu Sep 5 22:21:17 2002 *************** *** 2599,2604 **** --- 2599,2610 ---- || n == K_RIGHTRELEASE || n == K_MOUSEDOWN || n == K_MOUSEUP + || n == K_X1MOUSE + || n == K_X1DRAG + || n == K_X1RELEASE + || n == K_X2MOUSE + || n == K_X2DRAG + || n == K_X2RELEASE # ifdef FEAT_GUI || n == K_VER_SCROLLBAR || n == K_HOR_SCROLLBAR *** ../vim61.183/src/misc2.c Sun Jul 21 20:30:31 2002 --- src/misc2.c Thu Sep 5 22:23:46 2002 *************** *** 1870,1875 **** --- 1870,1881 ---- {K_RIGHTRELEASE, (char_u *)"RightRelease"}, {K_MOUSEDOWN, (char_u *)"MouseDown"}, {K_MOUSEUP, (char_u *)"MouseUp"}, + {K_X1MOUSE, (char_u *)"X1Mouse"}, + {K_X1DRAG, (char_u *)"X1Drag"}, + {K_X1RELEASE, (char_u *)"X1Release"}, + {K_X2MOUSE, (char_u *)"X2Mouse"}, + {K_X2DRAG, (char_u *)"X2Drag"}, + {K_X2RELEASE, (char_u *)"X2Release"}, {K_ZERO, (char_u *)"Nul"}, #ifdef FEAT_EVAL {K_SNR, (char_u *)"SNR"}, *************** *** 1904,1909 **** --- 1910,1921 ---- {(int)KE_RIGHTMOUSE, MOUSE_RIGHT, TRUE, FALSE}, {(int)KE_RIGHTDRAG, MOUSE_RIGHT, FALSE, TRUE}, {(int)KE_RIGHTRELEASE, MOUSE_RIGHT, FALSE, FALSE}, + {(int)KE_X1MOUSE, MOUSE_X1, TRUE, FALSE}, + {(int)KE_X1DRAG, MOUSE_X1, FALSE, TRUE}, + {(int)KE_X1RELEASE, MOUSE_X1, FALSE, FALSE}, + {(int)KE_X2MOUSE, MOUSE_X2, TRUE, FALSE}, + {(int)KE_X2DRAG, MOUSE_X2, FALSE, TRUE}, + {(int)KE_X2RELEASE, MOUSE_X2, FALSE, FALSE}, /* DRAG without CLICK */ {(int)KE_IGNORE, MOUSE_RELEASE, FALSE, TRUE}, /* RELEASE without CLICK */ *** ../vim61.183/src/normal.c Sat Sep 14 17:08:10 2002 --- src/normal.c Fri Sep 6 21:43:53 2002 *************** *** 358,363 **** --- 358,369 ---- {K_RIGHTMOUSE, nv_mouse, 0, 0}, {K_RIGHTDRAG, nv_mouse, 0, 0}, {K_RIGHTRELEASE, nv_mouse, 0, 0}, + {K_X1MOUSE, nv_mouse, 0, 0}, + {K_X1DRAG, nv_mouse, 0, 0}, + {K_X1RELEASE, nv_mouse, 0, 0}, + {K_X2MOUSE, nv_mouse, 0, 0}, + {K_X2DRAG, nv_mouse, 0, 0}, + {K_X2RELEASE, nv_mouse, 0, 0}, #endif {K_IGNORE, nv_ignore, 0, 0}, {K_INS, nv_edit, 0, 0}, *************** *** 3304,3309 **** --- 3310,3316 ---- K_MIDDLEMOUSE, K_MIDDLEDRAG, K_MIDDLERELEASE, K_RIGHTMOUSE, K_RIGHTDRAG, K_RIGHTRELEASE, K_MOUSEDOWN, K_MOUSEUP, + K_X1MOUSE, K_X1DRAG, K_X1RELEASE, K_X2MOUSE, K_X2DRAG, K_X2RELEASE, 0 }; #endif *************** *** 7081,7086 **** --- 7088,7099 ---- case K_RIGHTMOUSE: case K_RIGHTDRAG: case K_RIGHTRELEASE: + case K_X1MOUSE: + case K_X1DRAG: + case K_X1RELEASE: + case K_X2MOUSE: + case K_X2DRAG: + case K_X2RELEASE: mod_mask = MOD_MASK_CTRL; (void)do_mouse(oap, cap->nchar, BACKWARD, cap->count1, 0); break; *** ../vim61.183/src/vim.h Sun Jul 28 22:02:42 2002 --- src/vim.h Thu Sep 5 22:24:39 2002 *************** *** 1344,1349 **** --- 1344,1352 ---- # define MOUSE_4 0x100 /* scroll wheel down */ # define MOUSE_5 0x200 /* scroll wheel up */ + # define MOUSE_X1 0x300 /* Mouse-button X1 (6th) */ + # define MOUSE_X2 0x400 /* Mouse-button X2 */ + /* 0x20 is reserved by xterm */ # define MOUSE_DRAG_XTERM 0x40 *** ../vim61.183/src/version.c Mon Sep 16 21:53:32 2002 --- src/version.c Mon Sep 16 21:55:54 2002 *************** *** 608,609 **** --- 608,611 ---- { /* Add new patch number below this line */ + /**/ + 184, /**/ -- Our job was to build a computer information system for the branch banks. We were the perfect people for the job: Dean had seen a computer once, and I had heard Dean talk about it. (Scott Adams - The Dilbert principle) /// Bram Moolenaar -- Bram@moolenaar.net -- http://www.moolenaar.net \\\ /// Creator of Vim - Vi IMproved -- http://www.vim.org \\\ \\\ Project leader for A-A-P -- http://www.a-a-p.org /// \\\ Lord Of The Rings helps Uganda - http://iccf-holland.org/lotr.html ///