To: vim-dev@vim.org Subject: Patch 5.6.028 Fcc: outbox From: Bram Moolenaar ------------ Patch 5.6.028 Problem: Xterm patch level 126 sends codes for mouse scroll wheel. Fully works with xterm patch level 131. Solution: Recognize the codes for button 4 (0x60) and button 5 (0x61). Files: src/term.c, src/vim.h *** ../vim-5.6.27/src/term.c Thu Mar 23 17:46:04 2000 --- src/term.c Thu Mar 23 17:24:41 2000 *************** *** 3344,3356 **** { /* * For xterm and MSDOS we get "scr", where ! * s == encoded button state (0x20 = left, 0x22 = right, etc.) * c == column + ' ' + 1 == column + 33 * r == row + ' ' + 1 == row + 33 * ! * The coordinates are passed on through global variables. Ugly, ! * but this avoids trouble with mouse clicks at an unexpected ! * moment and allows for mapping them. */ num_bytes = get_bytes_from_buf(tp + slen, bytes, 3); if (num_bytes == -1) /* not enough coordinates */ --- 3344,3366 ---- { /* * For xterm and MSDOS we get "scr", where ! * s == encoded button state: ! * 0x20 = left button down ! * 0x21 = middle button down ! * 0x22 = right button down ! * 0x23 = any button release ! * 0x60 = button 4 down (scroll wheel down) ! * 0x61 = button 5 down (scroll wheel up) ! * add 0x04 for SHIFT ! * add 0x08 for ALT ! * add 0x10 for CTRL ! * add 0x20 for mouse drag (0x40 is drag with left button) * c == column + ' ' + 1 == column + 33 * r == row + ' ' + 1 == row + 33 * ! * The coordinates are passed on through global variables. ! * Ugly, but this avoids trouble with mouse clicks at an ! * unexpected moment and allows for mapping them. */ num_bytes = get_bytes_from_buf(tp + slen, bytes, 3); if (num_bytes == -1) /* not enough coordinates */ *************** *** 3359,3375 **** mouse_col = bytes[1] - ' ' - 1; mouse_row = bytes[2] - ' ' - 1; slen += num_bytes; # ifdef UNIX if (use_xterm_mouse() > 1) { ! if (mouse_code & MOUSE_DRAG_XTERM) mouse_code |= MOUSE_DRAG; } # endif # ifdef XTERM_CLIP else { ! if (!(mouse_code & MOUSE_DRAG & ~MOUSE_CLICK_MASK)) { if ((mouse_code & MOUSE_RELEASE) == MOUSE_RELEASE) stop_xterm_trace(); --- 3369,3391 ---- mouse_col = bytes[1] - ' ' - 1; mouse_row = bytes[2] - ' ' - 1; slen += num_bytes; + + /* + * Handle mouse events other than using the mouse wheel. + */ # ifdef UNIX if (use_xterm_mouse() > 1) { ! if ((mouse_code & MOUSE_DRAG_XTERM) ! && mouse_code < MOUSEWHEEL_LOW) mouse_code |= MOUSE_DRAG; } # endif # ifdef XTERM_CLIP else { ! if (!(mouse_code & MOUSE_DRAG & ~MOUSE_CLICK_MASK) ! && mouse_code < MOUSEWHEEL_LOW) { if ((mouse_code & MOUSE_RELEASE) == MOUSE_RELEASE) stop_xterm_trace(); *************** *** 3558,3564 **** is_drag = TRUE; current_button = held_button; } ! else { # if defined(UNIX) && defined(HAVE_GETTIMEOFDAY) && defined(HAVE_SYS_TIME_H) # ifdef GPM_MOUSE --- 3574,3580 ---- is_drag = TRUE; current_button = held_button; } ! else if (mouse_code < MOUSEWHEEL_LOW) { # if defined(UNIX) && defined(HAVE_GETTIMEOFDAY) && defined(HAVE_SYS_TIME_H) # ifdef GPM_MOUSE *************** *** 3643,3649 **** /* Work out our pseudo mouse event */ key_name[0] = (int)KS_EXTRA; ! key_name[1] = get_pseudo_mouse_code(current_button, is_click, is_drag); } #endif /* USE_MOUSE */ --- 3659,3668 ---- /* Work out our pseudo mouse event */ key_name[0] = (int)KS_EXTRA; ! if (mouse_code >= MOUSEWHEEL_LOW) ! key_name[1] = (mouse_code & 1) ? KE_MOUSEUP : KE_MOUSEDOWN; ! else ! key_name[1] = get_pseudo_mouse_code(current_button, is_click, is_drag); } #endif /* USE_MOUSE */ *** ../vim-5.6.27/src/vim.h Tue Jan 11 16:20:58 2000 --- src/vim.h Thu Feb 10 20:13:06 2000 *************** *** 886,901 **** #ifdef USE_MOUSE ! /* Codes for mouse event */ # define MOUSE_LEFT 0x00 # define MOUSE_MIDDLE 0x01 # define MOUSE_RIGHT 0x02 # define MOUSE_RELEASE 0x03 # define MOUSE_SHIFT 0x04 # define MOUSE_ALT 0x08 # define MOUSE_CTRL 0x10 ! /* mouse buttons that are handled like a key press */ # define MOUSE_4 0x100 /* scroll wheel down */ # define MOUSE_5 0x200 /* scroll wheel up */ --- 886,903 ---- #ifdef USE_MOUSE ! /* Codes for mouse button events in lower three bits: */ # define MOUSE_LEFT 0x00 # define MOUSE_MIDDLE 0x01 # define MOUSE_RIGHT 0x02 # define MOUSE_RELEASE 0x03 + + /* bit masks for modifiers: */ # define MOUSE_SHIFT 0x04 # define MOUSE_ALT 0x08 # define MOUSE_CTRL 0x10 ! /* mouse buttons that are handled like a key press (GUI only) */ # define MOUSE_4 0x100 /* scroll wheel down */ # define MOUSE_5 0x200 /* scroll wheel up */ *************** *** 904,910 **** # define MOUSE_DRAG (0x40 | MOUSE_RELEASE) ! # define MOUSE_CLICK_MASK 0x03 # define NUM_MOUSE_CLICKS(code) \ (((unsigned)((code) & 0xC0) >> 6) + 1) --- 906,915 ---- # define MOUSE_DRAG (0x40 | MOUSE_RELEASE) ! /* Lowest button code for using the mouse wheel (xterm only) */ ! # define MOUSEWHEEL_LOW 0x60 ! ! # define MOUSE_CLICK_MASK 0x03 # define NUM_MOUSE_CLICKS(code) \ (((unsigned)((code) & 0xC0) >> 6) + 1) *** ../vim-5.6.27/src/version.c Sat Mar 25 20:32:21 2000 --- src/version.c Sat Mar 25 20:33:17 2000 *************** *** 420,421 **** --- 420,423 ---- { /* Add new patch number below this line */ + /**/ + 28, /**/ -- Eight Megabytes And Continually Swapping. /-/-- Bram Moolenaar --- Bram@moolenaar.net --- http://www.moolenaar.net --\-\ \-\-- Vim: http://www.vim.org ---- ICCF Holland: http://www.vim.org/iccf --/-/