Mercurial > vim
comparison src/mouse.c @ 28773:d770568e6c98 v8.2.4911
patch 8.2.4911: the mode #defines are not clearly named
Commit: https://github.com/vim/vim/commit/249591057b4840785c50e41dd850efb8a8faf435
Author: Bram Moolenaar <Bram@vim.org>
Date: Sat May 7 20:01:16 2022 +0100
patch 8.2.4911: the mode #defines are not clearly named
Problem: The mode #defines are not clearly named.
Solution: Prepend MODE_. Renumber them to put the mapped modes first.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sat, 07 May 2022 21:15:06 +0200 |
parents | 26a2836923d6 |
children | d0241e74bfdb |
comparison
equal
deleted
inserted
replaced
28772:7b07ca0bb292 | 28773:d770568e6c98 |
---|---|
267 if (VIsual_active) | 267 if (VIsual_active) |
268 { | 268 { |
269 if (!mouse_has(MOUSE_VISUAL)) | 269 if (!mouse_has(MOUSE_VISUAL)) |
270 return FALSE; | 270 return FALSE; |
271 } | 271 } |
272 else if (State == NORMAL && !mouse_has(MOUSE_NORMAL)) | 272 else if (State == MODE_NORMAL && !mouse_has(MOUSE_NORMAL)) |
273 return FALSE; | 273 return FALSE; |
274 } | 274 } |
275 | 275 |
276 for (;;) | 276 for (;;) |
277 { | 277 { |
353 } | 353 } |
354 | 354 |
355 // CTRL right mouse button does CTRL-T | 355 // CTRL right mouse button does CTRL-T |
356 if (is_click && (mod_mask & MOD_MASK_CTRL) && which_button == MOUSE_RIGHT) | 356 if (is_click && (mod_mask & MOD_MASK_CTRL) && which_button == MOUSE_RIGHT) |
357 { | 357 { |
358 if (State & INSERT) | 358 if (State & MODE_INSERT) |
359 stuffcharReadbuff(Ctrl_O); | 359 stuffcharReadbuff(Ctrl_O); |
360 if (count > 1) | 360 if (count > 1) |
361 stuffnumReadbuff(count); | 361 stuffnumReadbuff(count); |
362 stuffcharReadbuff(Ctrl_T); | 362 stuffcharReadbuff(Ctrl_T); |
363 got_click = FALSE; // ignore drag&release now | 363 got_click = FALSE; // ignore drag&release now |
397 regname = 0; | 397 regname = 0; |
398 | 398 |
399 // Middle mouse button does a 'put' of the selected text | 399 // Middle mouse button does a 'put' of the selected text |
400 if (which_button == MOUSE_MIDDLE) | 400 if (which_button == MOUSE_MIDDLE) |
401 { | 401 { |
402 if (State == NORMAL) | 402 if (State == MODE_NORMAL) |
403 { | 403 { |
404 // If an operator was pending, we don't know what the user wanted | 404 // If an operator was pending, we don't know what the user wanted |
405 // to do. Go back to normal mode: Clear the operator and beep(). | 405 // to do. Go back to normal mode: Clear the operator and beep(). |
406 if (oap != NULL && oap->op_type != OP_NOP) | 406 if (oap != NULL && oap->op_type != OP_NOP) |
407 { | 407 { |
428 return FALSE; | 428 return FALSE; |
429 } | 429 } |
430 // The rest is below jump_to_mouse() | 430 // The rest is below jump_to_mouse() |
431 } | 431 } |
432 | 432 |
433 else if ((State & INSERT) == 0) | 433 else if ((State & MODE_INSERT) == 0) |
434 return FALSE; | 434 return FALSE; |
435 | 435 |
436 // Middle click in insert mode doesn't move the mouse, just insert the | 436 // Middle click in insert mode doesn't move the mouse, just insert the |
437 // contents of a register. '.' register is special, can't insert that | 437 // contents of a register. '.' register is special, can't insert that |
438 // with do_put(). | 438 // with do_put(). |
439 // Also paste at the cursor if the current mode isn't in 'mouse' (only | 439 // Also paste at the cursor if the current mode isn't in 'mouse' (only |
440 // happens for the GUI). | 440 // happens for the GUI). |
441 if ((State & INSERT) || !mouse_has(MOUSE_NORMAL)) | 441 if ((State & MODE_INSERT) || !mouse_has(MOUSE_NORMAL)) |
442 { | 442 { |
443 if (regname == '.') | 443 if (regname == '.') |
444 insert_reg(regname, TRUE); | 444 insert_reg(regname, TRUE); |
445 else | 445 else |
446 { | 446 { |
643 which_button = MOUSE_RIGHT; | 643 which_button = MOUSE_RIGHT; |
644 mod_mask &= ~MOD_MASK_SHIFT; | 644 mod_mask &= ~MOD_MASK_SHIFT; |
645 } | 645 } |
646 } | 646 } |
647 | 647 |
648 if ((State & (NORMAL | INSERT)) | 648 if ((State & (MODE_NORMAL | MODE_INSERT)) |
649 && !(mod_mask & (MOD_MASK_SHIFT | MOD_MASK_CTRL))) | 649 && !(mod_mask & (MOD_MASK_SHIFT | MOD_MASK_CTRL))) |
650 { | 650 { |
651 if (which_button == MOUSE_LEFT) | 651 if (which_button == MOUSE_LEFT) |
652 { | 652 { |
653 if (is_click) | 653 if (is_click) |
836 } | 836 } |
837 } | 837 } |
838 } | 838 } |
839 } | 839 } |
840 // If Visual mode started in insert mode, execute "CTRL-O" | 840 // If Visual mode started in insert mode, execute "CTRL-O" |
841 else if ((State & INSERT) && VIsual_active) | 841 else if ((State & MODE_INSERT) && VIsual_active) |
842 stuffcharReadbuff(Ctrl_O); | 842 stuffcharReadbuff(Ctrl_O); |
843 | 843 |
844 // Middle mouse click: Put text before cursor. | 844 // Middle mouse click: Put text before cursor. |
845 if (which_button == MOUSE_MIDDLE) | 845 if (which_button == MOUSE_MIDDLE) |
846 { | 846 { |
893 // Ctrl-Mouse click (or double click in a help window) jumps to the tag | 893 // Ctrl-Mouse click (or double click in a help window) jumps to the tag |
894 // under the mouse pointer. | 894 // under the mouse pointer. |
895 else if ((mod_mask & MOD_MASK_CTRL) || (curbuf->b_help | 895 else if ((mod_mask & MOD_MASK_CTRL) || (curbuf->b_help |
896 && (mod_mask & MOD_MASK_MULTI_CLICK) == MOD_MASK_2CLICK)) | 896 && (mod_mask & MOD_MASK_MULTI_CLICK) == MOD_MASK_2CLICK)) |
897 { | 897 { |
898 if (State & INSERT) | 898 if (State & MODE_INSERT) |
899 stuffcharReadbuff(Ctrl_O); | 899 stuffcharReadbuff(Ctrl_O); |
900 stuffcharReadbuff(Ctrl_RSB); | 900 stuffcharReadbuff(Ctrl_RSB); |
901 got_click = FALSE; // ignore drag&release now | 901 got_click = FALSE; // ignore drag&release now |
902 } | 902 } |
903 | 903 |
904 // Shift-Mouse click searches for the next occurrence of the word under | 904 // Shift-Mouse click searches for the next occurrence of the word under |
905 // the mouse pointer | 905 // the mouse pointer |
906 else if ((mod_mask & MOD_MASK_SHIFT)) | 906 else if ((mod_mask & MOD_MASK_SHIFT)) |
907 { | 907 { |
908 if ((State & INSERT) || (VIsual_active && VIsual_select)) | 908 if ((State & MODE_INSERT) || (VIsual_active && VIsual_select)) |
909 stuffcharReadbuff(Ctrl_O); | 909 stuffcharReadbuff(Ctrl_O); |
910 if (which_button == MOUSE_LEFT) | 910 if (which_button == MOUSE_LEFT) |
911 stuffcharReadbuff('*'); | 911 stuffcharReadbuff('*'); |
912 else // MOUSE_RIGHT | 912 else // MOUSE_RIGHT |
913 stuffcharReadbuff('#'); | 913 stuffcharReadbuff('#'); |
932 drag_sep_line = TRUE; | 932 drag_sep_line = TRUE; |
933 update_mouseshape(-1); | 933 update_mouseshape(-1); |
934 } | 934 } |
935 #endif | 935 #endif |
936 } | 936 } |
937 else if ((mod_mask & MOD_MASK_MULTI_CLICK) && (State & (NORMAL | INSERT)) | 937 else if ((mod_mask & MOD_MASK_MULTI_CLICK) |
938 && (State & (MODE_NORMAL | MODE_INSERT)) | |
938 && mouse_has(MOUSE_VISUAL)) | 939 && mouse_has(MOUSE_VISUAL)) |
939 { | 940 { |
940 if (is_click || !VIsual_active) | 941 if (is_click || !VIsual_active) |
941 { | 942 { |
942 if (VIsual_active) | 943 if (VIsual_active) |
1439 return; | 1440 return; |
1440 } | 1441 } |
1441 | 1442 |
1442 if (VIsual_active) | 1443 if (VIsual_active) |
1443 checkfor = MOUSE_VISUAL; | 1444 checkfor = MOUSE_VISUAL; |
1444 else if (State == HITRETURN || State == ASKMORE || State == SETWSIZE) | 1445 else if (State == MODE_HITRETURN || State == MODE_ASKMORE |
1446 || State == MODE_SETWSIZE) | |
1445 checkfor = MOUSE_RETURN; | 1447 checkfor = MOUSE_RETURN; |
1446 else if (State & INSERT) | 1448 else if (State & MODE_INSERT) |
1447 checkfor = MOUSE_INSERT; | 1449 checkfor = MOUSE_INSERT; |
1448 else if (State & CMDLINE) | 1450 else if (State & MODE_CMDLINE) |
1449 checkfor = MOUSE_COMMAND; | 1451 checkfor = MOUSE_COMMAND; |
1450 else if (State == CONFIRM || State == EXTERNCMD) | 1452 else if (State == MODE_CONFIRM || State == MODE_EXTERNCMD) |
1451 checkfor = ' '; // don't use mouse for ":confirm" or ":!cmd" | 1453 checkfor = ' '; // don't use mouse for ":confirm" or ":!cmd" |
1452 else | 1454 else |
1453 checkfor = MOUSE_NORMAL; // assume normal mode | 1455 checkfor = MOUSE_NORMAL; // assume normal mode |
1454 | 1456 |
1455 if (mouse_has(checkfor)) | 1457 if (mouse_has(checkfor)) |