comparison src/mouse.c @ 18354:9f51d0cef8da v8.1.2171

patch 8.1.2171: mouse support not always available Commit: https://github.com/vim/vim/commit/a1cb1d1dce14dd005797590721f1bcd0e7c3b35f Author: Bram Moolenaar <Bram@vim.org> Date: Thu Oct 17 23:00:07 2019 +0200 patch 8.1.2171: mouse support not always available Problem: Mouse support not always available. Solution: Enable mouse support also in tiny version. Do not define FEAT_MOUSE_XTERM on MS-Windows (didn't really work).
author Bram Moolenaar <Bram@vim.org>
date Thu, 17 Oct 2019 23:15:04 +0200
parents 0ec6521e9d80
children 3cd689e9eb7f
comparison
equal deleted inserted replaced
18353:c3a0f5d3c9d4 18354:9f51d0cef8da
10 /* 10 /*
11 * mouse.c: mouse handling functions 11 * mouse.c: mouse handling functions
12 */ 12 */
13 13
14 #include "vim.h" 14 #include "vim.h"
15
16 #if defined(FEAT_MOUSE) || defined(PROTO)
17 15
18 /* 16 /*
19 * Get class of a character for selection: same class means same word. 17 * Get class of a character for selection: same class means same word.
20 * 0: blank 18 * 0: blank
21 * 1: punctuation groups 19 * 1: punctuation groups
1256 return mouse_table[i].pseudo_code; 1254 return mouse_table[i].pseudo_code;
1257 } 1255 }
1258 return (int)KE_IGNORE; // not recognized, ignore it 1256 return (int)KE_IGNORE; // not recognized, ignore it
1259 } 1257 }
1260 1258
1261 # ifdef FEAT_MOUSE_TTY 1259 # define HMT_NORMAL 1
1262 # define HMT_NORMAL 1 1260 # define HMT_NETTERM 2
1263 # define HMT_NETTERM 2 1261 # define HMT_DEC 4
1264 # define HMT_DEC 4 1262 # define HMT_JSBTERM 8
1265 # define HMT_JSBTERM 8 1263 # define HMT_PTERM 16
1266 # define HMT_PTERM 16 1264 # define HMT_URXVT 32
1267 # define HMT_URXVT 32 1265 # define HMT_GPM 64
1268 # define HMT_GPM 64 1266 # define HMT_SGR 128
1269 # define HMT_SGR 128 1267 # define HMT_SGR_REL 256
1270 # define HMT_SGR_REL 256
1271 static int has_mouse_termcode = 0; 1268 static int has_mouse_termcode = 0;
1272 # endif 1269
1273
1274 # if (!defined(UNIX) || defined(FEAT_MOUSE_TTY)) || defined(PROTO)
1275 void 1270 void
1276 set_mouse_termcode( 1271 set_mouse_termcode(
1277 int n, // KS_MOUSE, KS_NETTERM_MOUSE or KS_DEC_MOUSE 1272 int n, // KS_MOUSE, KS_NETTERM_MOUSE or KS_DEC_MOUSE
1278 char_u *s) 1273 char_u *s)
1279 { 1274 {
1280 char_u name[2]; 1275 char_u name[2];
1281 1276
1282 name[0] = n; 1277 name[0] = n;
1283 name[1] = KE_FILLER; 1278 name[1] = KE_FILLER;
1284 add_termcode(name, s, FALSE); 1279 add_termcode(name, s, FALSE);
1285 # ifdef FEAT_MOUSE_TTY
1286 # ifdef FEAT_MOUSE_JSB 1280 # ifdef FEAT_MOUSE_JSB
1287 if (n == KS_JSBTERM_MOUSE) 1281 if (n == KS_JSBTERM_MOUSE)
1288 has_mouse_termcode |= HMT_JSBTERM; 1282 has_mouse_termcode |= HMT_JSBTERM;
1289 else 1283 else
1290 # endif 1284 # endif
1317 has_mouse_termcode |= HMT_SGR; 1311 has_mouse_termcode |= HMT_SGR;
1318 else if (n == KS_SGR_MOUSE_RELEASE) 1312 else if (n == KS_SGR_MOUSE_RELEASE)
1319 has_mouse_termcode |= HMT_SGR_REL; 1313 has_mouse_termcode |= HMT_SGR_REL;
1320 else 1314 else
1321 has_mouse_termcode |= HMT_NORMAL; 1315 has_mouse_termcode |= HMT_NORMAL;
1322 # endif
1323 } 1316 }
1324 # endif 1317
1325 1318 # if defined(UNIX) || defined(VMS) || defined(PROTO)
1326 # if ((defined(UNIX) || defined(VMS)) \
1327 && defined(FEAT_MOUSE_TTY)) || defined(PROTO)
1328 void 1319 void
1329 del_mouse_termcode( 1320 del_mouse_termcode(
1330 int n) // KS_MOUSE, KS_NETTERM_MOUSE or KS_DEC_MOUSE 1321 int n) // KS_MOUSE, KS_NETTERM_MOUSE or KS_DEC_MOUSE
1331 { 1322 {
1332 char_u name[2]; 1323 char_u name[2];
1333 1324
1334 name[0] = n; 1325 name[0] = n;
1335 name[1] = KE_FILLER; 1326 name[1] = KE_FILLER;
1336 del_termcode(name); 1327 del_termcode(name);
1337 # ifdef FEAT_MOUSE_TTY
1338 # ifdef FEAT_MOUSE_JSB 1328 # ifdef FEAT_MOUSE_JSB
1339 if (n == KS_JSBTERM_MOUSE) 1329 if (n == KS_JSBTERM_MOUSE)
1340 has_mouse_termcode &= ~HMT_JSBTERM; 1330 has_mouse_termcode &= ~HMT_JSBTERM;
1341 else 1331 else
1342 # endif 1332 # endif
1369 has_mouse_termcode &= ~HMT_SGR; 1359 has_mouse_termcode &= ~HMT_SGR;
1370 else if (n == KS_SGR_MOUSE_RELEASE) 1360 else if (n == KS_SGR_MOUSE_RELEASE)
1371 has_mouse_termcode &= ~HMT_SGR_REL; 1361 has_mouse_termcode &= ~HMT_SGR_REL;
1372 else 1362 else
1373 has_mouse_termcode &= ~HMT_NORMAL; 1363 has_mouse_termcode &= ~HMT_NORMAL;
1374 # endif
1375 } 1364 }
1376 # endif 1365 # endif
1377 1366
1378 /* 1367 /*
1379 * setmouse() - switch mouse on/off depending on current mode and 'mouse' 1368 * setmouse() - switch mouse on/off depending on current mode and 'mouse'
1380 */ 1369 */
1381 void 1370 void
1382 setmouse(void) 1371 setmouse(void)
1383 { 1372 {
1384 # ifdef FEAT_MOUSE_TTY
1385 int checkfor; 1373 int checkfor;
1386 # endif
1387 1374
1388 # ifdef FEAT_MOUSESHAPE 1375 # ifdef FEAT_MOUSESHAPE
1389 update_mouseshape(-1); 1376 update_mouseshape(-1);
1390 # endif 1377 # endif
1391 1378
1392 # ifdef FEAT_MOUSE_TTY // Should be outside proc, but may break MOUSESHAPE 1379 // Should be outside proc, but may break MOUSESHAPE
1393 # ifdef FEAT_GUI 1380 # ifdef FEAT_GUI
1394 // In the GUI the mouse is always enabled. 1381 // In the GUI the mouse is always enabled.
1395 if (gui.in_use) 1382 if (gui.in_use)
1396 return; 1383 return;
1397 # endif 1384 # endif
1421 1408
1422 if (mouse_has(checkfor)) 1409 if (mouse_has(checkfor))
1423 mch_setmouse(TRUE); 1410 mch_setmouse(TRUE);
1424 else 1411 else
1425 mch_setmouse(FALSE); 1412 mch_setmouse(FALSE);
1426 # endif
1427 } 1413 }
1428 1414
1429 /* 1415 /*
1430 * Return TRUE if 1416 * Return TRUE if
1431 * - "c" is in 'mouse', or 1417 * - "c" is in 'mouse', or
2287 # ifdef FEAT_MOUSE_GPM 2273 # ifdef FEAT_MOUSE_GPM
2288 && key_name[0] != KS_GPM_MOUSE 2274 && key_name[0] != KS_GPM_MOUSE
2289 # endif 2275 # endif
2290 ) 2276 )
2291 { 2277 {
2292 # if defined(UNIX) && defined(FEAT_MOUSE_TTY) 2278 # if defined(UNIX)
2293 if (use_xterm_mouse() > 1 && mouse_code >= 0x80) 2279 if (use_xterm_mouse() > 1 && mouse_code >= 0x80)
2294 // mouse-move event, using MOUSE_DRAG works 2280 // mouse-move event, using MOUSE_DRAG works
2295 mouse_code = MOUSE_DRAG; 2281 mouse_code = MOUSE_DRAG;
2296 else 2282 else
2297 # endif 2283 # endif
2312 wheel_code = mouse_code - (mouse_code >= 0x40 ? 0x40 : 0x23) 2298 wheel_code = mouse_code - (mouse_code >= 0x40 ? 0x40 : 0x23)
2313 + MOUSEWHEEL_LOW; 2299 + MOUSEWHEEL_LOW;
2314 } 2300 }
2315 # endif 2301 # endif
2316 2302
2317 # if defined(UNIX) && defined(FEAT_MOUSE_TTY) 2303 # if defined(UNIX)
2318 else if (use_xterm_mouse() > 1) 2304 else if (use_xterm_mouse() > 1)
2319 { 2305 {
2320 if (mouse_code & MOUSE_DRAG_XTERM) 2306 if (mouse_code & MOUSE_DRAG_XTERM)
2321 mouse_code |= MOUSE_DRAG; 2307 mouse_code |= MOUSE_DRAG;
2322 } 2308 }
2808 if (mouse_row >= Rows) 2794 if (mouse_row >= Rows)
2809 mouse_row = Rows - 1; 2795 mouse_row = Rows - 1;
2810 2796
2811 return 0; 2797 return 0;
2812 } 2798 }
2813 #endif // FEAT_MOUSE
2814 2799
2815 // Functions also used for popup windows. 2800 // Functions also used for popup windows.
2816 #if defined(FEAT_MOUSE) || defined(FEAT_TEXT_PROP) || defined(PROTO)
2817 2801
2818 /* 2802 /*
2819 * Compute the buffer line position from the screen position "rowp" / "colp" in 2803 * Compute the buffer line position from the screen position "rowp" / "colp" in
2820 * window "win". 2804 * window "win".
2821 * "plines_cache" can be NULL (no cache) or an array with "win->w_height" 2805 * "plines_cache" can be NULL (no cache) or an array with "win->w_height"
3015 MB_PTR_ADV(ptr); 2999 MB_PTR_ADV(ptr);
3016 } 3000 }
3017 return (int)(ptr - line); 3001 return (int)(ptr - line);
3018 } 3002 }
3019 #endif 3003 #endif
3020
3021 #else // FEAT_MOUSE
3022
3023 /*
3024 * Dummy implementation of setmouse() to avoid lots of #ifdefs.
3025 */
3026 void
3027 setmouse(void)
3028 {
3029 }
3030
3031 #endif // FEAT_MOUSE