Mercurial > vim
annotate src/mouse.c @ 31972:4e59c4260d84 v9.0.1318
patch 9.0.1318: code style test fails
Commit: https://github.com/vim/vim/commit/f2017f255ddceaad88a951adc6a2c190d3a18ebf
Author: Bram Moolenaar <Bram@vim.org>
Date: Fri Feb 17 21:29:57 2023 +0000
patch 9.0.1318: code style test fails
Problem: Code style test fails.
Solution: Remove trailing white space.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Fri, 17 Feb 2023 22:45:03 +0100 |
parents | fa26d002eb2a |
children | 4545f58c8490 |
rev | line source |
---|---|
18135
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1 /* vi:set ts=8 sts=4 sw=4 noet: |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2 * |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3 * VIM - Vi IMproved by Bram Moolenaar |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4 * |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
5 * Do ":help uganda" in Vim to read copying and usage conditions. |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
6 * Do ":help credits" in Vim to see a list of people who contributed. |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
7 * See README.txt for an overview of the Vim source code. |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
8 */ |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
9 |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
10 /* |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
11 * mouse.c: mouse handling functions |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
12 */ |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
13 |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
14 #include "vim.h" |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
15 |
28755
26a2836923d6
patch 8.2.4902: mouse wheel scrolling is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
28558
diff
changeset
|
16 /* |
26a2836923d6
patch 8.2.4902: mouse wheel scrolling is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
28558
diff
changeset
|
17 * Horiziontal and vertical steps used when scrolling. |
26a2836923d6
patch 8.2.4902: mouse wheel scrolling is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
28558
diff
changeset
|
18 * When negative scroll by a whole page. |
26a2836923d6
patch 8.2.4902: mouse wheel scrolling is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
28558
diff
changeset
|
19 */ |
26a2836923d6
patch 8.2.4902: mouse wheel scrolling is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
28558
diff
changeset
|
20 static long mouse_hor_step = 6; |
26a2836923d6
patch 8.2.4902: mouse wheel scrolling is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
28558
diff
changeset
|
21 static long mouse_vert_step = 3; |
26a2836923d6
patch 8.2.4902: mouse wheel scrolling is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
28558
diff
changeset
|
22 |
26a2836923d6
patch 8.2.4902: mouse wheel scrolling is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
28558
diff
changeset
|
23 void |
26a2836923d6
patch 8.2.4902: mouse wheel scrolling is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
28558
diff
changeset
|
24 mouse_set_vert_scroll_step(long step) |
26a2836923d6
patch 8.2.4902: mouse wheel scrolling is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
28558
diff
changeset
|
25 { |
26a2836923d6
patch 8.2.4902: mouse wheel scrolling is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
28558
diff
changeset
|
26 mouse_vert_step = step; |
26a2836923d6
patch 8.2.4902: mouse wheel scrolling is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
28558
diff
changeset
|
27 } |
26a2836923d6
patch 8.2.4902: mouse wheel scrolling is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
28558
diff
changeset
|
28 |
26a2836923d6
patch 8.2.4902: mouse wheel scrolling is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
28558
diff
changeset
|
29 void |
26a2836923d6
patch 8.2.4902: mouse wheel scrolling is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
28558
diff
changeset
|
30 mouse_set_hor_scroll_step(long step) |
26a2836923d6
patch 8.2.4902: mouse wheel scrolling is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
28558
diff
changeset
|
31 { |
26a2836923d6
patch 8.2.4902: mouse wheel scrolling is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
28558
diff
changeset
|
32 mouse_hor_step = step; |
26a2836923d6
patch 8.2.4902: mouse wheel scrolling is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
28558
diff
changeset
|
33 } |
26a2836923d6
patch 8.2.4902: mouse wheel scrolling is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
28558
diff
changeset
|
34 |
18691
fb07fe556e67
patch 8.1.2337: double-click time sometimes miscomputed
Bram Moolenaar <Bram@vim.org>
parents:
18658
diff
changeset
|
35 #ifdef CHECK_DOUBLE_CLICK |
fb07fe556e67
patch 8.1.2337: double-click time sometimes miscomputed
Bram Moolenaar <Bram@vim.org>
parents:
18658
diff
changeset
|
36 /* |
fb07fe556e67
patch 8.1.2337: double-click time sometimes miscomputed
Bram Moolenaar <Bram@vim.org>
parents:
18658
diff
changeset
|
37 * Return the duration from t1 to t2 in milliseconds. |
fb07fe556e67
patch 8.1.2337: double-click time sometimes miscomputed
Bram Moolenaar <Bram@vim.org>
parents:
18658
diff
changeset
|
38 */ |
fb07fe556e67
patch 8.1.2337: double-click time sometimes miscomputed
Bram Moolenaar <Bram@vim.org>
parents:
18658
diff
changeset
|
39 static long |
fb07fe556e67
patch 8.1.2337: double-click time sometimes miscomputed
Bram Moolenaar <Bram@vim.org>
parents:
18658
diff
changeset
|
40 time_diff_ms(struct timeval *t1, struct timeval *t2) |
fb07fe556e67
patch 8.1.2337: double-click time sometimes miscomputed
Bram Moolenaar <Bram@vim.org>
parents:
18658
diff
changeset
|
41 { |
fb07fe556e67
patch 8.1.2337: double-click time sometimes miscomputed
Bram Moolenaar <Bram@vim.org>
parents:
18658
diff
changeset
|
42 // This handles wrapping of tv_usec correctly without any special case. |
fb07fe556e67
patch 8.1.2337: double-click time sometimes miscomputed
Bram Moolenaar <Bram@vim.org>
parents:
18658
diff
changeset
|
43 // Example of 2 pairs (tv_sec, tv_usec) with a duration of 5 ms: |
fb07fe556e67
patch 8.1.2337: double-click time sometimes miscomputed
Bram Moolenaar <Bram@vim.org>
parents:
18658
diff
changeset
|
44 // t1 = (1, 998000) t2 = (2, 3000) gives: |
fb07fe556e67
patch 8.1.2337: double-click time sometimes miscomputed
Bram Moolenaar <Bram@vim.org>
parents:
18658
diff
changeset
|
45 // (2 - 1) * 1000 + (3000 - 998000) / 1000 -> 5 ms. |
fb07fe556e67
patch 8.1.2337: double-click time sometimes miscomputed
Bram Moolenaar <Bram@vim.org>
parents:
18658
diff
changeset
|
46 return (t2->tv_sec - t1->tv_sec) * 1000 |
fb07fe556e67
patch 8.1.2337: double-click time sometimes miscomputed
Bram Moolenaar <Bram@vim.org>
parents:
18658
diff
changeset
|
47 + (t2->tv_usec - t1->tv_usec) / 1000; |
fb07fe556e67
patch 8.1.2337: double-click time sometimes miscomputed
Bram Moolenaar <Bram@vim.org>
parents:
18658
diff
changeset
|
48 } |
fb07fe556e67
patch 8.1.2337: double-click time sometimes miscomputed
Bram Moolenaar <Bram@vim.org>
parents:
18658
diff
changeset
|
49 #endif |
fb07fe556e67
patch 8.1.2337: double-click time sometimes miscomputed
Bram Moolenaar <Bram@vim.org>
parents:
18658
diff
changeset
|
50 |
18135
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
51 /* |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
52 * Get class of a character for selection: same class means same word. |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
53 * 0: blank |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
54 * 1: punctuation groups |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
55 * 2: normal word character |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
56 * >2: multi-byte word character. |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
57 */ |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
58 static int |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
59 get_mouse_class(char_u *p) |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
60 { |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
61 int c; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
62 |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
63 if (has_mbyte && MB_BYTE2LEN(p[0]) > 1) |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
64 return mb_get_class(p); |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
65 |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
66 c = *p; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
67 if (c == ' ' || c == '\t') |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
68 return 0; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
69 |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
70 if (vim_iswordc(c)) |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
71 return 2; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
72 |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
73 // There are a few special cases where we want certain combinations of |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
74 // characters to be considered as a single word. These are things like |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
75 // "->", "/ *", "*=", "+=", "&=", "<=", ">=", "!=" etc. Otherwise, each |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
76 // character is in its own class. |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
77 if (c != NUL && vim_strchr((char_u *)"-+*/%<>&|^!=", c) != NULL) |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
78 return 1; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
79 return c; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
80 } |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
81 |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
82 /* |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
83 * Move "pos" back to the start of the word it's in. |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
84 */ |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
85 static void |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
86 find_start_of_word(pos_T *pos) |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
87 { |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
88 char_u *line; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
89 int cclass; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
90 int col; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
91 |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
92 line = ml_get(pos->lnum); |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
93 cclass = get_mouse_class(line + pos->col); |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
94 |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
95 while (pos->col > 0) |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
96 { |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
97 col = pos->col - 1; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
98 col -= (*mb_head_off)(line, line + col); |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
99 if (get_mouse_class(line + col) != cclass) |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
100 break; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
101 pos->col = col; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
102 } |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
103 } |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
104 |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
105 /* |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
106 * Move "pos" forward to the end of the word it's in. |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
107 * When 'selection' is "exclusive", the position is just after the word. |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
108 */ |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
109 static void |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
110 find_end_of_word(pos_T *pos) |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
111 { |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
112 char_u *line; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
113 int cclass; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
114 int col; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
115 |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
116 line = ml_get(pos->lnum); |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
117 if (*p_sel == 'e' && pos->col > 0) |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
118 { |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
119 --pos->col; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
120 pos->col -= (*mb_head_off)(line, line + pos->col); |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
121 } |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
122 cclass = get_mouse_class(line + pos->col); |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
123 while (line[pos->col] != NUL) |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
124 { |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
125 col = pos->col + (*mb_ptr2len)(line + pos->col); |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
126 if (get_mouse_class(line + col) != cclass) |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
127 { |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
128 if (*p_sel == 'e') |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
129 pos->col = col; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
130 break; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
131 } |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
132 pos->col = col; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
133 } |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
134 } |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
135 |
18141
2cc67e54edf8
patch 8.1.2065: compiler warning building non-GUI with MinGW.
Bram Moolenaar <Bram@vim.org>
parents:
18135
diff
changeset
|
136 #if defined(FEAT_GUI_MOTIF) || defined(FEAT_GUI_GTK) \ |
28303
9849df834f1d
patch 8.2.4677: the Athena GUI support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
28087
diff
changeset
|
137 || defined(FEAT_GUI_MSWIN) \ |
21745
35921b7fc07a
patch 8.2.1422: the Mac GUI implementation is outdated
Bram Moolenaar <Bram@vim.org>
parents:
21339
diff
changeset
|
138 || defined(FEAT_GUI_PHOTON) \ |
18141
2cc67e54edf8
patch 8.1.2065: compiler warning building non-GUI with MinGW.
Bram Moolenaar <Bram@vim.org>
parents:
18135
diff
changeset
|
139 || defined(FEAT_TERM_POPUP_MENU) |
2cc67e54edf8
patch 8.1.2065: compiler warning building non-GUI with MinGW.
Bram Moolenaar <Bram@vim.org>
parents:
18135
diff
changeset
|
140 # define USE_POPUP_SETPOS |
2cc67e54edf8
patch 8.1.2065: compiler warning building non-GUI with MinGW.
Bram Moolenaar <Bram@vim.org>
parents:
18135
diff
changeset
|
141 # define NEED_VCOL2COL |
2cc67e54edf8
patch 8.1.2065: compiler warning building non-GUI with MinGW.
Bram Moolenaar <Bram@vim.org>
parents:
18135
diff
changeset
|
142 |
2cc67e54edf8
patch 8.1.2065: compiler warning building non-GUI with MinGW.
Bram Moolenaar <Bram@vim.org>
parents:
18135
diff
changeset
|
143 /* |
30809
ffdb7a6785af
patch 9.0.0739: mouse column not correctly used for popup_setpos
Bram Moolenaar <Bram@vim.org>
parents:
30645
diff
changeset
|
144 * Translate window coordinates to buffer position without any side effects. |
ffdb7a6785af
patch 9.0.0739: mouse column not correctly used for popup_setpos
Bram Moolenaar <Bram@vim.org>
parents:
30645
diff
changeset
|
145 * Returns IN_BUFFER and sets "mpos->col" to the column when in buffer text. |
ffdb7a6785af
patch 9.0.0739: mouse column not correctly used for popup_setpos
Bram Moolenaar <Bram@vim.org>
parents:
30645
diff
changeset
|
146 * The column is one for the first column. |
18141
2cc67e54edf8
patch 8.1.2065: compiler warning building non-GUI with MinGW.
Bram Moolenaar <Bram@vim.org>
parents:
18135
diff
changeset
|
147 */ |
2cc67e54edf8
patch 8.1.2065: compiler warning building non-GUI with MinGW.
Bram Moolenaar <Bram@vim.org>
parents:
18135
diff
changeset
|
148 static int |
2cc67e54edf8
patch 8.1.2065: compiler warning building non-GUI with MinGW.
Bram Moolenaar <Bram@vim.org>
parents:
18135
diff
changeset
|
149 get_fpos_of_mouse(pos_T *mpos) |
2cc67e54edf8
patch 8.1.2065: compiler warning building non-GUI with MinGW.
Bram Moolenaar <Bram@vim.org>
parents:
18135
diff
changeset
|
150 { |
2cc67e54edf8
patch 8.1.2065: compiler warning building non-GUI with MinGW.
Bram Moolenaar <Bram@vim.org>
parents:
18135
diff
changeset
|
151 win_T *wp; |
2cc67e54edf8
patch 8.1.2065: compiler warning building non-GUI with MinGW.
Bram Moolenaar <Bram@vim.org>
parents:
18135
diff
changeset
|
152 int row = mouse_row; |
2cc67e54edf8
patch 8.1.2065: compiler warning building non-GUI with MinGW.
Bram Moolenaar <Bram@vim.org>
parents:
18135
diff
changeset
|
153 int col = mouse_col; |
2cc67e54edf8
patch 8.1.2065: compiler warning building non-GUI with MinGW.
Bram Moolenaar <Bram@vim.org>
parents:
18135
diff
changeset
|
154 |
2cc67e54edf8
patch 8.1.2065: compiler warning building non-GUI with MinGW.
Bram Moolenaar <Bram@vim.org>
parents:
18135
diff
changeset
|
155 if (row < 0 || col < 0) // check if it makes sense |
2cc67e54edf8
patch 8.1.2065: compiler warning building non-GUI with MinGW.
Bram Moolenaar <Bram@vim.org>
parents:
18135
diff
changeset
|
156 return IN_UNKNOWN; |
2cc67e54edf8
patch 8.1.2065: compiler warning building non-GUI with MinGW.
Bram Moolenaar <Bram@vim.org>
parents:
18135
diff
changeset
|
157 |
2cc67e54edf8
patch 8.1.2065: compiler warning building non-GUI with MinGW.
Bram Moolenaar <Bram@vim.org>
parents:
18135
diff
changeset
|
158 // find the window where the row is in |
2cc67e54edf8
patch 8.1.2065: compiler warning building non-GUI with MinGW.
Bram Moolenaar <Bram@vim.org>
parents:
18135
diff
changeset
|
159 wp = mouse_find_win(&row, &col, FAIL_POPUP); |
2cc67e54edf8
patch 8.1.2065: compiler warning building non-GUI with MinGW.
Bram Moolenaar <Bram@vim.org>
parents:
18135
diff
changeset
|
160 if (wp == NULL) |
2cc67e54edf8
patch 8.1.2065: compiler warning building non-GUI with MinGW.
Bram Moolenaar <Bram@vim.org>
parents:
18135
diff
changeset
|
161 return IN_UNKNOWN; |
2cc67e54edf8
patch 8.1.2065: compiler warning building non-GUI with MinGW.
Bram Moolenaar <Bram@vim.org>
parents:
18135
diff
changeset
|
162 // winpos and height may change in win_enter()! |
2cc67e54edf8
patch 8.1.2065: compiler warning building non-GUI with MinGW.
Bram Moolenaar <Bram@vim.org>
parents:
18135
diff
changeset
|
163 if (row >= wp->w_height) // In (or below) status line |
2cc67e54edf8
patch 8.1.2065: compiler warning building non-GUI with MinGW.
Bram Moolenaar <Bram@vim.org>
parents:
18135
diff
changeset
|
164 return IN_STATUS_LINE; |
2cc67e54edf8
patch 8.1.2065: compiler warning building non-GUI with MinGW.
Bram Moolenaar <Bram@vim.org>
parents:
18135
diff
changeset
|
165 if (col >= wp->w_width) // In vertical separator line |
2cc67e54edf8
patch 8.1.2065: compiler warning building non-GUI with MinGW.
Bram Moolenaar <Bram@vim.org>
parents:
18135
diff
changeset
|
166 return IN_SEP_LINE; |
2cc67e54edf8
patch 8.1.2065: compiler warning building non-GUI with MinGW.
Bram Moolenaar <Bram@vim.org>
parents:
18135
diff
changeset
|
167 |
2cc67e54edf8
patch 8.1.2065: compiler warning building non-GUI with MinGW.
Bram Moolenaar <Bram@vim.org>
parents:
18135
diff
changeset
|
168 if (wp != curwin) |
2cc67e54edf8
patch 8.1.2065: compiler warning building non-GUI with MinGW.
Bram Moolenaar <Bram@vim.org>
parents:
18135
diff
changeset
|
169 return IN_UNKNOWN; |
2cc67e54edf8
patch 8.1.2065: compiler warning building non-GUI with MinGW.
Bram Moolenaar <Bram@vim.org>
parents:
18135
diff
changeset
|
170 |
2cc67e54edf8
patch 8.1.2065: compiler warning building non-GUI with MinGW.
Bram Moolenaar <Bram@vim.org>
parents:
18135
diff
changeset
|
171 // compute the position in the buffer line from the posn on the screen |
2cc67e54edf8
patch 8.1.2065: compiler warning building non-GUI with MinGW.
Bram Moolenaar <Bram@vim.org>
parents:
18135
diff
changeset
|
172 if (mouse_comp_pos(curwin, &row, &col, &mpos->lnum, NULL)) |
2cc67e54edf8
patch 8.1.2065: compiler warning building non-GUI with MinGW.
Bram Moolenaar <Bram@vim.org>
parents:
18135
diff
changeset
|
173 return IN_STATUS_LINE; // past bottom |
2cc67e54edf8
patch 8.1.2065: compiler warning building non-GUI with MinGW.
Bram Moolenaar <Bram@vim.org>
parents:
18135
diff
changeset
|
174 |
2cc67e54edf8
patch 8.1.2065: compiler warning building non-GUI with MinGW.
Bram Moolenaar <Bram@vim.org>
parents:
18135
diff
changeset
|
175 mpos->col = vcol2col(wp, mpos->lnum, col); |
2cc67e54edf8
patch 8.1.2065: compiler warning building non-GUI with MinGW.
Bram Moolenaar <Bram@vim.org>
parents:
18135
diff
changeset
|
176 |
2cc67e54edf8
patch 8.1.2065: compiler warning building non-GUI with MinGW.
Bram Moolenaar <Bram@vim.org>
parents:
18135
diff
changeset
|
177 mpos->coladd = 0; |
2cc67e54edf8
patch 8.1.2065: compiler warning building non-GUI with MinGW.
Bram Moolenaar <Bram@vim.org>
parents:
18135
diff
changeset
|
178 return IN_BUFFER; |
2cc67e54edf8
patch 8.1.2065: compiler warning building non-GUI with MinGW.
Bram Moolenaar <Bram@vim.org>
parents:
18135
diff
changeset
|
179 } |
2cc67e54edf8
patch 8.1.2065: compiler warning building non-GUI with MinGW.
Bram Moolenaar <Bram@vim.org>
parents:
18135
diff
changeset
|
180 #endif |
2cc67e54edf8
patch 8.1.2065: compiler warning building non-GUI with MinGW.
Bram Moolenaar <Bram@vim.org>
parents:
18135
diff
changeset
|
181 |
18135
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
182 /* |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
183 * Do the appropriate action for the current mouse click in the current mode. |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
184 * Not used for Command-line mode. |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
185 * |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
186 * Normal and Visual Mode: |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
187 * event modi- position visual change action |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
188 * fier cursor window |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
189 * left press - yes end yes |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
190 * left press C yes end yes "^]" (2) |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
191 * left press S yes end (popup: extend) yes "*" (2) |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
192 * left drag - yes start if moved no |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
193 * left relse - yes start if moved no |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
194 * middle press - yes if not active no put register |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
195 * middle press - yes if active no yank and put |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
196 * right press - yes start or extend yes |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
197 * right press S yes no change yes "#" (2) |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
198 * right drag - yes extend no |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
199 * right relse - yes extend no |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
200 * |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
201 * Insert or Replace Mode: |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
202 * event modi- position visual change action |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
203 * fier cursor window |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
204 * left press - yes (cannot be active) yes |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
205 * left press C yes (cannot be active) yes "CTRL-O^]" (2) |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
206 * left press S yes (cannot be active) yes "CTRL-O*" (2) |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
207 * left drag - yes start or extend (1) no CTRL-O (1) |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
208 * left relse - yes start or extend (1) no CTRL-O (1) |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
209 * middle press - no (cannot be active) no put register |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
210 * right press - yes start or extend yes CTRL-O |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
211 * right press S yes (cannot be active) yes "CTRL-O#" (2) |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
212 * |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
213 * (1) only if mouse pointer moved since press |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
214 * (2) only if click is in same buffer |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
215 * |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
216 * Return TRUE if start_arrow() should be called for edit mode. |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
217 */ |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
218 int |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
219 do_mouse( |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
220 oparg_T *oap, // operator argument, can be NULL |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
221 int c, // K_LEFTMOUSE, etc |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
222 int dir, // Direction to 'put' if necessary |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
223 long count, |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
224 int fixindent) // PUT_FIXINDENT if fixing indent necessary |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
225 { |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
226 static int do_always = FALSE; // ignore 'mouse' setting next time |
30980
eb51299c4bfc
patch 9.0.0825: cannot drag an entry in the tabpage line
Bram Moolenaar <Bram@vim.org>
parents:
30974
diff
changeset
|
227 static int got_click = FALSE; // got a click some time back |
18135
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
228 |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
229 int which_button; // MOUSE_LEFT, _MIDDLE or _RIGHT |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
230 int is_click = FALSE; // If FALSE it's a drag or release event |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
231 int is_drag = FALSE; // If TRUE it's a drag event |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
232 int jump_flags = 0; // flags for jump_to_mouse() |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
233 pos_T start_visual; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
234 int moved; // Has cursor moved? |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
235 int in_status_line; // mouse in status line |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
236 static int in_tab_line = FALSE; // mouse clicked in tab line |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
237 int in_sep_line; // mouse in vertical separator line |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
238 int c1, c2; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
239 #if defined(FEAT_FOLDING) |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
240 pos_T save_cursor; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
241 #endif |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
242 win_T *old_curwin = curwin; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
243 static pos_T orig_cursor; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
244 colnr_T leftcol, rightcol; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
245 pos_T end_visual; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
246 int diff; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
247 int old_active = VIsual_active; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
248 int old_mode = VIsual_mode; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
249 int regname; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
250 |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
251 #if defined(FEAT_FOLDING) |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
252 save_cursor = curwin->w_cursor; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
253 #endif |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
254 |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
255 // When GUI is active, always recognize mouse events, otherwise: |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
256 // - Ignore mouse event in normal mode if 'mouse' doesn't include 'n'. |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
257 // - Ignore mouse event in visual mode if 'mouse' doesn't include 'v'. |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
258 // - For command line and insert mode 'mouse' is checked before calling |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
259 // do_mouse(). |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
260 if (do_always) |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
261 do_always = FALSE; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
262 else |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
263 #ifdef FEAT_GUI |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
264 if (!gui.in_use) |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
265 #endif |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
266 { |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
267 if (VIsual_active) |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
268 { |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
269 if (!mouse_has(MOUSE_VISUAL)) |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
270 return FALSE; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
271 } |
28773
d770568e6c98
patch 8.2.4911: the mode #defines are not clearly named
Bram Moolenaar <Bram@vim.org>
parents:
28755
diff
changeset
|
272 else if (State == MODE_NORMAL && !mouse_has(MOUSE_NORMAL)) |
18135
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
273 return FALSE; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
274 } |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
275 |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
276 for (;;) |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
277 { |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
278 which_button = get_mouse_button(KEY2TERMCAP1(c), &is_click, &is_drag); |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
279 if (is_drag) |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
280 { |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
281 // If the next character is the same mouse event then use that |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
282 // one. Speeds up dragging the status line. |
28333
04310f81143d
patch 8.2.4692: no test for what 8.2.4691 fixes
Bram Moolenaar <Bram@vim.org>
parents:
28303
diff
changeset
|
283 // Note: Since characters added to the stuff buffer in the code |
04310f81143d
patch 8.2.4692: no test for what 8.2.4691 fixes
Bram Moolenaar <Bram@vim.org>
parents:
28303
diff
changeset
|
284 // below need to come before the next character, do not do this |
04310f81143d
patch 8.2.4692: no test for what 8.2.4691 fixes
Bram Moolenaar <Bram@vim.org>
parents:
28303
diff
changeset
|
285 // when the current character was stuffed. |
04310f81143d
patch 8.2.4692: no test for what 8.2.4691 fixes
Bram Moolenaar <Bram@vim.org>
parents:
28303
diff
changeset
|
286 if (!KeyStuffed && vpeekc() != NUL) |
18135
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
287 { |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
288 int nc; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
289 int save_mouse_row = mouse_row; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
290 int save_mouse_col = mouse_col; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
291 |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
292 // Need to get the character, peeking doesn't get the actual |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
293 // one. |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
294 nc = safe_vgetc(); |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
295 if (c == nc) |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
296 continue; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
297 vungetc(nc); |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
298 mouse_row = save_mouse_row; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
299 mouse_col = save_mouse_col; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
300 } |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
301 } |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
302 break; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
303 } |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
304 |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
305 if (c == K_MOUSEMOVE) |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
306 { |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
307 // Mouse moved without a button pressed. |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
308 #ifdef FEAT_BEVAL_TERM |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
309 ui_may_remove_balloon(); |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
310 if (p_bevalterm) |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
311 { |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
312 profile_setlimit(p_bdlay, &bevalexpr_due); |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
313 bevalexpr_due_set = TRUE; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
314 } |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
315 #endif |
18763
49b78d6465e5
patch 8.1.2371: FEAT_TEXT_PROP is a confusing name
Bram Moolenaar <Bram@vim.org>
parents:
18691
diff
changeset
|
316 #ifdef FEAT_PROP_POPUP |
18135
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
317 popup_handle_mouse_moved(); |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
318 #endif |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
319 return FALSE; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
320 } |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
321 |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
322 #ifdef FEAT_MOUSESHAPE |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
323 // May have stopped dragging the status or separator line. The pointer is |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
324 // most likely still on the status or separator line. |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
325 if (!is_drag && drag_status_line) |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
326 { |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
327 drag_status_line = FALSE; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
328 update_mouseshape(SHAPE_IDX_STATUS); |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
329 } |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
330 if (!is_drag && drag_sep_line) |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
331 { |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
332 drag_sep_line = FALSE; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
333 update_mouseshape(SHAPE_IDX_VSEP); |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
334 } |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
335 #endif |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
336 |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
337 // Ignore drag and release events if we didn't get a click. |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
338 if (is_click) |
30980
eb51299c4bfc
patch 9.0.0825: cannot drag an entry in the tabpage line
Bram Moolenaar <Bram@vim.org>
parents:
30974
diff
changeset
|
339 got_click = TRUE; |
18135
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
340 else |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
341 { |
30980
eb51299c4bfc
patch 9.0.0825: cannot drag an entry in the tabpage line
Bram Moolenaar <Bram@vim.org>
parents:
30974
diff
changeset
|
342 if (!got_click) // didn't get click, ignore |
18135
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
343 return FALSE; |
30980
eb51299c4bfc
patch 9.0.0825: cannot drag an entry in the tabpage line
Bram Moolenaar <Bram@vim.org>
parents:
30974
diff
changeset
|
344 if (!is_drag) // release, reset got_click |
18135
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
345 { |
30980
eb51299c4bfc
patch 9.0.0825: cannot drag an entry in the tabpage line
Bram Moolenaar <Bram@vim.org>
parents:
30974
diff
changeset
|
346 got_click = FALSE; |
18135
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
347 if (in_tab_line) |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
348 { |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
349 in_tab_line = FALSE; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
350 return FALSE; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
351 } |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
352 } |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
353 } |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
354 |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
355 // CTRL right mouse button does CTRL-T |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
356 if (is_click && (mod_mask & MOD_MASK_CTRL) && which_button == MOUSE_RIGHT) |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
357 { |
28773
d770568e6c98
patch 8.2.4911: the mode #defines are not clearly named
Bram Moolenaar <Bram@vim.org>
parents:
28755
diff
changeset
|
358 if (State & MODE_INSERT) |
18135
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
359 stuffcharReadbuff(Ctrl_O); |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
360 if (count > 1) |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
361 stuffnumReadbuff(count); |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
362 stuffcharReadbuff(Ctrl_T); |
30980
eb51299c4bfc
patch 9.0.0825: cannot drag an entry in the tabpage line
Bram Moolenaar <Bram@vim.org>
parents:
30974
diff
changeset
|
363 got_click = FALSE; // ignore drag&release now |
18135
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
364 return FALSE; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
365 } |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
366 |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
367 // CTRL only works with left mouse button |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
368 if ((mod_mask & MOD_MASK_CTRL) && which_button != MOUSE_LEFT) |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
369 return FALSE; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
370 |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
371 // When a modifier is down, ignore drag and release events, as well as |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
372 // multiple clicks and the middle mouse button. |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
373 // Accept shift-leftmouse drags when 'mousemodel' is "popup.*". |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
374 if ((mod_mask & (MOD_MASK_SHIFT | MOD_MASK_CTRL | MOD_MASK_ALT |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
375 | MOD_MASK_META)) |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
376 && (!is_click |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
377 || (mod_mask & MOD_MASK_MULTI_CLICK) |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
378 || which_button == MOUSE_MIDDLE) |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
379 && !((mod_mask & (MOD_MASK_SHIFT|MOD_MASK_ALT)) |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
380 && mouse_model_popup() |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
381 && which_button == MOUSE_LEFT) |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
382 && !((mod_mask & MOD_MASK_ALT) |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
383 && !mouse_model_popup() |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
384 && which_button == MOUSE_RIGHT) |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
385 ) |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
386 return FALSE; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
387 |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
388 // If the button press was used as the movement command for an operator |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
389 // (eg "d<MOUSE>"), or it is the middle button that is held down, ignore |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
390 // drag/release events. |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
391 if (!is_click && which_button == MOUSE_MIDDLE) |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
392 return FALSE; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
393 |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
394 if (oap != NULL) |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
395 regname = oap->regname; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
396 else |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
397 regname = 0; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
398 |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
399 // Middle mouse button does a 'put' of the selected text |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
400 if (which_button == MOUSE_MIDDLE) |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
401 { |
28773
d770568e6c98
patch 8.2.4911: the mode #defines are not clearly named
Bram Moolenaar <Bram@vim.org>
parents:
28755
diff
changeset
|
402 if (State == MODE_NORMAL) |
18135
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
403 { |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
404 // If an operator was pending, we don't know what the user wanted |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
405 // to do. Go back to normal mode: Clear the operator and beep(). |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
406 if (oap != NULL && oap->op_type != OP_NOP) |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
407 { |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
408 clearopbeep(oap); |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
409 return FALSE; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
410 } |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
411 |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
412 // If visual was active, yank the highlighted text and put it |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
413 // before the mouse pointer position. |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
414 // In Select mode replace the highlighted text with the clipboard. |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
415 if (VIsual_active) |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
416 { |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
417 if (VIsual_select) |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
418 { |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
419 stuffcharReadbuff(Ctrl_G); |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
420 stuffReadbuff((char_u *)"\"+p"); |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
421 } |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
422 else |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
423 { |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
424 stuffcharReadbuff('y'); |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
425 stuffcharReadbuff(K_MIDDLEMOUSE); |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
426 } |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
427 do_always = TRUE; // ignore 'mouse' setting next time |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
428 return FALSE; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
429 } |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
430 // The rest is below jump_to_mouse() |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
431 } |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
432 |
28773
d770568e6c98
patch 8.2.4911: the mode #defines are not clearly named
Bram Moolenaar <Bram@vim.org>
parents:
28755
diff
changeset
|
433 else if ((State & MODE_INSERT) == 0) |
18135
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
434 return FALSE; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
435 |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
436 // Middle click in insert mode doesn't move the mouse, just insert the |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
437 // contents of a register. '.' register is special, can't insert that |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
438 // with do_put(). |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
439 // Also paste at the cursor if the current mode isn't in 'mouse' (only |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
440 // happens for the GUI). |
28773
d770568e6c98
patch 8.2.4911: the mode #defines are not clearly named
Bram Moolenaar <Bram@vim.org>
parents:
28755
diff
changeset
|
441 if ((State & MODE_INSERT) || !mouse_has(MOUSE_NORMAL)) |
18135
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
442 { |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
443 if (regname == '.') |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
444 insert_reg(regname, TRUE); |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
445 else |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
446 { |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
447 #ifdef FEAT_CLIPBOARD |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
448 if (clip_star.available && regname == 0) |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
449 regname = '*'; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
450 #endif |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
451 if ((State & REPLACE_FLAG) && !yank_register_mline(regname)) |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
452 insert_reg(regname, TRUE); |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
453 else |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
454 { |
22176
6941d3205be9
patch 8.2.1637: Vim9: :put ={expr} does not work inside :def function
Bram Moolenaar <Bram@vim.org>
parents:
21745
diff
changeset
|
455 do_put(regname, NULL, BACKWARD, 1L, |
6941d3205be9
patch 8.2.1637: Vim9: :put ={expr} does not work inside :def function
Bram Moolenaar <Bram@vim.org>
parents:
21745
diff
changeset
|
456 fixindent | PUT_CURSEND); |
18135
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
457 |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
458 // Repeat it with CTRL-R CTRL-O r or CTRL-R CTRL-P r |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
459 AppendCharToRedobuff(Ctrl_R); |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
460 AppendCharToRedobuff(fixindent ? Ctrl_P : Ctrl_O); |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
461 AppendCharToRedobuff(regname == 0 ? '"' : regname); |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
462 } |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
463 } |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
464 return FALSE; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
465 } |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
466 } |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
467 |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
468 // When dragging or button-up stay in the same window. |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
469 if (!is_click) |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
470 jump_flags |= MOUSE_FOCUS | MOUSE_DID_MOVE; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
471 |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
472 start_visual.lnum = 0; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
473 |
29841
b37b74ea8dee
patch 9.0.0259: crash with mouse click when not initialized
Bram Moolenaar <Bram@vim.org>
parents:
29732
diff
changeset
|
474 if (TabPageIdxs != NULL) // only when initialized |
18135
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
475 { |
29841
b37b74ea8dee
patch 9.0.0259: crash with mouse click when not initialized
Bram Moolenaar <Bram@vim.org>
parents:
29732
diff
changeset
|
476 // Check for clicking in the tab page line. |
b37b74ea8dee
patch 9.0.0259: crash with mouse click when not initialized
Bram Moolenaar <Bram@vim.org>
parents:
29732
diff
changeset
|
477 if (mouse_row == 0 && firstwin->w_winrow > 0) |
18135
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
478 { |
29841
b37b74ea8dee
patch 9.0.0259: crash with mouse click when not initialized
Bram Moolenaar <Bram@vim.org>
parents:
29732
diff
changeset
|
479 if (is_drag) |
18135
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
480 { |
29841
b37b74ea8dee
patch 9.0.0259: crash with mouse click when not initialized
Bram Moolenaar <Bram@vim.org>
parents:
29732
diff
changeset
|
481 if (in_tab_line) |
b37b74ea8dee
patch 9.0.0259: crash with mouse click when not initialized
Bram Moolenaar <Bram@vim.org>
parents:
29732
diff
changeset
|
482 { |
b37b74ea8dee
patch 9.0.0259: crash with mouse click when not initialized
Bram Moolenaar <Bram@vim.org>
parents:
29732
diff
changeset
|
483 c1 = TabPageIdxs[mouse_col]; |
b37b74ea8dee
patch 9.0.0259: crash with mouse click when not initialized
Bram Moolenaar <Bram@vim.org>
parents:
29732
diff
changeset
|
484 tabpage_move(c1 <= 0 ? 9999 : c1 < tabpage_index(curtab) |
30645
101f08b49ed3
patch 9.0.0657: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
29841
diff
changeset
|
485 ? c1 - 1 : c1); |
29841
b37b74ea8dee
patch 9.0.0259: crash with mouse click when not initialized
Bram Moolenaar <Bram@vim.org>
parents:
29732
diff
changeset
|
486 } |
b37b74ea8dee
patch 9.0.0259: crash with mouse click when not initialized
Bram Moolenaar <Bram@vim.org>
parents:
29732
diff
changeset
|
487 return FALSE; |
18135
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
488 } |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
489 |
29841
b37b74ea8dee
patch 9.0.0259: crash with mouse click when not initialized
Bram Moolenaar <Bram@vim.org>
parents:
29732
diff
changeset
|
490 // click in a tab selects that tab page |
30645
101f08b49ed3
patch 9.0.0657: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
29841
diff
changeset
|
491 if (is_click && cmdwin_type == 0 && mouse_col < Columns) |
18135
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
492 { |
29841
b37b74ea8dee
patch 9.0.0259: crash with mouse click when not initialized
Bram Moolenaar <Bram@vim.org>
parents:
29732
diff
changeset
|
493 in_tab_line = TRUE; |
b37b74ea8dee
patch 9.0.0259: crash with mouse click when not initialized
Bram Moolenaar <Bram@vim.org>
parents:
29732
diff
changeset
|
494 c1 = TabPageIdxs[mouse_col]; |
b37b74ea8dee
patch 9.0.0259: crash with mouse click when not initialized
Bram Moolenaar <Bram@vim.org>
parents:
29732
diff
changeset
|
495 if (c1 >= 0) |
18135
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
496 { |
29841
b37b74ea8dee
patch 9.0.0259: crash with mouse click when not initialized
Bram Moolenaar <Bram@vim.org>
parents:
29732
diff
changeset
|
497 if ((mod_mask & MOD_MASK_MULTI_CLICK) == MOD_MASK_2CLICK) |
b37b74ea8dee
patch 9.0.0259: crash with mouse click when not initialized
Bram Moolenaar <Bram@vim.org>
parents:
29732
diff
changeset
|
498 { |
b37b74ea8dee
patch 9.0.0259: crash with mouse click when not initialized
Bram Moolenaar <Bram@vim.org>
parents:
29732
diff
changeset
|
499 // double click opens new page |
b37b74ea8dee
patch 9.0.0259: crash with mouse click when not initialized
Bram Moolenaar <Bram@vim.org>
parents:
29732
diff
changeset
|
500 end_visual_mode_keep_button(); |
b37b74ea8dee
patch 9.0.0259: crash with mouse click when not initialized
Bram Moolenaar <Bram@vim.org>
parents:
29732
diff
changeset
|
501 tabpage_new(); |
b37b74ea8dee
patch 9.0.0259: crash with mouse click when not initialized
Bram Moolenaar <Bram@vim.org>
parents:
29732
diff
changeset
|
502 tabpage_move(c1 == 0 ? 9999 : c1 - 1); |
b37b74ea8dee
patch 9.0.0259: crash with mouse click when not initialized
Bram Moolenaar <Bram@vim.org>
parents:
29732
diff
changeset
|
503 } |
b37b74ea8dee
patch 9.0.0259: crash with mouse click when not initialized
Bram Moolenaar <Bram@vim.org>
parents:
29732
diff
changeset
|
504 else |
b37b74ea8dee
patch 9.0.0259: crash with mouse click when not initialized
Bram Moolenaar <Bram@vim.org>
parents:
29732
diff
changeset
|
505 { |
b37b74ea8dee
patch 9.0.0259: crash with mouse click when not initialized
Bram Moolenaar <Bram@vim.org>
parents:
29732
diff
changeset
|
506 // Go to specified tab page, or next one if not clicking |
b37b74ea8dee
patch 9.0.0259: crash with mouse click when not initialized
Bram Moolenaar <Bram@vim.org>
parents:
29732
diff
changeset
|
507 // on a label. |
b37b74ea8dee
patch 9.0.0259: crash with mouse click when not initialized
Bram Moolenaar <Bram@vim.org>
parents:
29732
diff
changeset
|
508 goto_tabpage(c1); |
b37b74ea8dee
patch 9.0.0259: crash with mouse click when not initialized
Bram Moolenaar <Bram@vim.org>
parents:
29732
diff
changeset
|
509 |
b37b74ea8dee
patch 9.0.0259: crash with mouse click when not initialized
Bram Moolenaar <Bram@vim.org>
parents:
29732
diff
changeset
|
510 // It's like clicking on the status line of a window. |
b37b74ea8dee
patch 9.0.0259: crash with mouse click when not initialized
Bram Moolenaar <Bram@vim.org>
parents:
29732
diff
changeset
|
511 if (curwin != old_curwin) |
b37b74ea8dee
patch 9.0.0259: crash with mouse click when not initialized
Bram Moolenaar <Bram@vim.org>
parents:
29732
diff
changeset
|
512 end_visual_mode_keep_button(); |
b37b74ea8dee
patch 9.0.0259: crash with mouse click when not initialized
Bram Moolenaar <Bram@vim.org>
parents:
29732
diff
changeset
|
513 } |
18135
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
514 } |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
515 else |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
516 { |
29841
b37b74ea8dee
patch 9.0.0259: crash with mouse click when not initialized
Bram Moolenaar <Bram@vim.org>
parents:
29732
diff
changeset
|
517 tabpage_T *tp; |
18135
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
518 |
29841
b37b74ea8dee
patch 9.0.0259: crash with mouse click when not initialized
Bram Moolenaar <Bram@vim.org>
parents:
29732
diff
changeset
|
519 // Close the current or specified tab page. |
b37b74ea8dee
patch 9.0.0259: crash with mouse click when not initialized
Bram Moolenaar <Bram@vim.org>
parents:
29732
diff
changeset
|
520 if (c1 == -999) |
b37b74ea8dee
patch 9.0.0259: crash with mouse click when not initialized
Bram Moolenaar <Bram@vim.org>
parents:
29732
diff
changeset
|
521 tp = curtab; |
b37b74ea8dee
patch 9.0.0259: crash with mouse click when not initialized
Bram Moolenaar <Bram@vim.org>
parents:
29732
diff
changeset
|
522 else |
b37b74ea8dee
patch 9.0.0259: crash with mouse click when not initialized
Bram Moolenaar <Bram@vim.org>
parents:
29732
diff
changeset
|
523 tp = find_tabpage(-c1); |
b37b74ea8dee
patch 9.0.0259: crash with mouse click when not initialized
Bram Moolenaar <Bram@vim.org>
parents:
29732
diff
changeset
|
524 if (tp == curtab) |
b37b74ea8dee
patch 9.0.0259: crash with mouse click when not initialized
Bram Moolenaar <Bram@vim.org>
parents:
29732
diff
changeset
|
525 { |
b37b74ea8dee
patch 9.0.0259: crash with mouse click when not initialized
Bram Moolenaar <Bram@vim.org>
parents:
29732
diff
changeset
|
526 if (first_tabpage->tp_next != NULL) |
b37b74ea8dee
patch 9.0.0259: crash with mouse click when not initialized
Bram Moolenaar <Bram@vim.org>
parents:
29732
diff
changeset
|
527 tabpage_close(FALSE); |
b37b74ea8dee
patch 9.0.0259: crash with mouse click when not initialized
Bram Moolenaar <Bram@vim.org>
parents:
29732
diff
changeset
|
528 } |
b37b74ea8dee
patch 9.0.0259: crash with mouse click when not initialized
Bram Moolenaar <Bram@vim.org>
parents:
29732
diff
changeset
|
529 else if (tp != NULL) |
b37b74ea8dee
patch 9.0.0259: crash with mouse click when not initialized
Bram Moolenaar <Bram@vim.org>
parents:
29732
diff
changeset
|
530 tabpage_close_other(tp, FALSE); |
18135
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
531 } |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
532 } |
29841
b37b74ea8dee
patch 9.0.0259: crash with mouse click when not initialized
Bram Moolenaar <Bram@vim.org>
parents:
29732
diff
changeset
|
533 return TRUE; |
18135
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
534 } |
29841
b37b74ea8dee
patch 9.0.0259: crash with mouse click when not initialized
Bram Moolenaar <Bram@vim.org>
parents:
29732
diff
changeset
|
535 else if (is_drag && in_tab_line) |
b37b74ea8dee
patch 9.0.0259: crash with mouse click when not initialized
Bram Moolenaar <Bram@vim.org>
parents:
29732
diff
changeset
|
536 { |
b37b74ea8dee
patch 9.0.0259: crash with mouse click when not initialized
Bram Moolenaar <Bram@vim.org>
parents:
29732
diff
changeset
|
537 c1 = TabPageIdxs[mouse_col]; |
b37b74ea8dee
patch 9.0.0259: crash with mouse click when not initialized
Bram Moolenaar <Bram@vim.org>
parents:
29732
diff
changeset
|
538 tabpage_move(c1 <= 0 ? 9999 : c1 - 1); |
b37b74ea8dee
patch 9.0.0259: crash with mouse click when not initialized
Bram Moolenaar <Bram@vim.org>
parents:
29732
diff
changeset
|
539 return FALSE; |
b37b74ea8dee
patch 9.0.0259: crash with mouse click when not initialized
Bram Moolenaar <Bram@vim.org>
parents:
29732
diff
changeset
|
540 } |
18135
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
541 } |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
542 |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
543 // When 'mousemodel' is "popup" or "popup_setpos", translate mouse events: |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
544 // right button up -> pop-up menu |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
545 // shift-left button -> right button |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
546 // alt-left button -> alt-right button |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
547 if (mouse_model_popup()) |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
548 { |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
549 if (which_button == MOUSE_RIGHT |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
550 && !(mod_mask & (MOD_MASK_SHIFT | MOD_MASK_CTRL))) |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
551 { |
18141
2cc67e54edf8
patch 8.1.2065: compiler warning building non-GUI with MinGW.
Bram Moolenaar <Bram@vim.org>
parents:
18135
diff
changeset
|
552 #ifdef USE_POPUP_SETPOS |
18135
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
553 # ifdef FEAT_GUI |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
554 if (gui.in_use) |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
555 { |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
556 # if defined(FEAT_GUI_MOTIF) || defined(FEAT_GUI_GTK) \ |
21745
35921b7fc07a
patch 8.2.1422: the Mac GUI implementation is outdated
Bram Moolenaar <Bram@vim.org>
parents:
21339
diff
changeset
|
557 || defined(FEAT_GUI_PHOTON) |
18135
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
558 if (!is_click) |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
559 // Ignore right button release events, only shows the popup |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
560 // menu on the button down event. |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
561 return FALSE; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
562 # endif |
28303
9849df834f1d
patch 8.2.4677: the Athena GUI support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
28087
diff
changeset
|
563 # if defined(FEAT_GUI_MSWIN) || defined(FEAT_GUI_HAIKU) |
18135
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
564 if (is_click || is_drag) |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
565 // Ignore right button down and drag mouse events. Windows |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
566 // only shows the popup menu on the button up event. |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
567 return FALSE; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
568 # endif |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
569 } |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
570 # endif |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
571 # if defined(FEAT_GUI) && defined(FEAT_TERM_POPUP_MENU) |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
572 else |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
573 # endif |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
574 # if defined(FEAT_TERM_POPUP_MENU) |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
575 if (!is_click) |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
576 // Ignore right button release events, only shows the popup |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
577 // menu on the button down event. |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
578 return FALSE; |
31135
759b181807f7
patch 9.0.0902: some mouse scroll code is not in a good place
Bram Moolenaar <Bram@vim.org>
parents:
31133
diff
changeset
|
579 # endif |
18135
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
580 |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
581 jump_flags = 0; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
582 if (STRCMP(p_mousem, "popup_setpos") == 0) |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
583 { |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
584 // First set the cursor position before showing the popup |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
585 // menu. |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
586 if (VIsual_active) |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
587 { |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
588 pos_T m_pos; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
589 |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
590 // set MOUSE_MAY_STOP_VIS if we are outside the |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
591 // selection or the current window (might have false |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
592 // negative here) |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
593 if (mouse_row < curwin->w_winrow |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
594 || mouse_row |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
595 > (curwin->w_winrow + curwin->w_height)) |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
596 jump_flags = MOUSE_MAY_STOP_VIS; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
597 else if (get_fpos_of_mouse(&m_pos) != IN_BUFFER) |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
598 jump_flags = MOUSE_MAY_STOP_VIS; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
599 else |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
600 { |
30809
ffdb7a6785af
patch 9.0.0739: mouse column not correctly used for popup_setpos
Bram Moolenaar <Bram@vim.org>
parents:
30645
diff
changeset
|
601 if (VIsual_mode == 'V') |
ffdb7a6785af
patch 9.0.0739: mouse column not correctly used for popup_setpos
Bram Moolenaar <Bram@vim.org>
parents:
30645
diff
changeset
|
602 { |
ffdb7a6785af
patch 9.0.0739: mouse column not correctly used for popup_setpos
Bram Moolenaar <Bram@vim.org>
parents:
30645
diff
changeset
|
603 if ((curwin->w_cursor.lnum <= VIsual.lnum |
ffdb7a6785af
patch 9.0.0739: mouse column not correctly used for popup_setpos
Bram Moolenaar <Bram@vim.org>
parents:
30645
diff
changeset
|
604 && (m_pos.lnum < curwin->w_cursor.lnum |
ffdb7a6785af
patch 9.0.0739: mouse column not correctly used for popup_setpos
Bram Moolenaar <Bram@vim.org>
parents:
30645
diff
changeset
|
605 || VIsual.lnum < m_pos.lnum)) |
ffdb7a6785af
patch 9.0.0739: mouse column not correctly used for popup_setpos
Bram Moolenaar <Bram@vim.org>
parents:
30645
diff
changeset
|
606 || (VIsual.lnum < curwin->w_cursor.lnum |
ffdb7a6785af
patch 9.0.0739: mouse column not correctly used for popup_setpos
Bram Moolenaar <Bram@vim.org>
parents:
30645
diff
changeset
|
607 && (m_pos.lnum < VIsual.lnum |
ffdb7a6785af
patch 9.0.0739: mouse column not correctly used for popup_setpos
Bram Moolenaar <Bram@vim.org>
parents:
30645
diff
changeset
|
608 || curwin->w_cursor.lnum < m_pos.lnum))) |
ffdb7a6785af
patch 9.0.0739: mouse column not correctly used for popup_setpos
Bram Moolenaar <Bram@vim.org>
parents:
30645
diff
changeset
|
609 { |
ffdb7a6785af
patch 9.0.0739: mouse column not correctly used for popup_setpos
Bram Moolenaar <Bram@vim.org>
parents:
30645
diff
changeset
|
610 jump_flags = MOUSE_MAY_STOP_VIS; |
ffdb7a6785af
patch 9.0.0739: mouse column not correctly used for popup_setpos
Bram Moolenaar <Bram@vim.org>
parents:
30645
diff
changeset
|
611 } |
ffdb7a6785af
patch 9.0.0739: mouse column not correctly used for popup_setpos
Bram Moolenaar <Bram@vim.org>
parents:
30645
diff
changeset
|
612 } |
ffdb7a6785af
patch 9.0.0739: mouse column not correctly used for popup_setpos
Bram Moolenaar <Bram@vim.org>
parents:
30645
diff
changeset
|
613 else if ((LTOREQ_POS(curwin->w_cursor, VIsual) |
18135
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
614 && (LT_POS(m_pos, curwin->w_cursor) |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
615 || LT_POS(VIsual, m_pos))) |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
616 || (LT_POS(VIsual, curwin->w_cursor) |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
617 && (LT_POS(m_pos, VIsual) |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
618 || LT_POS(curwin->w_cursor, m_pos)))) |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
619 { |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
620 jump_flags = MOUSE_MAY_STOP_VIS; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
621 } |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
622 else if (VIsual_mode == Ctrl_V) |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
623 { |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
624 getvcols(curwin, &curwin->w_cursor, &VIsual, |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
625 &leftcol, &rightcol); |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
626 getvcol(curwin, &m_pos, NULL, &m_pos.col, NULL); |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
627 if (m_pos.col < leftcol || m_pos.col > rightcol) |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
628 jump_flags = MOUSE_MAY_STOP_VIS; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
629 } |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
630 } |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
631 } |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
632 else |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
633 jump_flags = MOUSE_MAY_STOP_VIS; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
634 } |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
635 if (jump_flags) |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
636 { |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
637 jump_flags = jump_to_mouse(jump_flags, NULL, which_button); |
29732
89e1d67814a9
patch 9.0.0206: redraw flags are not named specifically
Bram Moolenaar <Bram@vim.org>
parents:
29674
diff
changeset
|
638 update_curbuf(VIsual_active ? UPD_INVERTED : UPD_VALID); |
18135
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
639 setcursor(); |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
640 out_flush(); // Update before showing popup menu |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
641 } |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
642 # ifdef FEAT_MENU |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
643 show_popupmenu(); |
30980
eb51299c4bfc
patch 9.0.0825: cannot drag an entry in the tabpage line
Bram Moolenaar <Bram@vim.org>
parents:
30974
diff
changeset
|
644 got_click = FALSE; // ignore release events |
18135
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
645 # endif |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
646 return (jump_flags & CURSOR_MOVED) != 0; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
647 #else |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
648 return FALSE; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
649 #endif |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
650 } |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
651 if (which_button == MOUSE_LEFT |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
652 && (mod_mask & (MOD_MASK_SHIFT|MOD_MASK_ALT))) |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
653 { |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
654 which_button = MOUSE_RIGHT; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
655 mod_mask &= ~MOD_MASK_SHIFT; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
656 } |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
657 } |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
658 |
28773
d770568e6c98
patch 8.2.4911: the mode #defines are not clearly named
Bram Moolenaar <Bram@vim.org>
parents:
28755
diff
changeset
|
659 if ((State & (MODE_NORMAL | MODE_INSERT)) |
18135
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
660 && !(mod_mask & (MOD_MASK_SHIFT | MOD_MASK_CTRL))) |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
661 { |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
662 if (which_button == MOUSE_LEFT) |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
663 { |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
664 if (is_click) |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
665 { |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
666 // stop Visual mode for a left click in a window, but not when |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
667 // on a status line |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
668 if (VIsual_active) |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
669 jump_flags |= MOUSE_MAY_STOP_VIS; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
670 } |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
671 else if (mouse_has(MOUSE_VISUAL)) |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
672 jump_flags |= MOUSE_MAY_VIS; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
673 } |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
674 else if (which_button == MOUSE_RIGHT) |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
675 { |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
676 if (is_click && VIsual_active) |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
677 { |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
678 // Remember the start and end of visual before moving the |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
679 // cursor. |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
680 if (LT_POS(curwin->w_cursor, VIsual)) |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
681 { |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
682 start_visual = curwin->w_cursor; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
683 end_visual = VIsual; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
684 } |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
685 else |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
686 { |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
687 start_visual = VIsual; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
688 end_visual = curwin->w_cursor; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
689 } |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
690 } |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
691 jump_flags |= MOUSE_FOCUS; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
692 if (mouse_has(MOUSE_VISUAL)) |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
693 jump_flags |= MOUSE_MAY_VIS; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
694 } |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
695 } |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
696 |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
697 // If an operator is pending, ignore all drags and releases until the |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
698 // next mouse click. |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
699 if (!is_drag && oap != NULL && oap->op_type != OP_NOP) |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
700 { |
30980
eb51299c4bfc
patch 9.0.0825: cannot drag an entry in the tabpage line
Bram Moolenaar <Bram@vim.org>
parents:
30974
diff
changeset
|
701 got_click = FALSE; |
18135
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
702 oap->motion_type = MCHAR; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
703 } |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
704 |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
705 // When releasing the button let jump_to_mouse() know. |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
706 if (!is_click && !is_drag) |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
707 jump_flags |= MOUSE_RELEASED; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
708 |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
709 // JUMP! |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
710 jump_flags = jump_to_mouse(jump_flags, |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
711 oap == NULL ? NULL : &(oap->inclusive), which_button); |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
712 |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
713 #ifdef FEAT_MENU |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
714 // A click in the window toolbar has no side effects. |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
715 if (jump_flags & MOUSE_WINBAR) |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
716 return FALSE; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
717 #endif |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
718 moved = (jump_flags & CURSOR_MOVED); |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
719 in_status_line = (jump_flags & IN_STATUS_LINE); |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
720 in_sep_line = (jump_flags & IN_SEP_LINE); |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
721 |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
722 #ifdef FEAT_NETBEANS_INTG |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
723 if (isNetbeansBuffer(curbuf) |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
724 && !(jump_flags & (IN_STATUS_LINE | IN_SEP_LINE))) |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
725 { |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
726 int key = KEY2TERMCAP1(c); |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
727 |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
728 if (key == (int)KE_LEFTRELEASE || key == (int)KE_MIDDLERELEASE |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
729 || key == (int)KE_RIGHTRELEASE) |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
730 netbeans_button_release(which_button); |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
731 } |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
732 #endif |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
733 |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
734 // When jumping to another window, clear a pending operator. That's a bit |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
735 // friendlier than beeping and not jumping to that window. |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
736 if (curwin != old_curwin && oap != NULL && oap->op_type != OP_NOP) |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
737 clearop(oap); |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
738 |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
739 #ifdef FEAT_FOLDING |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
740 if (mod_mask == 0 |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
741 && !is_drag |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
742 && (jump_flags & (MOUSE_FOLD_CLOSE | MOUSE_FOLD_OPEN)) |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
743 && which_button == MOUSE_LEFT) |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
744 { |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
745 // open or close a fold at this line |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
746 if (jump_flags & MOUSE_FOLD_OPEN) |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
747 openFold(curwin->w_cursor.lnum, 1L); |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
748 else |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
749 closeFold(curwin->w_cursor.lnum, 1L); |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
750 // don't move the cursor if still in the same window |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
751 if (curwin == old_curwin) |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
752 curwin->w_cursor = save_cursor; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
753 } |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
754 #endif |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
755 |
30645
101f08b49ed3
patch 9.0.0657: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
29841
diff
changeset
|
756 #if defined(FEAT_CLIPBOARD) |
18135
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
757 if ((jump_flags & IN_OTHER_WIN) && !VIsual_active && clip_star.available) |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
758 { |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
759 clip_modeless(which_button, is_click, is_drag); |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
760 return FALSE; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
761 } |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
762 #endif |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
763 |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
764 // Set global flag that we are extending the Visual area with mouse |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
765 // dragging; temporarily minimize 'scrolloff'. |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
766 if (VIsual_active && is_drag && get_scrolloff_value()) |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
767 { |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
768 // In the very first line, allow scrolling one line |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
769 if (mouse_row == 0) |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
770 mouse_dragging = 2; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
771 else |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
772 mouse_dragging = 1; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
773 } |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
774 |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
775 // When dragging the mouse above the window, scroll down. |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
776 if (is_drag && mouse_row < 0 && !in_status_line) |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
777 { |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
778 scroll_redraw(FALSE, 1L); |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
779 mouse_row = 0; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
780 } |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
781 |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
782 if (start_visual.lnum) // right click in visual mode |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
783 { |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
784 // When ALT is pressed make Visual mode blockwise. |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
785 if (mod_mask & MOD_MASK_ALT) |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
786 VIsual_mode = Ctrl_V; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
787 |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
788 // In Visual-block mode, divide the area in four, pick up the corner |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
789 // that is in the quarter that the cursor is in. |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
790 if (VIsual_mode == Ctrl_V) |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
791 { |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
792 getvcols(curwin, &start_visual, &end_visual, &leftcol, &rightcol); |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
793 if (curwin->w_curswant > (leftcol + rightcol) / 2) |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
794 end_visual.col = leftcol; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
795 else |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
796 end_visual.col = rightcol; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
797 if (curwin->w_cursor.lnum >= |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
798 (start_visual.lnum + end_visual.lnum) / 2) |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
799 end_visual.lnum = start_visual.lnum; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
800 |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
801 // move VIsual to the right column |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
802 start_visual = curwin->w_cursor; // save the cursor pos |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
803 curwin->w_cursor = end_visual; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
804 coladvance(end_visual.col); |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
805 VIsual = curwin->w_cursor; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
806 curwin->w_cursor = start_visual; // restore the cursor |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
807 } |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
808 else |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
809 { |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
810 // If the click is before the start of visual, change the start. |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
811 // If the click is after the end of visual, change the end. If |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
812 // the click is inside the visual, change the closest side. |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
813 if (LT_POS(curwin->w_cursor, start_visual)) |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
814 VIsual = end_visual; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
815 else if (LT_POS(end_visual, curwin->w_cursor)) |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
816 VIsual = start_visual; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
817 else |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
818 { |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
819 // In the same line, compare column number |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
820 if (end_visual.lnum == start_visual.lnum) |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
821 { |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
822 if (curwin->w_cursor.col - start_visual.col > |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
823 end_visual.col - curwin->w_cursor.col) |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
824 VIsual = start_visual; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
825 else |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
826 VIsual = end_visual; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
827 } |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
828 |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
829 // In different lines, compare line number |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
830 else |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
831 { |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
832 diff = (curwin->w_cursor.lnum - start_visual.lnum) - |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
833 (end_visual.lnum - curwin->w_cursor.lnum); |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
834 |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
835 if (diff > 0) // closest to end |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
836 VIsual = start_visual; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
837 else if (diff < 0) // closest to start |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
838 VIsual = end_visual; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
839 else // in the middle line |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
840 { |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
841 if (curwin->w_cursor.col < |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
842 (start_visual.col + end_visual.col) / 2) |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
843 VIsual = end_visual; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
844 else |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
845 VIsual = start_visual; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
846 } |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
847 } |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
848 } |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
849 } |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
850 } |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
851 // If Visual mode started in insert mode, execute "CTRL-O" |
28773
d770568e6c98
patch 8.2.4911: the mode #defines are not clearly named
Bram Moolenaar <Bram@vim.org>
parents:
28755
diff
changeset
|
852 else if ((State & MODE_INSERT) && VIsual_active) |
18135
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
853 stuffcharReadbuff(Ctrl_O); |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
854 |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
855 // Middle mouse click: Put text before cursor. |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
856 if (which_button == MOUSE_MIDDLE) |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
857 { |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
858 #ifdef FEAT_CLIPBOARD |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
859 if (clip_star.available && regname == 0) |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
860 regname = '*'; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
861 #endif |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
862 if (yank_register_mline(regname)) |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
863 { |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
864 if (mouse_past_bottom) |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
865 dir = FORWARD; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
866 } |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
867 else if (mouse_past_eol) |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
868 dir = FORWARD; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
869 |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
870 if (fixindent) |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
871 { |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
872 c1 = (dir == BACKWARD) ? '[' : ']'; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
873 c2 = 'p'; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
874 } |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
875 else |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
876 { |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
877 c1 = (dir == FORWARD) ? 'p' : 'P'; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
878 c2 = NUL; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
879 } |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
880 prep_redo(regname, count, NUL, c1, NUL, c2, NUL); |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
881 |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
882 // Remember where the paste started, so in edit() Insstart can be set |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
883 // to this position |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
884 if (restart_edit != 0) |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
885 where_paste_started = curwin->w_cursor; |
22176
6941d3205be9
patch 8.2.1637: Vim9: :put ={expr} does not work inside :def function
Bram Moolenaar <Bram@vim.org>
parents:
21745
diff
changeset
|
886 do_put(regname, NULL, dir, count, fixindent | PUT_CURSEND); |
18135
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
887 } |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
888 |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
889 #if defined(FEAT_QUICKFIX) |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
890 // Ctrl-Mouse click or double click in a quickfix window jumps to the |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
891 // error under the mouse pointer. |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
892 else if (((mod_mask & MOD_MASK_CTRL) |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
893 || (mod_mask & MOD_MASK_MULTI_CLICK) == MOD_MASK_2CLICK) |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
894 && bt_quickfix(curbuf)) |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
895 { |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
896 if (curwin->w_llist_ref == NULL) // quickfix window |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
897 do_cmdline_cmd((char_u *)".cc"); |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
898 else // location list window |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
899 do_cmdline_cmd((char_u *)".ll"); |
30980
eb51299c4bfc
patch 9.0.0825: cannot drag an entry in the tabpage line
Bram Moolenaar <Bram@vim.org>
parents:
30974
diff
changeset
|
900 got_click = FALSE; // ignore drag&release now |
18135
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
901 } |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
902 #endif |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
903 |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
904 // Ctrl-Mouse click (or double click in a help window) jumps to the tag |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
905 // under the mouse pointer. |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
906 else if ((mod_mask & MOD_MASK_CTRL) || (curbuf->b_help |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
907 && (mod_mask & MOD_MASK_MULTI_CLICK) == MOD_MASK_2CLICK)) |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
908 { |
28773
d770568e6c98
patch 8.2.4911: the mode #defines are not clearly named
Bram Moolenaar <Bram@vim.org>
parents:
28755
diff
changeset
|
909 if (State & MODE_INSERT) |
18135
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
910 stuffcharReadbuff(Ctrl_O); |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
911 stuffcharReadbuff(Ctrl_RSB); |
30980
eb51299c4bfc
patch 9.0.0825: cannot drag an entry in the tabpage line
Bram Moolenaar <Bram@vim.org>
parents:
30974
diff
changeset
|
912 got_click = FALSE; // ignore drag&release now |
18135
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
913 } |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
914 |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
915 // Shift-Mouse click searches for the next occurrence of the word under |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
916 // the mouse pointer |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
917 else if ((mod_mask & MOD_MASK_SHIFT)) |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
918 { |
28773
d770568e6c98
patch 8.2.4911: the mode #defines are not clearly named
Bram Moolenaar <Bram@vim.org>
parents:
28755
diff
changeset
|
919 if ((State & MODE_INSERT) || (VIsual_active && VIsual_select)) |
18135
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
920 stuffcharReadbuff(Ctrl_O); |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
921 if (which_button == MOUSE_LEFT) |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
922 stuffcharReadbuff('*'); |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
923 else // MOUSE_RIGHT |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
924 stuffcharReadbuff('#'); |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
925 } |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
926 |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
927 // Handle double clicks, unless on status line |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
928 else if (in_status_line) |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
929 { |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
930 #ifdef FEAT_MOUSESHAPE |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
931 if ((is_drag || is_click) && !drag_status_line) |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
932 { |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
933 drag_status_line = TRUE; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
934 update_mouseshape(-1); |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
935 } |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
936 #endif |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
937 } |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
938 else if (in_sep_line) |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
939 { |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
940 #ifdef FEAT_MOUSESHAPE |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
941 if ((is_drag || is_click) && !drag_sep_line) |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
942 { |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
943 drag_sep_line = TRUE; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
944 update_mouseshape(-1); |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
945 } |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
946 #endif |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
947 } |
28773
d770568e6c98
patch 8.2.4911: the mode #defines are not clearly named
Bram Moolenaar <Bram@vim.org>
parents:
28755
diff
changeset
|
948 else if ((mod_mask & MOD_MASK_MULTI_CLICK) |
d770568e6c98
patch 8.2.4911: the mode #defines are not clearly named
Bram Moolenaar <Bram@vim.org>
parents:
28755
diff
changeset
|
949 && (State & (MODE_NORMAL | MODE_INSERT)) |
18135
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
950 && mouse_has(MOUSE_VISUAL)) |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
951 { |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
952 if (is_click || !VIsual_active) |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
953 { |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
954 if (VIsual_active) |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
955 orig_cursor = VIsual; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
956 else |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
957 { |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
958 check_visual_highlight(); |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
959 VIsual = curwin->w_cursor; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
960 orig_cursor = VIsual; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
961 VIsual_active = TRUE; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
962 VIsual_reselect = TRUE; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
963 // start Select mode if 'selectmode' contains "mouse" |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
964 may_start_select('o'); |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
965 setmouse(); |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
966 } |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
967 if ((mod_mask & MOD_MASK_MULTI_CLICK) == MOD_MASK_2CLICK) |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
968 { |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
969 // Double click with ALT pressed makes it blockwise. |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
970 if (mod_mask & MOD_MASK_ALT) |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
971 VIsual_mode = Ctrl_V; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
972 else |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
973 VIsual_mode = 'v'; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
974 } |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
975 else if ((mod_mask & MOD_MASK_MULTI_CLICK) == MOD_MASK_3CLICK) |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
976 VIsual_mode = 'V'; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
977 else if ((mod_mask & MOD_MASK_MULTI_CLICK) == MOD_MASK_4CLICK) |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
978 VIsual_mode = Ctrl_V; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
979 #ifdef FEAT_CLIPBOARD |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
980 // Make sure the clipboard gets updated. Needed because start and |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
981 // end may still be the same, and the selection needs to be owned |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
982 clip_star.vmode = NUL; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
983 #endif |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
984 } |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
985 // A double click selects a word or a block. |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
986 if ((mod_mask & MOD_MASK_MULTI_CLICK) == MOD_MASK_2CLICK) |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
987 { |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
988 pos_T *pos = NULL; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
989 int gc; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
990 |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
991 if (is_click) |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
992 { |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
993 // If the character under the cursor (skipping white space) is |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
994 // not a word character, try finding a match and select a (), |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
995 // {}, [], #if/#endif, etc. block. |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
996 end_visual = curwin->w_cursor; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
997 while (gc = gchar_pos(&end_visual), VIM_ISWHITE(gc)) |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
998 inc(&end_visual); |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
999 if (oap != NULL) |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1000 oap->motion_type = MCHAR; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1001 if (oap != NULL |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1002 && VIsual_mode == 'v' |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1003 && !vim_iswordc(gchar_pos(&end_visual)) |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1004 && EQUAL_POS(curwin->w_cursor, VIsual) |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1005 && (pos = findmatch(oap, NUL)) != NULL) |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1006 { |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1007 curwin->w_cursor = *pos; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1008 if (oap->motion_type == MLINE) |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1009 VIsual_mode = 'V'; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1010 else if (*p_sel == 'e') |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1011 { |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1012 if (LT_POS(curwin->w_cursor, VIsual)) |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1013 ++VIsual.col; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1014 else |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1015 ++curwin->w_cursor.col; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1016 } |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1017 } |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1018 } |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1019 |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1020 if (pos == NULL && (is_click || is_drag)) |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1021 { |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1022 // When not found a match or when dragging: extend to include |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1023 // a word. |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1024 if (LT_POS(curwin->w_cursor, orig_cursor)) |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1025 { |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1026 find_start_of_word(&curwin->w_cursor); |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1027 find_end_of_word(&VIsual); |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1028 } |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1029 else |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1030 { |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1031 find_start_of_word(&VIsual); |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1032 if (*p_sel == 'e' && *ml_get_cursor() != NUL) |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1033 curwin->w_cursor.col += |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1034 (*mb_ptr2len)(ml_get_cursor()); |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1035 find_end_of_word(&curwin->w_cursor); |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1036 } |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1037 } |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1038 curwin->w_set_curswant = TRUE; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1039 } |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1040 if (is_click) |
29732
89e1d67814a9
patch 9.0.0206: redraw flags are not named specifically
Bram Moolenaar <Bram@vim.org>
parents:
29674
diff
changeset
|
1041 redraw_curbuf_later(UPD_INVERTED); // update the inversion |
18135
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1042 } |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1043 else if (VIsual_active && !old_active) |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1044 { |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1045 if (mod_mask & MOD_MASK_ALT) |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1046 VIsual_mode = Ctrl_V; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1047 else |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1048 VIsual_mode = 'v'; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1049 } |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1050 |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1051 // If Visual mode changed show it later. |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1052 if ((!VIsual_active && old_active && mode_displayed) |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1053 || (VIsual_active && p_smd && msg_silent == 0 |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1054 && (!old_active || VIsual_mode != old_mode))) |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1055 redraw_cmdline = TRUE; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1056 |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1057 return moved; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1058 } |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1059 |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1060 void |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1061 ins_mouse(int c) |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1062 { |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1063 pos_T tpos; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1064 win_T *old_curwin = curwin; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1065 |
31135
759b181807f7
patch 9.0.0902: some mouse scroll code is not in a good place
Bram Moolenaar <Bram@vim.org>
parents:
31133
diff
changeset
|
1066 #ifdef FEAT_GUI |
18135
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1067 // When GUI is active, also move/paste when 'mouse' is empty |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1068 if (!gui.in_use) |
31135
759b181807f7
patch 9.0.0902: some mouse scroll code is not in a good place
Bram Moolenaar <Bram@vim.org>
parents:
31133
diff
changeset
|
1069 #endif |
18135
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1070 if (!mouse_has(MOUSE_INSERT)) |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1071 return; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1072 |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1073 undisplay_dollar(); |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1074 tpos = curwin->w_cursor; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1075 if (do_mouse(NULL, c, BACKWARD, 1L, 0)) |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1076 { |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1077 win_T *new_curwin = curwin; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1078 |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1079 if (curwin != old_curwin && win_valid(old_curwin)) |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1080 { |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1081 // Mouse took us to another window. We need to go back to the |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1082 // previous one to stop insert there properly. |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1083 curwin = old_curwin; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1084 curbuf = curwin->w_buffer; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1085 #ifdef FEAT_JOB_CHANNEL |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1086 if (bt_prompt(curbuf)) |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1087 // Restart Insert mode when re-entering the prompt buffer. |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1088 curbuf->b_prompt_insert = 'A'; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1089 #endif |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1090 } |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1091 start_arrow(curwin == old_curwin ? &tpos : NULL); |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1092 if (curwin != new_curwin && win_valid(new_curwin)) |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1093 { |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1094 curwin = new_curwin; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1095 curbuf = curwin->w_buffer; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1096 } |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1097 set_can_cindent(TRUE); |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1098 } |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1099 |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1100 // redraw status lines (in case another window became active) |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1101 redraw_statuslines(); |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1102 } |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1103 |
31103
33ca088dbd3e
patch 9.0.0886: horizontal mouse scroll only works in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
30980
diff
changeset
|
1104 /* |
31144
388ef91ae4f5
patch 9.0.0906: mouse scroll code is not optimal
Bram Moolenaar <Bram@vim.org>
parents:
31135
diff
changeset
|
1105 * Common mouse wheel scrolling, shared between Insert mode and NV modes. |
388ef91ae4f5
patch 9.0.0906: mouse scroll code is not optimal
Bram Moolenaar <Bram@vim.org>
parents:
31135
diff
changeset
|
1106 * Default action is to scroll mouse_vert_step lines (or mouse_hor_step columns |
388ef91ae4f5
patch 9.0.0906: mouse scroll code is not optimal
Bram Moolenaar <Bram@vim.org>
parents:
31135
diff
changeset
|
1107 * depending on the scroll direction) or one page when Shift or Ctrl is used. |
388ef91ae4f5
patch 9.0.0906: mouse scroll code is not optimal
Bram Moolenaar <Bram@vim.org>
parents:
31135
diff
changeset
|
1108 * Direction is indicated by "cap->arg": |
388ef91ae4f5
patch 9.0.0906: mouse scroll code is not optimal
Bram Moolenaar <Bram@vim.org>
parents:
31135
diff
changeset
|
1109 * K_MOUSEUP - MSCR_UP |
388ef91ae4f5
patch 9.0.0906: mouse scroll code is not optimal
Bram Moolenaar <Bram@vim.org>
parents:
31135
diff
changeset
|
1110 * K_MOUSEDOWN - MSCR_DOWN |
388ef91ae4f5
patch 9.0.0906: mouse scroll code is not optimal
Bram Moolenaar <Bram@vim.org>
parents:
31135
diff
changeset
|
1111 * K_MOUSELEFT - MSCR_LEFT |
388ef91ae4f5
patch 9.0.0906: mouse scroll code is not optimal
Bram Moolenaar <Bram@vim.org>
parents:
31135
diff
changeset
|
1112 * K_MOUSERIGHT - MSCR_RIGHT |
388ef91ae4f5
patch 9.0.0906: mouse scroll code is not optimal
Bram Moolenaar <Bram@vim.org>
parents:
31135
diff
changeset
|
1113 * "curwin" may have been changed to the window that should be scrolled and |
388ef91ae4f5
patch 9.0.0906: mouse scroll code is not optimal
Bram Moolenaar <Bram@vim.org>
parents:
31135
diff
changeset
|
1114 * differ from the window that actually has focus. |
388ef91ae4f5
patch 9.0.0906: mouse scroll code is not optimal
Bram Moolenaar <Bram@vim.org>
parents:
31135
diff
changeset
|
1115 */ |
388ef91ae4f5
patch 9.0.0906: mouse scroll code is not optimal
Bram Moolenaar <Bram@vim.org>
parents:
31135
diff
changeset
|
1116 static void |
388ef91ae4f5
patch 9.0.0906: mouse scroll code is not optimal
Bram Moolenaar <Bram@vim.org>
parents:
31135
diff
changeset
|
1117 do_mousescroll(cmdarg_T *cap) |
388ef91ae4f5
patch 9.0.0906: mouse scroll code is not optimal
Bram Moolenaar <Bram@vim.org>
parents:
31135
diff
changeset
|
1118 { |
388ef91ae4f5
patch 9.0.0906: mouse scroll code is not optimal
Bram Moolenaar <Bram@vim.org>
parents:
31135
diff
changeset
|
1119 int shift_or_ctrl = mod_mask & (MOD_MASK_SHIFT | MOD_MASK_CTRL); |
388ef91ae4f5
patch 9.0.0906: mouse scroll code is not optimal
Bram Moolenaar <Bram@vim.org>
parents:
31135
diff
changeset
|
1120 |
388ef91ae4f5
patch 9.0.0906: mouse scroll code is not optimal
Bram Moolenaar <Bram@vim.org>
parents:
31135
diff
changeset
|
1121 #ifdef FEAT_TERMINAL |
388ef91ae4f5
patch 9.0.0906: mouse scroll code is not optimal
Bram Moolenaar <Bram@vim.org>
parents:
31135
diff
changeset
|
1122 if (term_use_loop()) |
388ef91ae4f5
patch 9.0.0906: mouse scroll code is not optimal
Bram Moolenaar <Bram@vim.org>
parents:
31135
diff
changeset
|
1123 // This window is a terminal window, send the mouse event there. |
388ef91ae4f5
patch 9.0.0906: mouse scroll code is not optimal
Bram Moolenaar <Bram@vim.org>
parents:
31135
diff
changeset
|
1124 // Set "typed" to FALSE to avoid an endless loop. |
388ef91ae4f5
patch 9.0.0906: mouse scroll code is not optimal
Bram Moolenaar <Bram@vim.org>
parents:
31135
diff
changeset
|
1125 send_keys_to_term(curbuf->b_term, cap->cmdchar, mod_mask, FALSE); |
388ef91ae4f5
patch 9.0.0906: mouse scroll code is not optimal
Bram Moolenaar <Bram@vim.org>
parents:
31135
diff
changeset
|
1126 else |
388ef91ae4f5
patch 9.0.0906: mouse scroll code is not optimal
Bram Moolenaar <Bram@vim.org>
parents:
31135
diff
changeset
|
1127 #endif |
388ef91ae4f5
patch 9.0.0906: mouse scroll code is not optimal
Bram Moolenaar <Bram@vim.org>
parents:
31135
diff
changeset
|
1128 if (cap->arg == MSCR_UP || cap->arg == MSCR_DOWN) |
388ef91ae4f5
patch 9.0.0906: mouse scroll code is not optimal
Bram Moolenaar <Bram@vim.org>
parents:
31135
diff
changeset
|
1129 { |
388ef91ae4f5
patch 9.0.0906: mouse scroll code is not optimal
Bram Moolenaar <Bram@vim.org>
parents:
31135
diff
changeset
|
1130 // Vertical scrolling |
388ef91ae4f5
patch 9.0.0906: mouse scroll code is not optimal
Bram Moolenaar <Bram@vim.org>
parents:
31135
diff
changeset
|
1131 if (!(State & MODE_INSERT) && (mouse_vert_step < 0 || shift_or_ctrl)) |
388ef91ae4f5
patch 9.0.0906: mouse scroll code is not optimal
Bram Moolenaar <Bram@vim.org>
parents:
31135
diff
changeset
|
1132 { |
388ef91ae4f5
patch 9.0.0906: mouse scroll code is not optimal
Bram Moolenaar <Bram@vim.org>
parents:
31135
diff
changeset
|
1133 // whole page up or down |
388ef91ae4f5
patch 9.0.0906: mouse scroll code is not optimal
Bram Moolenaar <Bram@vim.org>
parents:
31135
diff
changeset
|
1134 onepage(cap->arg == MSCR_UP ? FORWARD : BACKWARD, 1L); |
388ef91ae4f5
patch 9.0.0906: mouse scroll code is not optimal
Bram Moolenaar <Bram@vim.org>
parents:
31135
diff
changeset
|
1135 } |
388ef91ae4f5
patch 9.0.0906: mouse scroll code is not optimal
Bram Moolenaar <Bram@vim.org>
parents:
31135
diff
changeset
|
1136 else |
388ef91ae4f5
patch 9.0.0906: mouse scroll code is not optimal
Bram Moolenaar <Bram@vim.org>
parents:
31135
diff
changeset
|
1137 { |
388ef91ae4f5
patch 9.0.0906: mouse scroll code is not optimal
Bram Moolenaar <Bram@vim.org>
parents:
31135
diff
changeset
|
1138 if (mouse_vert_step < 0 || shift_or_ctrl) |
388ef91ae4f5
patch 9.0.0906: mouse scroll code is not optimal
Bram Moolenaar <Bram@vim.org>
parents:
31135
diff
changeset
|
1139 { |
388ef91ae4f5
patch 9.0.0906: mouse scroll code is not optimal
Bram Moolenaar <Bram@vim.org>
parents:
31135
diff
changeset
|
1140 // whole page up or down |
388ef91ae4f5
patch 9.0.0906: mouse scroll code is not optimal
Bram Moolenaar <Bram@vim.org>
parents:
31135
diff
changeset
|
1141 cap->count1 = (long)(curwin->w_botline - curwin->w_topline); |
388ef91ae4f5
patch 9.0.0906: mouse scroll code is not optimal
Bram Moolenaar <Bram@vim.org>
parents:
31135
diff
changeset
|
1142 } |
388ef91ae4f5
patch 9.0.0906: mouse scroll code is not optimal
Bram Moolenaar <Bram@vim.org>
parents:
31135
diff
changeset
|
1143 // Don't scroll more than half the window height. |
388ef91ae4f5
patch 9.0.0906: mouse scroll code is not optimal
Bram Moolenaar <Bram@vim.org>
parents:
31135
diff
changeset
|
1144 else if (curwin->w_height < mouse_vert_step * 2) |
388ef91ae4f5
patch 9.0.0906: mouse scroll code is not optimal
Bram Moolenaar <Bram@vim.org>
parents:
31135
diff
changeset
|
1145 { |
388ef91ae4f5
patch 9.0.0906: mouse scroll code is not optimal
Bram Moolenaar <Bram@vim.org>
parents:
31135
diff
changeset
|
1146 cap->count1 = curwin->w_height / 2; |
388ef91ae4f5
patch 9.0.0906: mouse scroll code is not optimal
Bram Moolenaar <Bram@vim.org>
parents:
31135
diff
changeset
|
1147 if (cap->count1 == 0) |
388ef91ae4f5
patch 9.0.0906: mouse scroll code is not optimal
Bram Moolenaar <Bram@vim.org>
parents:
31135
diff
changeset
|
1148 cap->count1 = 1; |
388ef91ae4f5
patch 9.0.0906: mouse scroll code is not optimal
Bram Moolenaar <Bram@vim.org>
parents:
31135
diff
changeset
|
1149 } |
388ef91ae4f5
patch 9.0.0906: mouse scroll code is not optimal
Bram Moolenaar <Bram@vim.org>
parents:
31135
diff
changeset
|
1150 else |
388ef91ae4f5
patch 9.0.0906: mouse scroll code is not optimal
Bram Moolenaar <Bram@vim.org>
parents:
31135
diff
changeset
|
1151 { |
388ef91ae4f5
patch 9.0.0906: mouse scroll code is not optimal
Bram Moolenaar <Bram@vim.org>
parents:
31135
diff
changeset
|
1152 cap->count1 = mouse_vert_step; |
388ef91ae4f5
patch 9.0.0906: mouse scroll code is not optimal
Bram Moolenaar <Bram@vim.org>
parents:
31135
diff
changeset
|
1153 } |
388ef91ae4f5
patch 9.0.0906: mouse scroll code is not optimal
Bram Moolenaar <Bram@vim.org>
parents:
31135
diff
changeset
|
1154 cap->count0 = cap->count1; |
388ef91ae4f5
patch 9.0.0906: mouse scroll code is not optimal
Bram Moolenaar <Bram@vim.org>
parents:
31135
diff
changeset
|
1155 nv_scroll_line(cap); |
388ef91ae4f5
patch 9.0.0906: mouse scroll code is not optimal
Bram Moolenaar <Bram@vim.org>
parents:
31135
diff
changeset
|
1156 } |
388ef91ae4f5
patch 9.0.0906: mouse scroll code is not optimal
Bram Moolenaar <Bram@vim.org>
parents:
31135
diff
changeset
|
1157 |
388ef91ae4f5
patch 9.0.0906: mouse scroll code is not optimal
Bram Moolenaar <Bram@vim.org>
parents:
31135
diff
changeset
|
1158 #ifdef FEAT_PROP_POPUP |
388ef91ae4f5
patch 9.0.0906: mouse scroll code is not optimal
Bram Moolenaar <Bram@vim.org>
parents:
31135
diff
changeset
|
1159 if (WIN_IS_POPUP(curwin)) |
388ef91ae4f5
patch 9.0.0906: mouse scroll code is not optimal
Bram Moolenaar <Bram@vim.org>
parents:
31135
diff
changeset
|
1160 popup_set_firstline(curwin); |
388ef91ae4f5
patch 9.0.0906: mouse scroll code is not optimal
Bram Moolenaar <Bram@vim.org>
parents:
31135
diff
changeset
|
1161 #endif |
388ef91ae4f5
patch 9.0.0906: mouse scroll code is not optimal
Bram Moolenaar <Bram@vim.org>
parents:
31135
diff
changeset
|
1162 } |
388ef91ae4f5
patch 9.0.0906: mouse scroll code is not optimal
Bram Moolenaar <Bram@vim.org>
parents:
31135
diff
changeset
|
1163 else |
388ef91ae4f5
patch 9.0.0906: mouse scroll code is not optimal
Bram Moolenaar <Bram@vim.org>
parents:
31135
diff
changeset
|
1164 { |
388ef91ae4f5
patch 9.0.0906: mouse scroll code is not optimal
Bram Moolenaar <Bram@vim.org>
parents:
31135
diff
changeset
|
1165 // Horizontal scrolling |
388ef91ae4f5
patch 9.0.0906: mouse scroll code is not optimal
Bram Moolenaar <Bram@vim.org>
parents:
31135
diff
changeset
|
1166 long step = (mouse_hor_step < 0 || shift_or_ctrl) |
388ef91ae4f5
patch 9.0.0906: mouse scroll code is not optimal
Bram Moolenaar <Bram@vim.org>
parents:
31135
diff
changeset
|
1167 ? curwin->w_width : mouse_hor_step; |
388ef91ae4f5
patch 9.0.0906: mouse scroll code is not optimal
Bram Moolenaar <Bram@vim.org>
parents:
31135
diff
changeset
|
1168 long leftcol = curwin->w_leftcol |
388ef91ae4f5
patch 9.0.0906: mouse scroll code is not optimal
Bram Moolenaar <Bram@vim.org>
parents:
31135
diff
changeset
|
1169 + (cap->arg == MSCR_RIGHT ? -step : step); |
388ef91ae4f5
patch 9.0.0906: mouse scroll code is not optimal
Bram Moolenaar <Bram@vim.org>
parents:
31135
diff
changeset
|
1170 if (leftcol < 0) |
388ef91ae4f5
patch 9.0.0906: mouse scroll code is not optimal
Bram Moolenaar <Bram@vim.org>
parents:
31135
diff
changeset
|
1171 leftcol = 0; |
388ef91ae4f5
patch 9.0.0906: mouse scroll code is not optimal
Bram Moolenaar <Bram@vim.org>
parents:
31135
diff
changeset
|
1172 do_mousescroll_horiz((long_u)leftcol); |
388ef91ae4f5
patch 9.0.0906: mouse scroll code is not optimal
Bram Moolenaar <Bram@vim.org>
parents:
31135
diff
changeset
|
1173 } |
31166
a86ee6c0309e
patch 9.0.0917: the WinScrolled autocommand event is not enough
Bram Moolenaar <Bram@vim.org>
parents:
31154
diff
changeset
|
1174 may_trigger_win_scrolled_resized(); |
31144
388ef91ae4f5
patch 9.0.0906: mouse scroll code is not optimal
Bram Moolenaar <Bram@vim.org>
parents:
31135
diff
changeset
|
1175 } |
388ef91ae4f5
patch 9.0.0906: mouse scroll code is not optimal
Bram Moolenaar <Bram@vim.org>
parents:
31135
diff
changeset
|
1176 |
388ef91ae4f5
patch 9.0.0906: mouse scroll code is not optimal
Bram Moolenaar <Bram@vim.org>
parents:
31135
diff
changeset
|
1177 /* |
388ef91ae4f5
patch 9.0.0906: mouse scroll code is not optimal
Bram Moolenaar <Bram@vim.org>
parents:
31135
diff
changeset
|
1178 * Insert mode implementation for scrolling in direction "dir", which is |
388ef91ae4f5
patch 9.0.0906: mouse scroll code is not optimal
Bram Moolenaar <Bram@vim.org>
parents:
31135
diff
changeset
|
1179 * one of the MSCR_ values. |
31103
33ca088dbd3e
patch 9.0.0886: horizontal mouse scroll only works in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
30980
diff
changeset
|
1180 */ |
18135
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1181 void |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1182 ins_mousescroll(int dir) |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1183 { |
31135
759b181807f7
patch 9.0.0902: some mouse scroll code is not in a good place
Bram Moolenaar <Bram@vim.org>
parents:
31133
diff
changeset
|
1184 cmdarg_T cap; |
759b181807f7
patch 9.0.0902: some mouse scroll code is not in a good place
Bram Moolenaar <Bram@vim.org>
parents:
31133
diff
changeset
|
1185 oparg_T oa; |
31103
33ca088dbd3e
patch 9.0.0886: horizontal mouse scroll only works in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
30980
diff
changeset
|
1186 CLEAR_FIELD(cap); |
33ca088dbd3e
patch 9.0.0886: horizontal mouse scroll only works in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
30980
diff
changeset
|
1187 clear_oparg(&oa); |
33ca088dbd3e
patch 9.0.0886: horizontal mouse scroll only works in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
30980
diff
changeset
|
1188 cap.oap = &oa; |
31135
759b181807f7
patch 9.0.0902: some mouse scroll code is not in a good place
Bram Moolenaar <Bram@vim.org>
parents:
31133
diff
changeset
|
1189 cap.arg = dir; |
28755
26a2836923d6
patch 8.2.4902: mouse wheel scrolling is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
28558
diff
changeset
|
1190 |
31103
33ca088dbd3e
patch 9.0.0886: horizontal mouse scroll only works in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
30980
diff
changeset
|
1191 switch (dir) |
33ca088dbd3e
patch 9.0.0886: horizontal mouse scroll only works in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
30980
diff
changeset
|
1192 { |
33ca088dbd3e
patch 9.0.0886: horizontal mouse scroll only works in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
30980
diff
changeset
|
1193 case MSCR_UP: |
33ca088dbd3e
patch 9.0.0886: horizontal mouse scroll only works in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
30980
diff
changeset
|
1194 cap.cmdchar = K_MOUSEUP; |
33ca088dbd3e
patch 9.0.0886: horizontal mouse scroll only works in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
30980
diff
changeset
|
1195 break; |
33ca088dbd3e
patch 9.0.0886: horizontal mouse scroll only works in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
30980
diff
changeset
|
1196 case MSCR_DOWN: |
33ca088dbd3e
patch 9.0.0886: horizontal mouse scroll only works in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
30980
diff
changeset
|
1197 cap.cmdchar = K_MOUSEDOWN; |
33ca088dbd3e
patch 9.0.0886: horizontal mouse scroll only works in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
30980
diff
changeset
|
1198 break; |
33ca088dbd3e
patch 9.0.0886: horizontal mouse scroll only works in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
30980
diff
changeset
|
1199 case MSCR_LEFT: |
33ca088dbd3e
patch 9.0.0886: horizontal mouse scroll only works in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
30980
diff
changeset
|
1200 cap.cmdchar = K_MOUSELEFT; |
33ca088dbd3e
patch 9.0.0886: horizontal mouse scroll only works in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
30980
diff
changeset
|
1201 break; |
33ca088dbd3e
patch 9.0.0886: horizontal mouse scroll only works in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
30980
diff
changeset
|
1202 case MSCR_RIGHT: |
33ca088dbd3e
patch 9.0.0886: horizontal mouse scroll only works in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
30980
diff
changeset
|
1203 cap.cmdchar = K_MOUSERIGHT; |
33ca088dbd3e
patch 9.0.0886: horizontal mouse scroll only works in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
30980
diff
changeset
|
1204 break; |
33ca088dbd3e
patch 9.0.0886: horizontal mouse scroll only works in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
30980
diff
changeset
|
1205 default: |
33ca088dbd3e
patch 9.0.0886: horizontal mouse scroll only works in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
30980
diff
changeset
|
1206 siemsg("Invalid ins_mousescroll() argument: %d", dir); |
18135
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1207 } |
31135
759b181807f7
patch 9.0.0902: some mouse scroll code is not in a good place
Bram Moolenaar <Bram@vim.org>
parents:
31133
diff
changeset
|
1208 |
31144
388ef91ae4f5
patch 9.0.0906: mouse scroll code is not optimal
Bram Moolenaar <Bram@vim.org>
parents:
31135
diff
changeset
|
1209 win_T *old_curwin = curwin; |
31135
759b181807f7
patch 9.0.0902: some mouse scroll code is not in a good place
Bram Moolenaar <Bram@vim.org>
parents:
31133
diff
changeset
|
1210 if (mouse_row >= 0 && mouse_col >= 0) |
759b181807f7
patch 9.0.0902: some mouse scroll code is not in a good place
Bram Moolenaar <Bram@vim.org>
parents:
31133
diff
changeset
|
1211 { |
759b181807f7
patch 9.0.0902: some mouse scroll code is not in a good place
Bram Moolenaar <Bram@vim.org>
parents:
31133
diff
changeset
|
1212 // Find the window at the mouse pointer coordinates. |
31144
388ef91ae4f5
patch 9.0.0906: mouse scroll code is not optimal
Bram Moolenaar <Bram@vim.org>
parents:
31135
diff
changeset
|
1213 // NOTE: Must restore "curwin" to "old_curwin" before returning! |
31135
759b181807f7
patch 9.0.0902: some mouse scroll code is not in a good place
Bram Moolenaar <Bram@vim.org>
parents:
31133
diff
changeset
|
1214 int row = mouse_row; |
759b181807f7
patch 9.0.0902: some mouse scroll code is not in a good place
Bram Moolenaar <Bram@vim.org>
parents:
31133
diff
changeset
|
1215 int col = mouse_col; |
31144
388ef91ae4f5
patch 9.0.0906: mouse scroll code is not optimal
Bram Moolenaar <Bram@vim.org>
parents:
31135
diff
changeset
|
1216 curwin = mouse_find_win(&row, &col, FIND_POPUP); |
388ef91ae4f5
patch 9.0.0906: mouse scroll code is not optimal
Bram Moolenaar <Bram@vim.org>
parents:
31135
diff
changeset
|
1217 if (curwin == NULL) |
388ef91ae4f5
patch 9.0.0906: mouse scroll code is not optimal
Bram Moolenaar <Bram@vim.org>
parents:
31135
diff
changeset
|
1218 { |
388ef91ae4f5
patch 9.0.0906: mouse scroll code is not optimal
Bram Moolenaar <Bram@vim.org>
parents:
31135
diff
changeset
|
1219 curwin = old_curwin; |
31135
759b181807f7
patch 9.0.0902: some mouse scroll code is not in a good place
Bram Moolenaar <Bram@vim.org>
parents:
31133
diff
changeset
|
1220 return; |
31144
388ef91ae4f5
patch 9.0.0906: mouse scroll code is not optimal
Bram Moolenaar <Bram@vim.org>
parents:
31135
diff
changeset
|
1221 } |
388ef91ae4f5
patch 9.0.0906: mouse scroll code is not optimal
Bram Moolenaar <Bram@vim.org>
parents:
31135
diff
changeset
|
1222 curbuf = curwin->w_buffer; |
31135
759b181807f7
patch 9.0.0902: some mouse scroll code is not in a good place
Bram Moolenaar <Bram@vim.org>
parents:
31133
diff
changeset
|
1223 } |
759b181807f7
patch 9.0.0902: some mouse scroll code is not in a good place
Bram Moolenaar <Bram@vim.org>
parents:
31133
diff
changeset
|
1224 |
31144
388ef91ae4f5
patch 9.0.0906: mouse scroll code is not optimal
Bram Moolenaar <Bram@vim.org>
parents:
31135
diff
changeset
|
1225 if (curwin == old_curwin) |
31135
759b181807f7
patch 9.0.0902: some mouse scroll code is not in a good place
Bram Moolenaar <Bram@vim.org>
parents:
31133
diff
changeset
|
1226 { |
759b181807f7
patch 9.0.0902: some mouse scroll code is not in a good place
Bram Moolenaar <Bram@vim.org>
parents:
31133
diff
changeset
|
1227 // Don't scroll the current window if the popup menu is visible. |
759b181807f7
patch 9.0.0902: some mouse scroll code is not in a good place
Bram Moolenaar <Bram@vim.org>
parents:
31133
diff
changeset
|
1228 if (pum_visible()) |
759b181807f7
patch 9.0.0902: some mouse scroll code is not in a good place
Bram Moolenaar <Bram@vim.org>
parents:
31133
diff
changeset
|
1229 return; |
759b181807f7
patch 9.0.0902: some mouse scroll code is not in a good place
Bram Moolenaar <Bram@vim.org>
parents:
31133
diff
changeset
|
1230 |
759b181807f7
patch 9.0.0902: some mouse scroll code is not in a good place
Bram Moolenaar <Bram@vim.org>
parents:
31133
diff
changeset
|
1231 undisplay_dollar(); |
759b181807f7
patch 9.0.0902: some mouse scroll code is not in a good place
Bram Moolenaar <Bram@vim.org>
parents:
31133
diff
changeset
|
1232 } |
759b181807f7
patch 9.0.0902: some mouse scroll code is not in a good place
Bram Moolenaar <Bram@vim.org>
parents:
31133
diff
changeset
|
1233 |
31144
388ef91ae4f5
patch 9.0.0906: mouse scroll code is not optimal
Bram Moolenaar <Bram@vim.org>
parents:
31135
diff
changeset
|
1234 linenr_T orig_topline = curwin->w_topline; |
388ef91ae4f5
patch 9.0.0906: mouse scroll code is not optimal
Bram Moolenaar <Bram@vim.org>
parents:
31135
diff
changeset
|
1235 colnr_T orig_leftcol = curwin->w_leftcol; |
31135
759b181807f7
patch 9.0.0902: some mouse scroll code is not in a good place
Bram Moolenaar <Bram@vim.org>
parents:
31133
diff
changeset
|
1236 pos_T orig_cursor = curwin->w_cursor; |
759b181807f7
patch 9.0.0902: some mouse scroll code is not in a good place
Bram Moolenaar <Bram@vim.org>
parents:
31133
diff
changeset
|
1237 |
31144
388ef91ae4f5
patch 9.0.0906: mouse scroll code is not optimal
Bram Moolenaar <Bram@vim.org>
parents:
31135
diff
changeset
|
1238 // Call the common mouse scroll function shared with other modes. |
388ef91ae4f5
patch 9.0.0906: mouse scroll code is not optimal
Bram Moolenaar <Bram@vim.org>
parents:
31135
diff
changeset
|
1239 do_mousescroll(&cap); |
388ef91ae4f5
patch 9.0.0906: mouse scroll code is not optimal
Bram Moolenaar <Bram@vim.org>
parents:
31135
diff
changeset
|
1240 |
388ef91ae4f5
patch 9.0.0906: mouse scroll code is not optimal
Bram Moolenaar <Bram@vim.org>
parents:
31135
diff
changeset
|
1241 int did_scroll = (orig_topline != curwin->w_topline |
388ef91ae4f5
patch 9.0.0906: mouse scroll code is not optimal
Bram Moolenaar <Bram@vim.org>
parents:
31135
diff
changeset
|
1242 || orig_leftcol != curwin->w_leftcol); |
388ef91ae4f5
patch 9.0.0906: mouse scroll code is not optimal
Bram Moolenaar <Bram@vim.org>
parents:
31135
diff
changeset
|
1243 |
388ef91ae4f5
patch 9.0.0906: mouse scroll code is not optimal
Bram Moolenaar <Bram@vim.org>
parents:
31135
diff
changeset
|
1244 curwin->w_redr_status = TRUE; |
388ef91ae4f5
patch 9.0.0906: mouse scroll code is not optimal
Bram Moolenaar <Bram@vim.org>
parents:
31135
diff
changeset
|
1245 curwin = old_curwin; |
388ef91ae4f5
patch 9.0.0906: mouse scroll code is not optimal
Bram Moolenaar <Bram@vim.org>
parents:
31135
diff
changeset
|
1246 curbuf = curwin->w_buffer; |
31135
759b181807f7
patch 9.0.0902: some mouse scroll code is not in a good place
Bram Moolenaar <Bram@vim.org>
parents:
31133
diff
changeset
|
1247 |
759b181807f7
patch 9.0.0902: some mouse scroll code is not in a good place
Bram Moolenaar <Bram@vim.org>
parents:
31133
diff
changeset
|
1248 // If the window actually scrolled and the popup menu may overlay the |
759b181807f7
patch 9.0.0902: some mouse scroll code is not in a good place
Bram Moolenaar <Bram@vim.org>
parents:
31133
diff
changeset
|
1249 // window, need to redraw it. |
31144
388ef91ae4f5
patch 9.0.0906: mouse scroll code is not optimal
Bram Moolenaar <Bram@vim.org>
parents:
31135
diff
changeset
|
1250 if (did_scroll && pum_visible()) |
31135
759b181807f7
patch 9.0.0902: some mouse scroll code is not in a good place
Bram Moolenaar <Bram@vim.org>
parents:
31133
diff
changeset
|
1251 { |
759b181807f7
patch 9.0.0902: some mouse scroll code is not in a good place
Bram Moolenaar <Bram@vim.org>
parents:
31133
diff
changeset
|
1252 // TODO: Would be more efficient to only redraw the windows that are |
759b181807f7
patch 9.0.0902: some mouse scroll code is not in a good place
Bram Moolenaar <Bram@vim.org>
parents:
31133
diff
changeset
|
1253 // overlapped by the popup menu. |
759b181807f7
patch 9.0.0902: some mouse scroll code is not in a good place
Bram Moolenaar <Bram@vim.org>
parents:
31133
diff
changeset
|
1254 redraw_all_later(UPD_NOT_VALID); |
759b181807f7
patch 9.0.0902: some mouse scroll code is not in a good place
Bram Moolenaar <Bram@vim.org>
parents:
31133
diff
changeset
|
1255 ins_compl_show_pum(); |
759b181807f7
patch 9.0.0902: some mouse scroll code is not in a good place
Bram Moolenaar <Bram@vim.org>
parents:
31133
diff
changeset
|
1256 } |
759b181807f7
patch 9.0.0902: some mouse scroll code is not in a good place
Bram Moolenaar <Bram@vim.org>
parents:
31133
diff
changeset
|
1257 |
759b181807f7
patch 9.0.0902: some mouse scroll code is not in a good place
Bram Moolenaar <Bram@vim.org>
parents:
31133
diff
changeset
|
1258 if (!EQUAL_POS(curwin->w_cursor, orig_cursor)) |
759b181807f7
patch 9.0.0902: some mouse scroll code is not in a good place
Bram Moolenaar <Bram@vim.org>
parents:
31133
diff
changeset
|
1259 { |
759b181807f7
patch 9.0.0902: some mouse scroll code is not in a good place
Bram Moolenaar <Bram@vim.org>
parents:
31133
diff
changeset
|
1260 start_arrow(&orig_cursor); |
759b181807f7
patch 9.0.0902: some mouse scroll code is not in a good place
Bram Moolenaar <Bram@vim.org>
parents:
31133
diff
changeset
|
1261 set_can_cindent(TRUE); |
759b181807f7
patch 9.0.0902: some mouse scroll code is not in a good place
Bram Moolenaar <Bram@vim.org>
parents:
31133
diff
changeset
|
1262 } |
18135
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1263 } |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1264 |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1265 /* |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1266 * Return TRUE if "c" is a mouse key. |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1267 */ |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1268 int |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1269 is_mouse_key(int c) |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1270 { |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1271 return c == K_LEFTMOUSE |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1272 || c == K_LEFTMOUSE_NM |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1273 || c == K_LEFTDRAG |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1274 || c == K_LEFTRELEASE |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1275 || c == K_LEFTRELEASE_NM |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1276 || c == K_MOUSEMOVE |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1277 || c == K_MIDDLEMOUSE |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1278 || c == K_MIDDLEDRAG |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1279 || c == K_MIDDLERELEASE |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1280 || c == K_RIGHTMOUSE |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1281 || c == K_RIGHTDRAG |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1282 || c == K_RIGHTRELEASE |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1283 || c == K_MOUSEDOWN |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1284 || c == K_MOUSEUP |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1285 || c == K_MOUSELEFT |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1286 || c == K_MOUSERIGHT |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1287 || c == K_X1MOUSE |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1288 || c == K_X1DRAG |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1289 || c == K_X1RELEASE |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1290 || c == K_X2MOUSE |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1291 || c == K_X2DRAG |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1292 || c == K_X2RELEASE; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1293 } |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1294 |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1295 static struct mousetable |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1296 { |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1297 int pseudo_code; // Code for pseudo mouse event |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1298 int button; // Which mouse button is it? |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1299 int is_click; // Is it a mouse button click event? |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1300 int is_drag; // Is it a mouse drag event? |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1301 } mouse_table[] = |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1302 { |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1303 {(int)KE_LEFTMOUSE, MOUSE_LEFT, TRUE, FALSE}, |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1304 #ifdef FEAT_GUI |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1305 {(int)KE_LEFTMOUSE_NM, MOUSE_LEFT, TRUE, FALSE}, |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1306 #endif |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1307 {(int)KE_LEFTDRAG, MOUSE_LEFT, FALSE, TRUE}, |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1308 {(int)KE_LEFTRELEASE, MOUSE_LEFT, FALSE, FALSE}, |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1309 #ifdef FEAT_GUI |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1310 {(int)KE_LEFTRELEASE_NM, MOUSE_LEFT, FALSE, FALSE}, |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1311 #endif |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1312 {(int)KE_MIDDLEMOUSE, MOUSE_MIDDLE, TRUE, FALSE}, |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1313 {(int)KE_MIDDLEDRAG, MOUSE_MIDDLE, FALSE, TRUE}, |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1314 {(int)KE_MIDDLERELEASE, MOUSE_MIDDLE, FALSE, FALSE}, |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1315 {(int)KE_RIGHTMOUSE, MOUSE_RIGHT, TRUE, FALSE}, |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1316 {(int)KE_RIGHTDRAG, MOUSE_RIGHT, FALSE, TRUE}, |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1317 {(int)KE_RIGHTRELEASE, MOUSE_RIGHT, FALSE, FALSE}, |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1318 {(int)KE_X1MOUSE, MOUSE_X1, TRUE, FALSE}, |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1319 {(int)KE_X1DRAG, MOUSE_X1, FALSE, TRUE}, |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1320 {(int)KE_X1RELEASE, MOUSE_X1, FALSE, FALSE}, |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1321 {(int)KE_X2MOUSE, MOUSE_X2, TRUE, FALSE}, |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1322 {(int)KE_X2DRAG, MOUSE_X2, FALSE, TRUE}, |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1323 {(int)KE_X2RELEASE, MOUSE_X2, FALSE, FALSE}, |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1324 // DRAG without CLICK |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1325 {(int)KE_MOUSEMOVE, MOUSE_RELEASE, FALSE, TRUE}, |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1326 // RELEASE without CLICK |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1327 {(int)KE_IGNORE, MOUSE_RELEASE, FALSE, FALSE}, |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1328 {0, 0, 0, 0}, |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1329 }; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1330 |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1331 /* |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1332 * Look up the given mouse code to return the relevant information in the other |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1333 * arguments. Return which button is down or was released. |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1334 */ |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1335 int |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1336 get_mouse_button(int code, int *is_click, int *is_drag) |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1337 { |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1338 int i; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1339 |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1340 for (i = 0; mouse_table[i].pseudo_code; i++) |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1341 if (code == mouse_table[i].pseudo_code) |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1342 { |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1343 *is_click = mouse_table[i].is_click; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1344 *is_drag = mouse_table[i].is_drag; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1345 return mouse_table[i].button; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1346 } |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1347 return 0; // Shouldn't get here |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1348 } |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1349 |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1350 /* |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1351 * Return the appropriate pseudo mouse event token (KE_LEFTMOUSE etc) based on |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1352 * the given information about which mouse button is down, and whether the |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1353 * mouse was clicked, dragged or released. |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1354 */ |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1355 int |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1356 get_pseudo_mouse_code( |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1357 int button, // eg MOUSE_LEFT |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1358 int is_click, |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1359 int is_drag) |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1360 { |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1361 int i; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1362 |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1363 for (i = 0; mouse_table[i].pseudo_code; i++) |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1364 if (button == mouse_table[i].button |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1365 && is_click == mouse_table[i].is_click |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1366 && is_drag == mouse_table[i].is_drag) |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1367 { |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1368 #ifdef FEAT_GUI |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1369 // Trick: a non mappable left click and release has mouse_col -1 |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1370 // or added MOUSE_COLOFF. Used for 'mousefocus' in |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1371 // gui_mouse_moved() |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1372 if (mouse_col < 0 || mouse_col > MOUSE_COLOFF) |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1373 { |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1374 if (mouse_col < 0) |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1375 mouse_col = 0; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1376 else |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1377 mouse_col -= MOUSE_COLOFF; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1378 if (mouse_table[i].pseudo_code == (int)KE_LEFTMOUSE) |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1379 return (int)KE_LEFTMOUSE_NM; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1380 if (mouse_table[i].pseudo_code == (int)KE_LEFTRELEASE) |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1381 return (int)KE_LEFTRELEASE_NM; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1382 } |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1383 #endif |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1384 return mouse_table[i].pseudo_code; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1385 } |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1386 return (int)KE_IGNORE; // not recognized, ignore it |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1387 } |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1388 |
18354
9f51d0cef8da
patch 8.1.2171: mouse support not always available
Bram Moolenaar <Bram@vim.org>
parents:
18150
diff
changeset
|
1389 # define HMT_NORMAL 1 |
9f51d0cef8da
patch 8.1.2171: mouse support not always available
Bram Moolenaar <Bram@vim.org>
parents:
18150
diff
changeset
|
1390 # define HMT_NETTERM 2 |
9f51d0cef8da
patch 8.1.2171: mouse support not always available
Bram Moolenaar <Bram@vim.org>
parents:
18150
diff
changeset
|
1391 # define HMT_DEC 4 |
9f51d0cef8da
patch 8.1.2171: mouse support not always available
Bram Moolenaar <Bram@vim.org>
parents:
18150
diff
changeset
|
1392 # define HMT_JSBTERM 8 |
9f51d0cef8da
patch 8.1.2171: mouse support not always available
Bram Moolenaar <Bram@vim.org>
parents:
18150
diff
changeset
|
1393 # define HMT_PTERM 16 |
9f51d0cef8da
patch 8.1.2171: mouse support not always available
Bram Moolenaar <Bram@vim.org>
parents:
18150
diff
changeset
|
1394 # define HMT_URXVT 32 |
9f51d0cef8da
patch 8.1.2171: mouse support not always available
Bram Moolenaar <Bram@vim.org>
parents:
18150
diff
changeset
|
1395 # define HMT_GPM 64 |
9f51d0cef8da
patch 8.1.2171: mouse support not always available
Bram Moolenaar <Bram@vim.org>
parents:
18150
diff
changeset
|
1396 # define HMT_SGR 128 |
9f51d0cef8da
patch 8.1.2171: mouse support not always available
Bram Moolenaar <Bram@vim.org>
parents:
18150
diff
changeset
|
1397 # define HMT_SGR_REL 256 |
18135
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1398 static int has_mouse_termcode = 0; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1399 |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1400 void |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1401 set_mouse_termcode( |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1402 int n, // KS_MOUSE, KS_NETTERM_MOUSE or KS_DEC_MOUSE |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1403 char_u *s) |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1404 { |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1405 char_u name[2]; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1406 |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1407 name[0] = n; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1408 name[1] = KE_FILLER; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1409 add_termcode(name, s, FALSE); |
31135
759b181807f7
patch 9.0.0902: some mouse scroll code is not in a good place
Bram Moolenaar <Bram@vim.org>
parents:
31133
diff
changeset
|
1410 #ifdef FEAT_MOUSE_JSB |
18135
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1411 if (n == KS_JSBTERM_MOUSE) |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1412 has_mouse_termcode |= HMT_JSBTERM; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1413 else |
31135
759b181807f7
patch 9.0.0902: some mouse scroll code is not in a good place
Bram Moolenaar <Bram@vim.org>
parents:
31133
diff
changeset
|
1414 #endif |
759b181807f7
patch 9.0.0902: some mouse scroll code is not in a good place
Bram Moolenaar <Bram@vim.org>
parents:
31133
diff
changeset
|
1415 #ifdef FEAT_MOUSE_NET |
18135
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1416 if (n == KS_NETTERM_MOUSE) |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1417 has_mouse_termcode |= HMT_NETTERM; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1418 else |
31135
759b181807f7
patch 9.0.0902: some mouse scroll code is not in a good place
Bram Moolenaar <Bram@vim.org>
parents:
31133
diff
changeset
|
1419 #endif |
759b181807f7
patch 9.0.0902: some mouse scroll code is not in a good place
Bram Moolenaar <Bram@vim.org>
parents:
31133
diff
changeset
|
1420 #ifdef FEAT_MOUSE_DEC |
18135
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1421 if (n == KS_DEC_MOUSE) |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1422 has_mouse_termcode |= HMT_DEC; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1423 else |
31135
759b181807f7
patch 9.0.0902: some mouse scroll code is not in a good place
Bram Moolenaar <Bram@vim.org>
parents:
31133
diff
changeset
|
1424 #endif |
759b181807f7
patch 9.0.0902: some mouse scroll code is not in a good place
Bram Moolenaar <Bram@vim.org>
parents:
31133
diff
changeset
|
1425 #ifdef FEAT_MOUSE_PTERM |
18135
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1426 if (n == KS_PTERM_MOUSE) |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1427 has_mouse_termcode |= HMT_PTERM; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1428 else |
31135
759b181807f7
patch 9.0.0902: some mouse scroll code is not in a good place
Bram Moolenaar <Bram@vim.org>
parents:
31133
diff
changeset
|
1429 #endif |
759b181807f7
patch 9.0.0902: some mouse scroll code is not in a good place
Bram Moolenaar <Bram@vim.org>
parents:
31133
diff
changeset
|
1430 #ifdef FEAT_MOUSE_URXVT |
18135
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1431 if (n == KS_URXVT_MOUSE) |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1432 has_mouse_termcode |= HMT_URXVT; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1433 else |
31135
759b181807f7
patch 9.0.0902: some mouse scroll code is not in a good place
Bram Moolenaar <Bram@vim.org>
parents:
31133
diff
changeset
|
1434 #endif |
759b181807f7
patch 9.0.0902: some mouse scroll code is not in a good place
Bram Moolenaar <Bram@vim.org>
parents:
31133
diff
changeset
|
1435 #ifdef FEAT_MOUSE_GPM |
18135
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1436 if (n == KS_GPM_MOUSE) |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1437 has_mouse_termcode |= HMT_GPM; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1438 else |
31135
759b181807f7
patch 9.0.0902: some mouse scroll code is not in a good place
Bram Moolenaar <Bram@vim.org>
parents:
31133
diff
changeset
|
1439 #endif |
18135
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1440 if (n == KS_SGR_MOUSE) |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1441 has_mouse_termcode |= HMT_SGR; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1442 else if (n == KS_SGR_MOUSE_RELEASE) |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1443 has_mouse_termcode |= HMT_SGR_REL; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1444 else |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1445 has_mouse_termcode |= HMT_NORMAL; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1446 } |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1447 |
31135
759b181807f7
patch 9.0.0902: some mouse scroll code is not in a good place
Bram Moolenaar <Bram@vim.org>
parents:
31133
diff
changeset
|
1448 #if defined(UNIX) || defined(VMS) || defined(PROTO) |
18135
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1449 void |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1450 del_mouse_termcode( |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1451 int n) // KS_MOUSE, KS_NETTERM_MOUSE or KS_DEC_MOUSE |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1452 { |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1453 char_u name[2]; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1454 |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1455 name[0] = n; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1456 name[1] = KE_FILLER; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1457 del_termcode(name); |
31135
759b181807f7
patch 9.0.0902: some mouse scroll code is not in a good place
Bram Moolenaar <Bram@vim.org>
parents:
31133
diff
changeset
|
1458 # ifdef FEAT_MOUSE_JSB |
18135
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1459 if (n == KS_JSBTERM_MOUSE) |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1460 has_mouse_termcode &= ~HMT_JSBTERM; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1461 else |
31135
759b181807f7
patch 9.0.0902: some mouse scroll code is not in a good place
Bram Moolenaar <Bram@vim.org>
parents:
31133
diff
changeset
|
1462 # endif |
759b181807f7
patch 9.0.0902: some mouse scroll code is not in a good place
Bram Moolenaar <Bram@vim.org>
parents:
31133
diff
changeset
|
1463 # ifdef FEAT_MOUSE_NET |
18135
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1464 if (n == KS_NETTERM_MOUSE) |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1465 has_mouse_termcode &= ~HMT_NETTERM; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1466 else |
31135
759b181807f7
patch 9.0.0902: some mouse scroll code is not in a good place
Bram Moolenaar <Bram@vim.org>
parents:
31133
diff
changeset
|
1467 # endif |
759b181807f7
patch 9.0.0902: some mouse scroll code is not in a good place
Bram Moolenaar <Bram@vim.org>
parents:
31133
diff
changeset
|
1468 # ifdef FEAT_MOUSE_DEC |
18135
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1469 if (n == KS_DEC_MOUSE) |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1470 has_mouse_termcode &= ~HMT_DEC; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1471 else |
31135
759b181807f7
patch 9.0.0902: some mouse scroll code is not in a good place
Bram Moolenaar <Bram@vim.org>
parents:
31133
diff
changeset
|
1472 # endif |
759b181807f7
patch 9.0.0902: some mouse scroll code is not in a good place
Bram Moolenaar <Bram@vim.org>
parents:
31133
diff
changeset
|
1473 # ifdef FEAT_MOUSE_PTERM |
18135
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1474 if (n == KS_PTERM_MOUSE) |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1475 has_mouse_termcode &= ~HMT_PTERM; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1476 else |
31135
759b181807f7
patch 9.0.0902: some mouse scroll code is not in a good place
Bram Moolenaar <Bram@vim.org>
parents:
31133
diff
changeset
|
1477 # endif |
759b181807f7
patch 9.0.0902: some mouse scroll code is not in a good place
Bram Moolenaar <Bram@vim.org>
parents:
31133
diff
changeset
|
1478 # ifdef FEAT_MOUSE_URXVT |
18135
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1479 if (n == KS_URXVT_MOUSE) |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1480 has_mouse_termcode &= ~HMT_URXVT; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1481 else |
31135
759b181807f7
patch 9.0.0902: some mouse scroll code is not in a good place
Bram Moolenaar <Bram@vim.org>
parents:
31133
diff
changeset
|
1482 # endif |
759b181807f7
patch 9.0.0902: some mouse scroll code is not in a good place
Bram Moolenaar <Bram@vim.org>
parents:
31133
diff
changeset
|
1483 # ifdef FEAT_MOUSE_GPM |
18135
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1484 if (n == KS_GPM_MOUSE) |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1485 has_mouse_termcode &= ~HMT_GPM; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1486 else |
31135
759b181807f7
patch 9.0.0902: some mouse scroll code is not in a good place
Bram Moolenaar <Bram@vim.org>
parents:
31133
diff
changeset
|
1487 # endif |
18135
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1488 if (n == KS_SGR_MOUSE) |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1489 has_mouse_termcode &= ~HMT_SGR; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1490 else if (n == KS_SGR_MOUSE_RELEASE) |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1491 has_mouse_termcode &= ~HMT_SGR_REL; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1492 else |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1493 has_mouse_termcode &= ~HMT_NORMAL; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1494 } |
31135
759b181807f7
patch 9.0.0902: some mouse scroll code is not in a good place
Bram Moolenaar <Bram@vim.org>
parents:
31133
diff
changeset
|
1495 #endif |
18135
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1496 |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1497 /* |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1498 * setmouse() - switch mouse on/off depending on current mode and 'mouse' |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1499 */ |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1500 void |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1501 setmouse(void) |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1502 { |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1503 int checkfor; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1504 |
31135
759b181807f7
patch 9.0.0902: some mouse scroll code is not in a good place
Bram Moolenaar <Bram@vim.org>
parents:
31133
diff
changeset
|
1505 #ifdef FEAT_MOUSESHAPE |
18135
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1506 update_mouseshape(-1); |
31135
759b181807f7
patch 9.0.0902: some mouse scroll code is not in a good place
Bram Moolenaar <Bram@vim.org>
parents:
31133
diff
changeset
|
1507 #endif |
18135
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1508 |
18354
9f51d0cef8da
patch 8.1.2171: mouse support not always available
Bram Moolenaar <Bram@vim.org>
parents:
18150
diff
changeset
|
1509 // Should be outside proc, but may break MOUSESHAPE |
31135
759b181807f7
patch 9.0.0902: some mouse scroll code is not in a good place
Bram Moolenaar <Bram@vim.org>
parents:
31133
diff
changeset
|
1510 #ifdef FEAT_GUI |
18135
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1511 // In the GUI the mouse is always enabled. |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1512 if (gui.in_use) |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1513 return; |
31135
759b181807f7
patch 9.0.0902: some mouse scroll code is not in a good place
Bram Moolenaar <Bram@vim.org>
parents:
31133
diff
changeset
|
1514 #endif |
18135
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1515 // be quick when mouse is off |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1516 if (*p_mouse == NUL || has_mouse_termcode == 0) |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1517 return; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1518 |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1519 // don't switch mouse on when not in raw mode (Ex mode) |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1520 if (cur_tmode != TMODE_RAW) |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1521 { |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1522 mch_setmouse(FALSE); |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1523 return; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1524 } |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1525 |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1526 if (VIsual_active) |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1527 checkfor = MOUSE_VISUAL; |
28773
d770568e6c98
patch 8.2.4911: the mode #defines are not clearly named
Bram Moolenaar <Bram@vim.org>
parents:
28755
diff
changeset
|
1528 else if (State == MODE_HITRETURN || State == MODE_ASKMORE |
d770568e6c98
patch 8.2.4911: the mode #defines are not clearly named
Bram Moolenaar <Bram@vim.org>
parents:
28755
diff
changeset
|
1529 || State == MODE_SETWSIZE) |
18135
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1530 checkfor = MOUSE_RETURN; |
28773
d770568e6c98
patch 8.2.4911: the mode #defines are not clearly named
Bram Moolenaar <Bram@vim.org>
parents:
28755
diff
changeset
|
1531 else if (State & MODE_INSERT) |
18135
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1532 checkfor = MOUSE_INSERT; |
28773
d770568e6c98
patch 8.2.4911: the mode #defines are not clearly named
Bram Moolenaar <Bram@vim.org>
parents:
28755
diff
changeset
|
1533 else if (State & MODE_CMDLINE) |
18135
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1534 checkfor = MOUSE_COMMAND; |
28773
d770568e6c98
patch 8.2.4911: the mode #defines are not clearly named
Bram Moolenaar <Bram@vim.org>
parents:
28755
diff
changeset
|
1535 else if (State == MODE_CONFIRM || State == MODE_EXTERNCMD) |
18135
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1536 checkfor = ' '; // don't use mouse for ":confirm" or ":!cmd" |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1537 else |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1538 checkfor = MOUSE_NORMAL; // assume normal mode |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1539 |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1540 if (mouse_has(checkfor)) |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1541 mch_setmouse(TRUE); |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1542 else |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1543 mch_setmouse(FALSE); |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1544 } |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1545 |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1546 /* |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1547 * Return TRUE if |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1548 * - "c" is in 'mouse', or |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1549 * - 'a' is in 'mouse' and "c" is in MOUSE_A, or |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1550 * - the current buffer is a help file and 'h' is in 'mouse' and we are in a |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1551 * normal editing mode (not at hit-return message). |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1552 */ |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1553 int |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1554 mouse_has(int c) |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1555 { |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1556 char_u *p; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1557 |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1558 for (p = p_mouse; *p; ++p) |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1559 switch (*p) |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1560 { |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1561 case 'a': if (vim_strchr((char_u *)MOUSE_A, c) != NULL) |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1562 return TRUE; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1563 break; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1564 case MOUSE_HELP: if (c != MOUSE_RETURN && curbuf->b_help) |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1565 return TRUE; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1566 break; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1567 default: if (c == *p) return TRUE; break; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1568 } |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1569 return FALSE; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1570 } |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1571 |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1572 /* |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1573 * Return TRUE when 'mousemodel' is set to "popup" or "popup_setpos". |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1574 */ |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1575 int |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1576 mouse_model_popup(void) |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1577 { |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1578 return (p_mousem[0] == 'p'); |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1579 } |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1580 |
30980
eb51299c4bfc
patch 9.0.0825: cannot drag an entry in the tabpage line
Bram Moolenaar <Bram@vim.org>
parents:
30974
diff
changeset
|
1581 static win_T *dragwin = NULL; // window being dragged |
eb51299c4bfc
patch 9.0.0825: cannot drag an entry in the tabpage line
Bram Moolenaar <Bram@vim.org>
parents:
30974
diff
changeset
|
1582 |
eb51299c4bfc
patch 9.0.0825: cannot drag an entry in the tabpage line
Bram Moolenaar <Bram@vim.org>
parents:
30974
diff
changeset
|
1583 /* |
eb51299c4bfc
patch 9.0.0825: cannot drag an entry in the tabpage line
Bram Moolenaar <Bram@vim.org>
parents:
30974
diff
changeset
|
1584 * Reset the window being dragged. To be called when switching tab page. |
eb51299c4bfc
patch 9.0.0825: cannot drag an entry in the tabpage line
Bram Moolenaar <Bram@vim.org>
parents:
30974
diff
changeset
|
1585 */ |
eb51299c4bfc
patch 9.0.0825: cannot drag an entry in the tabpage line
Bram Moolenaar <Bram@vim.org>
parents:
30974
diff
changeset
|
1586 void |
eb51299c4bfc
patch 9.0.0825: cannot drag an entry in the tabpage line
Bram Moolenaar <Bram@vim.org>
parents:
30974
diff
changeset
|
1587 reset_dragwin(void) |
eb51299c4bfc
patch 9.0.0825: cannot drag an entry in the tabpage line
Bram Moolenaar <Bram@vim.org>
parents:
30974
diff
changeset
|
1588 { |
eb51299c4bfc
patch 9.0.0825: cannot drag an entry in the tabpage line
Bram Moolenaar <Bram@vim.org>
parents:
30974
diff
changeset
|
1589 dragwin = NULL; |
eb51299c4bfc
patch 9.0.0825: cannot drag an entry in the tabpage line
Bram Moolenaar <Bram@vim.org>
parents:
30974
diff
changeset
|
1590 } |
eb51299c4bfc
patch 9.0.0825: cannot drag an entry in the tabpage line
Bram Moolenaar <Bram@vim.org>
parents:
30974
diff
changeset
|
1591 |
18135
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1592 /* |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1593 * Move the cursor to the specified row and column on the screen. |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1594 * Change current window if necessary. Returns an integer with the |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1595 * CURSOR_MOVED bit set if the cursor has moved or unset otherwise. |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1596 * |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1597 * The MOUSE_FOLD_CLOSE bit is set when clicked on the '-' in a fold column. |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1598 * The MOUSE_FOLD_OPEN bit is set when clicked on the '+' in a fold column. |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1599 * |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1600 * If flags has MOUSE_FOCUS, then the current window will not be changed, and |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1601 * if the mouse is outside the window then the text will scroll, or if the |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1602 * mouse was previously on a status line, then the status line may be dragged. |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1603 * |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1604 * If flags has MOUSE_MAY_VIS, then VIsual mode will be started before the |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1605 * cursor is moved unless the cursor was on a status line. |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1606 * This function returns one of IN_UNKNOWN, IN_BUFFER, IN_STATUS_LINE or |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1607 * IN_SEP_LINE depending on where the cursor was clicked. |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1608 * |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1609 * If flags has MOUSE_MAY_STOP_VIS, then Visual mode will be stopped, unless |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1610 * the mouse is on the status line of the same window. |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1611 * |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1612 * If flags has MOUSE_DID_MOVE, nothing is done if the mouse didn't move since |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1613 * the last call. |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1614 * |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1615 * If flags has MOUSE_SETPOS, nothing is done, only the current position is |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1616 * remembered. |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1617 */ |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1618 int |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1619 jump_to_mouse( |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1620 int flags, |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1621 int *inclusive, // used for inclusive operator, can be NULL |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1622 int which_button) // MOUSE_LEFT, MOUSE_RIGHT, MOUSE_MIDDLE |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1623 { |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1624 static int on_status_line = 0; // #lines below bottom of window |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1625 static int on_sep_line = 0; // on separator right of window |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1626 #ifdef FEAT_MENU |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1627 static int in_winbar = FALSE; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1628 #endif |
18763
49b78d6465e5
patch 8.1.2371: FEAT_TEXT_PROP is a confusing name
Bram Moolenaar <Bram@vim.org>
parents:
18691
diff
changeset
|
1629 #ifdef FEAT_PROP_POPUP |
18135
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1630 static int in_popup_win = FALSE; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1631 static win_T *click_in_popup_win = NULL; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1632 #endif |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1633 static int prev_row = -1; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1634 static int prev_col = -1; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1635 static int did_drag = FALSE; // drag was noticed |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1636 |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1637 win_T *wp, *old_curwin; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1638 pos_T old_cursor; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1639 int count; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1640 int first; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1641 int row = mouse_row; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1642 int col = mouse_col; |
29413
34e93e046526
patch 9.0.0048: cursor in wrong column with mouse click after concealed text
Bram Moolenaar <Bram@vim.org>
parents:
29387
diff
changeset
|
1643 colnr_T col_from_screen = -1; |
18135
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1644 #ifdef FEAT_FOLDING |
29413
34e93e046526
patch 9.0.0048: cursor in wrong column with mouse click after concealed text
Bram Moolenaar <Bram@vim.org>
parents:
29387
diff
changeset
|
1645 int mouse_char = ' '; |
18135
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1646 #endif |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1647 |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1648 mouse_past_bottom = FALSE; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1649 mouse_past_eol = FALSE; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1650 |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1651 if (flags & MOUSE_RELEASED) |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1652 { |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1653 // On button release we may change window focus if positioned on a |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1654 // status line and no dragging happened. |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1655 if (dragwin != NULL && !did_drag) |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1656 flags &= ~(MOUSE_FOCUS | MOUSE_DID_MOVE); |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1657 dragwin = NULL; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1658 did_drag = FALSE; |
18763
49b78d6465e5
patch 8.1.2371: FEAT_TEXT_PROP is a confusing name
Bram Moolenaar <Bram@vim.org>
parents:
18691
diff
changeset
|
1659 #ifdef FEAT_PROP_POPUP |
18135
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1660 if (click_in_popup_win != NULL && popup_dragwin == NULL) |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1661 popup_close_for_mouse_click(click_in_popup_win); |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1662 |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1663 popup_dragwin = NULL; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1664 click_in_popup_win = NULL; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1665 #endif |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1666 } |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1667 |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1668 if ((flags & MOUSE_DID_MOVE) |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1669 && prev_row == mouse_row |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1670 && prev_col == mouse_col) |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1671 { |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1672 retnomove: |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1673 // before moving the cursor for a left click which is NOT in a status |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1674 // line, stop Visual mode |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1675 if (on_status_line) |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1676 return IN_STATUS_LINE; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1677 if (on_sep_line) |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1678 return IN_SEP_LINE; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1679 #ifdef FEAT_MENU |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1680 if (in_winbar) |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1681 { |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1682 // A quick second click may arrive as a double-click, but we use it |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1683 // as a second click in the WinBar. |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1684 if ((mod_mask & MOD_MASK_MULTI_CLICK) && !(flags & MOUSE_RELEASED)) |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1685 { |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1686 wp = mouse_find_win(&row, &col, FAIL_POPUP); |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1687 if (wp == NULL) |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1688 return IN_UNKNOWN; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1689 winbar_click(wp, col); |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1690 } |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1691 return IN_OTHER_WIN | MOUSE_WINBAR; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1692 } |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1693 #endif |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1694 if (flags & MOUSE_MAY_STOP_VIS) |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1695 { |
24788
b36ceac30454
patch 8.2.2932: select mode test fails
Bram Moolenaar <Bram@vim.org>
parents:
24784
diff
changeset
|
1696 end_visual_mode_keep_button(); |
29732
89e1d67814a9
patch 9.0.0206: redraw flags are not named specifically
Bram Moolenaar <Bram@vim.org>
parents:
29674
diff
changeset
|
1697 redraw_curbuf_later(UPD_INVERTED); // delete the inversion |
18135
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1698 } |
30645
101f08b49ed3
patch 9.0.0657: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
29841
diff
changeset
|
1699 #if defined(FEAT_CLIPBOARD) |
18135
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1700 // Continue a modeless selection in another window. |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1701 if (cmdwin_type != 0 && row < curwin->w_winrow) |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1702 return IN_OTHER_WIN; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1703 #endif |
18763
49b78d6465e5
patch 8.1.2371: FEAT_TEXT_PROP is a confusing name
Bram Moolenaar <Bram@vim.org>
parents:
18691
diff
changeset
|
1704 #ifdef FEAT_PROP_POPUP |
18135
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1705 // Continue a modeless selection in a popup window or dragging it. |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1706 if (in_popup_win) |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1707 { |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1708 click_in_popup_win = NULL; // don't close it on release |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1709 if (popup_dragwin != NULL) |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1710 { |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1711 // dragging a popup window |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1712 popup_drag(popup_dragwin); |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1713 return IN_UNKNOWN; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1714 } |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1715 return IN_OTHER_WIN; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1716 } |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1717 #endif |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1718 return IN_BUFFER; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1719 } |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1720 |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1721 prev_row = mouse_row; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1722 prev_col = mouse_col; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1723 |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1724 if (flags & MOUSE_SETPOS) |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1725 goto retnomove; // ugly goto... |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1726 |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1727 old_curwin = curwin; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1728 old_cursor = curwin->w_cursor; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1729 |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1730 if (!(flags & MOUSE_FOCUS)) |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1731 { |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1732 if (row < 0 || col < 0) // check if it makes sense |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1733 return IN_UNKNOWN; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1734 |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1735 // find the window where the row is in and adjust "row" and "col" to be |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1736 // relative to top-left of the window |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1737 wp = mouse_find_win(&row, &col, FIND_POPUP); |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1738 if (wp == NULL) |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1739 return IN_UNKNOWN; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1740 dragwin = NULL; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1741 |
18763
49b78d6465e5
patch 8.1.2371: FEAT_TEXT_PROP is a confusing name
Bram Moolenaar <Bram@vim.org>
parents:
18691
diff
changeset
|
1742 #ifdef FEAT_PROP_POPUP |
18135
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1743 // Click in a popup window may start dragging or modeless selection, |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1744 // but not much else. |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1745 if (WIN_IS_POPUP(wp)) |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1746 { |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1747 on_sep_line = 0; |
26300
0374f55a16be
patch 8.2.3681: cannot drag popup window after click on a status line
Bram Moolenaar <Bram@vim.org>
parents:
24788
diff
changeset
|
1748 on_status_line = 0; |
18135
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1749 in_popup_win = TRUE; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1750 if (which_button == MOUSE_LEFT && popup_close_if_on_X(wp, row, col)) |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1751 { |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1752 return IN_UNKNOWN; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1753 } |
26332
8b7f01b39d79
patch 8.2.3697: cannot drag a popup without a border
Bram Moolenaar <Bram@vim.org>
parents:
26300
diff
changeset
|
1754 else if (((wp->w_popup_flags & (POPF_DRAG | POPF_RESIZE)) |
18135
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1755 && popup_on_border(wp, row, col)) |
26332
8b7f01b39d79
patch 8.2.3697: cannot drag a popup without a border
Bram Moolenaar <Bram@vim.org>
parents:
26300
diff
changeset
|
1756 || (wp->w_popup_flags & POPF_DRAGALL)) |
18135
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1757 { |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1758 popup_dragwin = wp; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1759 popup_start_drag(wp, row, col); |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1760 return IN_UNKNOWN; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1761 } |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1762 // Only close on release, otherwise it's not possible to drag or do |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1763 // modeless selection. |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1764 else if (wp->w_popup_close == POPCLOSE_CLICK |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1765 && which_button == MOUSE_LEFT) |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1766 { |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1767 click_in_popup_win = wp; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1768 } |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1769 else if (which_button == MOUSE_LEFT) |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1770 // If the click is in the scrollbar, may scroll up/down. |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1771 popup_handle_scrollbar_click(wp, row, col); |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1772 # ifdef FEAT_CLIPBOARD |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1773 return IN_OTHER_WIN; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1774 # else |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1775 return IN_UNKNOWN; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1776 # endif |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1777 } |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1778 in_popup_win = FALSE; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1779 popup_dragwin = NULL; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1780 #endif |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1781 #ifdef FEAT_MENU |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1782 if (row == -1) |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1783 { |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1784 // A click in the window toolbar does not enter another window or |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1785 // change Visual highlighting. |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1786 winbar_click(wp, col); |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1787 in_winbar = TRUE; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1788 return IN_OTHER_WIN | MOUSE_WINBAR; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1789 } |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1790 in_winbar = FALSE; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1791 #endif |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1792 |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1793 // winpos and height may change in win_enter()! |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1794 if (row >= wp->w_height) // In (or below) status line |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1795 { |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1796 on_status_line = row - wp->w_height + 1; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1797 dragwin = wp; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1798 } |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1799 else |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1800 on_status_line = 0; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1801 if (col >= wp->w_width) // In separator line |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1802 { |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1803 on_sep_line = col - wp->w_width + 1; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1804 dragwin = wp; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1805 } |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1806 else |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1807 on_sep_line = 0; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1808 |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1809 // The rightmost character of the status line might be a vertical |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1810 // separator character if there is no connecting window to the right. |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1811 if (on_status_line && on_sep_line) |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1812 { |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1813 if (stl_connected(wp)) |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1814 on_sep_line = 0; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1815 else |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1816 on_status_line = 0; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1817 } |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1818 |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1819 // Before jumping to another buffer, or moving the cursor for a left |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1820 // click, stop Visual mode. |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1821 if (VIsual_active |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1822 && (wp->w_buffer != curwin->w_buffer |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1823 || (!on_status_line && !on_sep_line |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1824 #ifdef FEAT_FOLDING |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1825 && ( |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1826 # ifdef FEAT_RIGHTLEFT |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1827 wp->w_p_rl ? col < wp->w_width - wp->w_p_fdc : |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1828 # endif |
30645
101f08b49ed3
patch 9.0.0657: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
29841
diff
changeset
|
1829 col >= wp->w_p_fdc + (cmdwin_type == 0 && wp == curwin ? 0 : 1) |
18135
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1830 ) |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1831 #endif |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1832 && (flags & MOUSE_MAY_STOP_VIS)))) |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1833 { |
24788
b36ceac30454
patch 8.2.2932: select mode test fails
Bram Moolenaar <Bram@vim.org>
parents:
24784
diff
changeset
|
1834 end_visual_mode_keep_button(); |
29732
89e1d67814a9
patch 9.0.0206: redraw flags are not named specifically
Bram Moolenaar <Bram@vim.org>
parents:
29674
diff
changeset
|
1835 redraw_curbuf_later(UPD_INVERTED); // delete the inversion |
18135
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1836 } |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1837 if (cmdwin_type != 0 && wp != curwin) |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1838 { |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1839 // A click outside the command-line window: Use modeless |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1840 // selection if possible. Allow dragging the status lines. |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1841 on_sep_line = 0; |
31135
759b181807f7
patch 9.0.0902: some mouse scroll code is not in a good place
Bram Moolenaar <Bram@vim.org>
parents:
31133
diff
changeset
|
1842 #ifdef FEAT_CLIPBOARD |
18135
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1843 if (on_status_line) |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1844 return IN_STATUS_LINE; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1845 return IN_OTHER_WIN; |
31135
759b181807f7
patch 9.0.0902: some mouse scroll code is not in a good place
Bram Moolenaar <Bram@vim.org>
parents:
31133
diff
changeset
|
1846 #else |
18135
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1847 row = 0; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1848 col += wp->w_wincol; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1849 wp = curwin; |
31135
759b181807f7
patch 9.0.0902: some mouse scroll code is not in a good place
Bram Moolenaar <Bram@vim.org>
parents:
31133
diff
changeset
|
1850 #endif |
18135
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1851 } |
19265
ce8c47ed54e5
patch 8.2.0191: cannot put a terminal in a popup window
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1852 #if defined(FEAT_PROP_POPUP) && defined(FEAT_TERMINAL) |
ce8c47ed54e5
patch 8.2.0191: cannot put a terminal in a popup window
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1853 if (popup_is_popup(curwin) && curbuf->b_term != NULL) |
ce8c47ed54e5
patch 8.2.0191: cannot put a terminal in a popup window
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1854 // terminal in popup window: don't jump to another window |
ce8c47ed54e5
patch 8.2.0191: cannot put a terminal in a popup window
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1855 return IN_OTHER_WIN; |
ce8c47ed54e5
patch 8.2.0191: cannot put a terminal in a popup window
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1856 #endif |
18135
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1857 // Only change window focus when not clicking on or dragging the |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1858 // status line. Do change focus when releasing the mouse button |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1859 // (MOUSE_FOCUS was set above if we dragged first). |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1860 if (dragwin == NULL || (flags & MOUSE_RELEASED)) |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1861 win_enter(wp, TRUE); // can make wp invalid! |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1862 |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1863 if (curwin != old_curwin) |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1864 { |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1865 #ifdef CHECK_DOUBLE_CLICK |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1866 // set topline, to be able to check for double click ourselves |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1867 set_mouse_topline(curwin); |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1868 #endif |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1869 #ifdef FEAT_TERMINAL |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1870 // when entering a terminal window may change state |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1871 term_win_entered(); |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1872 #endif |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1873 } |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1874 if (on_status_line) // In (or below) status line |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1875 { |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1876 // Don't use start_arrow() if we're in the same window |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1877 if (curwin == old_curwin) |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1878 return IN_STATUS_LINE; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1879 else |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1880 return IN_STATUS_LINE | CURSOR_MOVED; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1881 } |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1882 if (on_sep_line) // In (or below) status line |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1883 { |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1884 // Don't use start_arrow() if we're in the same window |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1885 if (curwin == old_curwin) |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1886 return IN_SEP_LINE; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1887 else |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1888 return IN_SEP_LINE | CURSOR_MOVED; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1889 } |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1890 |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1891 curwin->w_cursor.lnum = curwin->w_topline; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1892 #ifdef FEAT_GUI |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1893 // remember topline, needed for double click |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1894 gui_prev_topline = curwin->w_topline; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1895 # ifdef FEAT_DIFF |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1896 gui_prev_topfill = curwin->w_topfill; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1897 # endif |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1898 #endif |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1899 } |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1900 else if (on_status_line && which_button == MOUSE_LEFT) |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1901 { |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1902 if (dragwin != NULL) |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1903 { |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1904 // Drag the status line |
28923
2d726d5a6405
patch 8.2.4984: dragging statusline fails for window with winbar
Bram Moolenaar <Bram@vim.org>
parents:
28809
diff
changeset
|
1905 count = row - W_WINROW(dragwin) - dragwin->w_height + 1 |
18135
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1906 - on_status_line; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1907 win_drag_status_line(dragwin, count); |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1908 did_drag |= count; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1909 } |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1910 return IN_STATUS_LINE; // Cursor didn't move |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1911 } |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1912 else if (on_sep_line && which_button == MOUSE_LEFT) |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1913 { |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1914 if (dragwin != NULL) |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1915 { |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1916 // Drag the separator column |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1917 count = col - dragwin->w_wincol - dragwin->w_width + 1 |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1918 - on_sep_line; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1919 win_drag_vsep_line(dragwin, count); |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1920 did_drag |= count; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1921 } |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1922 return IN_SEP_LINE; // Cursor didn't move |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1923 } |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1924 #ifdef FEAT_MENU |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1925 else if (in_winbar) |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1926 { |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1927 // After a click on the window toolbar don't start Visual mode. |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1928 return IN_OTHER_WIN | MOUSE_WINBAR; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1929 } |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1930 #endif |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1931 else // keep_window_focus must be TRUE |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1932 { |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1933 // before moving the cursor for a left click, stop Visual mode |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1934 if (flags & MOUSE_MAY_STOP_VIS) |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1935 { |
24788
b36ceac30454
patch 8.2.2932: select mode test fails
Bram Moolenaar <Bram@vim.org>
parents:
24784
diff
changeset
|
1936 end_visual_mode_keep_button(); |
29732
89e1d67814a9
patch 9.0.0206: redraw flags are not named specifically
Bram Moolenaar <Bram@vim.org>
parents:
29674
diff
changeset
|
1937 redraw_curbuf_later(UPD_INVERTED); // delete the inversion |
18135
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1938 } |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1939 |
30645
101f08b49ed3
patch 9.0.0657: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
29841
diff
changeset
|
1940 #if defined(FEAT_CLIPBOARD) |
18135
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1941 // Continue a modeless selection in another window. |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1942 if (cmdwin_type != 0 && row < curwin->w_winrow) |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1943 return IN_OTHER_WIN; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1944 #endif |
18763
49b78d6465e5
patch 8.1.2371: FEAT_TEXT_PROP is a confusing name
Bram Moolenaar <Bram@vim.org>
parents:
18691
diff
changeset
|
1945 #ifdef FEAT_PROP_POPUP |
18135
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1946 if (in_popup_win) |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1947 { |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1948 if (popup_dragwin != NULL) |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1949 { |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1950 // dragging a popup window |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1951 popup_drag(popup_dragwin); |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1952 return IN_UNKNOWN; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1953 } |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1954 // continue a modeless selection in a popup window |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1955 click_in_popup_win = NULL; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1956 return IN_OTHER_WIN; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1957 } |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1958 #endif |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1959 |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1960 row -= W_WINROW(curwin); |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1961 col -= curwin->w_wincol; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1962 |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1963 // When clicking beyond the end of the window, scroll the screen. |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1964 // Scroll by however many rows outside the window we are. |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1965 if (row < 0) |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1966 { |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1967 count = 0; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1968 for (first = TRUE; curwin->w_topline > 1; ) |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1969 { |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1970 #ifdef FEAT_DIFF |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1971 if (curwin->w_topfill < diff_check(curwin, curwin->w_topline)) |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1972 ++count; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1973 else |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1974 #endif |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1975 count += plines(curwin->w_topline - 1); |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1976 if (!first && count > -row) |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1977 break; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1978 first = FALSE; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1979 #ifdef FEAT_FOLDING |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1980 (void)hasFolding(curwin->w_topline, &curwin->w_topline, NULL); |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1981 #endif |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1982 #ifdef FEAT_DIFF |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1983 if (curwin->w_topfill < diff_check(curwin, curwin->w_topline)) |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1984 ++curwin->w_topfill; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1985 else |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1986 #endif |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1987 { |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1988 --curwin->w_topline; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1989 #ifdef FEAT_DIFF |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1990 curwin->w_topfill = 0; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1991 #endif |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1992 } |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1993 } |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1994 #ifdef FEAT_DIFF |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1995 check_topfill(curwin, FALSE); |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1996 #endif |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1997 curwin->w_valid &= |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1998 ~(VALID_WROW|VALID_CROW|VALID_BOTLINE|VALID_BOTLINE_AP); |
29732
89e1d67814a9
patch 9.0.0206: redraw flags are not named specifically
Bram Moolenaar <Bram@vim.org>
parents:
29674
diff
changeset
|
1999 redraw_later(UPD_VALID); |
18135
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2000 row = 0; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2001 } |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2002 else if (row >= curwin->w_height) |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2003 { |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2004 count = 0; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2005 for (first = TRUE; curwin->w_topline < curbuf->b_ml.ml_line_count; ) |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2006 { |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2007 #ifdef FEAT_DIFF |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2008 if (curwin->w_topfill > 0) |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2009 ++count; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2010 else |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2011 #endif |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2012 count += plines(curwin->w_topline); |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2013 if (!first && count > row - curwin->w_height + 1) |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2014 break; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2015 first = FALSE; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2016 #ifdef FEAT_FOLDING |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2017 if (hasFolding(curwin->w_topline, NULL, &curwin->w_topline) |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2018 && curwin->w_topline == curbuf->b_ml.ml_line_count) |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2019 break; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2020 #endif |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2021 #ifdef FEAT_DIFF |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2022 if (curwin->w_topfill > 0) |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2023 --curwin->w_topfill; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2024 else |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2025 #endif |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2026 { |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2027 ++curwin->w_topline; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2028 #ifdef FEAT_DIFF |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2029 curwin->w_topfill = |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2030 diff_check_fill(curwin, curwin->w_topline); |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2031 #endif |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2032 } |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2033 } |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2034 #ifdef FEAT_DIFF |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2035 check_topfill(curwin, FALSE); |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2036 #endif |
29732
89e1d67814a9
patch 9.0.0206: redraw flags are not named specifically
Bram Moolenaar <Bram@vim.org>
parents:
29674
diff
changeset
|
2037 redraw_later(UPD_VALID); |
18135
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2038 curwin->w_valid &= |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2039 ~(VALID_WROW|VALID_CROW|VALID_BOTLINE|VALID_BOTLINE_AP); |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2040 row = curwin->w_height - 1; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2041 } |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2042 else if (row == 0) |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2043 { |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2044 // When dragging the mouse, while the text has been scrolled up as |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2045 // far as it goes, moving the mouse in the top line should scroll |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2046 // the text down (done later when recomputing w_topline). |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2047 if (mouse_dragging > 0 |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2048 && curwin->w_cursor.lnum |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2049 == curwin->w_buffer->b_ml.ml_line_count |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2050 && curwin->w_cursor.lnum == curwin->w_topline) |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2051 curwin->w_valid &= ~(VALID_TOPLINE); |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2052 } |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2053 } |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2054 |
29413
34e93e046526
patch 9.0.0048: cursor in wrong column with mouse click after concealed text
Bram Moolenaar <Bram@vim.org>
parents:
29387
diff
changeset
|
2055 if (prev_row >= 0 && prev_row < Rows && prev_col >= 0 && prev_col <= Columns |
34e93e046526
patch 9.0.0048: cursor in wrong column with mouse click after concealed text
Bram Moolenaar <Bram@vim.org>
parents:
29387
diff
changeset
|
2056 && ScreenLines != NULL) |
34e93e046526
patch 9.0.0048: cursor in wrong column with mouse click after concealed text
Bram Moolenaar <Bram@vim.org>
parents:
29387
diff
changeset
|
2057 { |
34e93e046526
patch 9.0.0048: cursor in wrong column with mouse click after concealed text
Bram Moolenaar <Bram@vim.org>
parents:
29387
diff
changeset
|
2058 int off = LineOffset[prev_row] + prev_col; |
34e93e046526
patch 9.0.0048: cursor in wrong column with mouse click after concealed text
Bram Moolenaar <Bram@vim.org>
parents:
29387
diff
changeset
|
2059 |
34e93e046526
patch 9.0.0048: cursor in wrong column with mouse click after concealed text
Bram Moolenaar <Bram@vim.org>
parents:
29387
diff
changeset
|
2060 // Only use ScreenCols[] after the window was redrawn. Mainly matters |
34e93e046526
patch 9.0.0048: cursor in wrong column with mouse click after concealed text
Bram Moolenaar <Bram@vim.org>
parents:
29387
diff
changeset
|
2061 // for tests, a user would not click before redrawing. |
29674
b11130c6e694
patch 9.0.0177: cursor position wrong with 'virtualedit' and mouse click
Bram Moolenaar <Bram@vim.org>
parents:
29591
diff
changeset
|
2062 // Do not use when 'virtualedit' is active. |
29732
89e1d67814a9
patch 9.0.0206: redraw flags are not named specifically
Bram Moolenaar <Bram@vim.org>
parents:
29674
diff
changeset
|
2063 if (curwin->w_redr_type <= UPD_VALID_NO_UPDATE && !virtual_active()) |
29413
34e93e046526
patch 9.0.0048: cursor in wrong column with mouse click after concealed text
Bram Moolenaar <Bram@vim.org>
parents:
29387
diff
changeset
|
2064 col_from_screen = ScreenCols[off]; |
34e93e046526
patch 9.0.0048: cursor in wrong column with mouse click after concealed text
Bram Moolenaar <Bram@vim.org>
parents:
29387
diff
changeset
|
2065 #ifdef FEAT_FOLDING |
34e93e046526
patch 9.0.0048: cursor in wrong column with mouse click after concealed text
Bram Moolenaar <Bram@vim.org>
parents:
29387
diff
changeset
|
2066 // Remember the character under the mouse, it might be a '-' or '+' in |
34e93e046526
patch 9.0.0048: cursor in wrong column with mouse click after concealed text
Bram Moolenaar <Bram@vim.org>
parents:
29387
diff
changeset
|
2067 // the fold column. |
34e93e046526
patch 9.0.0048: cursor in wrong column with mouse click after concealed text
Bram Moolenaar <Bram@vim.org>
parents:
29387
diff
changeset
|
2068 mouse_char = ScreenLines[off]; |
34e93e046526
patch 9.0.0048: cursor in wrong column with mouse click after concealed text
Bram Moolenaar <Bram@vim.org>
parents:
29387
diff
changeset
|
2069 #endif |
34e93e046526
patch 9.0.0048: cursor in wrong column with mouse click after concealed text
Bram Moolenaar <Bram@vim.org>
parents:
29387
diff
changeset
|
2070 } |
34e93e046526
patch 9.0.0048: cursor in wrong column with mouse click after concealed text
Bram Moolenaar <Bram@vim.org>
parents:
29387
diff
changeset
|
2071 |
18135
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2072 #ifdef FEAT_FOLDING |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2073 // Check for position outside of the fold column. |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2074 if ( |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2075 # ifdef FEAT_RIGHTLEFT |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2076 curwin->w_p_rl ? col < curwin->w_width - curwin->w_p_fdc : |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2077 # endif |
30645
101f08b49ed3
patch 9.0.0657: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
29841
diff
changeset
|
2078 col >= curwin->w_p_fdc + (cmdwin_type == 0 ? 0 : 1) |
18135
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2079 ) |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2080 mouse_char = ' '; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2081 #endif |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2082 |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2083 // compute the position in the buffer line from the posn on the screen |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2084 if (mouse_comp_pos(curwin, &row, &col, &curwin->w_cursor.lnum, NULL)) |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2085 mouse_past_bottom = TRUE; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2086 |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2087 // Start Visual mode before coladvance(), for when 'sel' != "old" |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2088 if ((flags & MOUSE_MAY_VIS) && !VIsual_active) |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2089 { |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2090 check_visual_highlight(); |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2091 VIsual = old_cursor; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2092 VIsual_active = TRUE; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2093 VIsual_reselect = TRUE; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2094 // if 'selectmode' contains "mouse", start Select mode |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2095 may_start_select('o'); |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2096 setmouse(); |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2097 if (p_smd && msg_silent == 0) |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2098 redraw_cmdline = TRUE; // show visual mode later |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2099 } |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2100 |
29413
34e93e046526
patch 9.0.0048: cursor in wrong column with mouse click after concealed text
Bram Moolenaar <Bram@vim.org>
parents:
29387
diff
changeset
|
2101 if (col_from_screen >= 0) |
18135
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2102 { |
29413
34e93e046526
patch 9.0.0048: cursor in wrong column with mouse click after concealed text
Bram Moolenaar <Bram@vim.org>
parents:
29387
diff
changeset
|
2103 // Use the column from ScreenCols[], it is accurate also after |
34e93e046526
patch 9.0.0048: cursor in wrong column with mouse click after concealed text
Bram Moolenaar <Bram@vim.org>
parents:
29387
diff
changeset
|
2104 // concealed characters. |
34e93e046526
patch 9.0.0048: cursor in wrong column with mouse click after concealed text
Bram Moolenaar <Bram@vim.org>
parents:
29387
diff
changeset
|
2105 curwin->w_cursor.col = col_from_screen; |
34e93e046526
patch 9.0.0048: cursor in wrong column with mouse click after concealed text
Bram Moolenaar <Bram@vim.org>
parents:
29387
diff
changeset
|
2106 if (col_from_screen == MAXCOL) |
34e93e046526
patch 9.0.0048: cursor in wrong column with mouse click after concealed text
Bram Moolenaar <Bram@vim.org>
parents:
29387
diff
changeset
|
2107 { |
34e93e046526
patch 9.0.0048: cursor in wrong column with mouse click after concealed text
Bram Moolenaar <Bram@vim.org>
parents:
29387
diff
changeset
|
2108 curwin->w_curswant = col_from_screen; |
34e93e046526
patch 9.0.0048: cursor in wrong column with mouse click after concealed text
Bram Moolenaar <Bram@vim.org>
parents:
29387
diff
changeset
|
2109 curwin->w_set_curswant = FALSE; // May still have been TRUE |
34e93e046526
patch 9.0.0048: cursor in wrong column with mouse click after concealed text
Bram Moolenaar <Bram@vim.org>
parents:
29387
diff
changeset
|
2110 mouse_past_eol = TRUE; |
34e93e046526
patch 9.0.0048: cursor in wrong column with mouse click after concealed text
Bram Moolenaar <Bram@vim.org>
parents:
29387
diff
changeset
|
2111 if (inclusive != NULL) |
34e93e046526
patch 9.0.0048: cursor in wrong column with mouse click after concealed text
Bram Moolenaar <Bram@vim.org>
parents:
29387
diff
changeset
|
2112 *inclusive = TRUE; |
34e93e046526
patch 9.0.0048: cursor in wrong column with mouse click after concealed text
Bram Moolenaar <Bram@vim.org>
parents:
29387
diff
changeset
|
2113 } |
34e93e046526
patch 9.0.0048: cursor in wrong column with mouse click after concealed text
Bram Moolenaar <Bram@vim.org>
parents:
29387
diff
changeset
|
2114 else |
34e93e046526
patch 9.0.0048: cursor in wrong column with mouse click after concealed text
Bram Moolenaar <Bram@vim.org>
parents:
29387
diff
changeset
|
2115 { |
34e93e046526
patch 9.0.0048: cursor in wrong column with mouse click after concealed text
Bram Moolenaar <Bram@vim.org>
parents:
29387
diff
changeset
|
2116 curwin->w_set_curswant = TRUE; |
34e93e046526
patch 9.0.0048: cursor in wrong column with mouse click after concealed text
Bram Moolenaar <Bram@vim.org>
parents:
29387
diff
changeset
|
2117 if (inclusive != NULL) |
34e93e046526
patch 9.0.0048: cursor in wrong column with mouse click after concealed text
Bram Moolenaar <Bram@vim.org>
parents:
29387
diff
changeset
|
2118 *inclusive = FALSE; |
34e93e046526
patch 9.0.0048: cursor in wrong column with mouse click after concealed text
Bram Moolenaar <Bram@vim.org>
parents:
29387
diff
changeset
|
2119 } |
34e93e046526
patch 9.0.0048: cursor in wrong column with mouse click after concealed text
Bram Moolenaar <Bram@vim.org>
parents:
29387
diff
changeset
|
2120 check_cursor_col(); |
18135
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2121 } |
29413
34e93e046526
patch 9.0.0048: cursor in wrong column with mouse click after concealed text
Bram Moolenaar <Bram@vim.org>
parents:
29387
diff
changeset
|
2122 else |
34e93e046526
patch 9.0.0048: cursor in wrong column with mouse click after concealed text
Bram Moolenaar <Bram@vim.org>
parents:
29387
diff
changeset
|
2123 { |
34e93e046526
patch 9.0.0048: cursor in wrong column with mouse click after concealed text
Bram Moolenaar <Bram@vim.org>
parents:
29387
diff
changeset
|
2124 curwin->w_curswant = col; |
34e93e046526
patch 9.0.0048: cursor in wrong column with mouse click after concealed text
Bram Moolenaar <Bram@vim.org>
parents:
29387
diff
changeset
|
2125 curwin->w_set_curswant = FALSE; // May still have been TRUE |
34e93e046526
patch 9.0.0048: cursor in wrong column with mouse click after concealed text
Bram Moolenaar <Bram@vim.org>
parents:
29387
diff
changeset
|
2126 if (coladvance(col) == FAIL) // Mouse click beyond end of line |
34e93e046526
patch 9.0.0048: cursor in wrong column with mouse click after concealed text
Bram Moolenaar <Bram@vim.org>
parents:
29387
diff
changeset
|
2127 { |
34e93e046526
patch 9.0.0048: cursor in wrong column with mouse click after concealed text
Bram Moolenaar <Bram@vim.org>
parents:
29387
diff
changeset
|
2128 if (inclusive != NULL) |
34e93e046526
patch 9.0.0048: cursor in wrong column with mouse click after concealed text
Bram Moolenaar <Bram@vim.org>
parents:
29387
diff
changeset
|
2129 *inclusive = TRUE; |
34e93e046526
patch 9.0.0048: cursor in wrong column with mouse click after concealed text
Bram Moolenaar <Bram@vim.org>
parents:
29387
diff
changeset
|
2130 mouse_past_eol = TRUE; |
34e93e046526
patch 9.0.0048: cursor in wrong column with mouse click after concealed text
Bram Moolenaar <Bram@vim.org>
parents:
29387
diff
changeset
|
2131 } |
34e93e046526
patch 9.0.0048: cursor in wrong column with mouse click after concealed text
Bram Moolenaar <Bram@vim.org>
parents:
29387
diff
changeset
|
2132 else if (inclusive != NULL) |
34e93e046526
patch 9.0.0048: cursor in wrong column with mouse click after concealed text
Bram Moolenaar <Bram@vim.org>
parents:
29387
diff
changeset
|
2133 *inclusive = FALSE; |
34e93e046526
patch 9.0.0048: cursor in wrong column with mouse click after concealed text
Bram Moolenaar <Bram@vim.org>
parents:
29387
diff
changeset
|
2134 } |
18135
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2135 |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2136 count = IN_BUFFER; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2137 if (curwin != old_curwin || curwin->w_cursor.lnum != old_cursor.lnum |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2138 || curwin->w_cursor.col != old_cursor.col) |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2139 count |= CURSOR_MOVED; // Cursor has moved |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2140 |
31135
759b181807f7
patch 9.0.0902: some mouse scroll code is not in a good place
Bram Moolenaar <Bram@vim.org>
parents:
31133
diff
changeset
|
2141 #ifdef FEAT_FOLDING |
29387
9dce192d1ac2
patch 9.0.0036: 'fillchars' cannot have window-local values
Bram Moolenaar <Bram@vim.org>
parents:
29175
diff
changeset
|
2142 if (mouse_char == curwin->w_fill_chars.foldclosed) |
18135
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2143 count |= MOUSE_FOLD_OPEN; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2144 else if (mouse_char != ' ') |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2145 count |= MOUSE_FOLD_CLOSE; |
31135
759b181807f7
patch 9.0.0902: some mouse scroll code is not in a good place
Bram Moolenaar <Bram@vim.org>
parents:
31133
diff
changeset
|
2146 #endif |
18135
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2147 |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2148 return count; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2149 } |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2150 |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2151 /* |
31103
33ca088dbd3e
patch 9.0.0886: horizontal mouse scroll only works in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
30980
diff
changeset
|
2152 * Make a horizontal scroll to "leftcol". |
33ca088dbd3e
patch 9.0.0886: horizontal mouse scroll only works in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
30980
diff
changeset
|
2153 * Return TRUE if the cursor moved, FALSE otherwise. |
33ca088dbd3e
patch 9.0.0886: horizontal mouse scroll only works in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
30980
diff
changeset
|
2154 */ |
33ca088dbd3e
patch 9.0.0886: horizontal mouse scroll only works in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
30980
diff
changeset
|
2155 int |
33ca088dbd3e
patch 9.0.0886: horizontal mouse scroll only works in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
30980
diff
changeset
|
2156 do_mousescroll_horiz(long_u leftcol) |
33ca088dbd3e
patch 9.0.0886: horizontal mouse scroll only works in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
30980
diff
changeset
|
2157 { |
33ca088dbd3e
patch 9.0.0886: horizontal mouse scroll only works in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
30980
diff
changeset
|
2158 if (curwin->w_p_wrap) |
33ca088dbd3e
patch 9.0.0886: horizontal mouse scroll only works in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
30980
diff
changeset
|
2159 return FALSE; // no wrapping, no scrolling |
33ca088dbd3e
patch 9.0.0886: horizontal mouse scroll only works in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
30980
diff
changeset
|
2160 |
33ca088dbd3e
patch 9.0.0886: horizontal mouse scroll only works in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
30980
diff
changeset
|
2161 if (curwin->w_leftcol == (colnr_T)leftcol) |
33ca088dbd3e
patch 9.0.0886: horizontal mouse scroll only works in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
30980
diff
changeset
|
2162 return FALSE; // already there |
33ca088dbd3e
patch 9.0.0886: horizontal mouse scroll only works in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
30980
diff
changeset
|
2163 |
33ca088dbd3e
patch 9.0.0886: horizontal mouse scroll only works in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
30980
diff
changeset
|
2164 // When the line of the cursor is too short, move the cursor to the |
33ca088dbd3e
patch 9.0.0886: horizontal mouse scroll only works in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
30980
diff
changeset
|
2165 // longest visible line. |
33ca088dbd3e
patch 9.0.0886: horizontal mouse scroll only works in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
30980
diff
changeset
|
2166 if ( |
33ca088dbd3e
patch 9.0.0886: horizontal mouse scroll only works in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
30980
diff
changeset
|
2167 #ifdef FEAT_GUI |
33ca088dbd3e
patch 9.0.0886: horizontal mouse scroll only works in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
30980
diff
changeset
|
2168 (!gui.in_use || vim_strchr(p_go, GO_HORSCROLL) == NULL) && |
33ca088dbd3e
patch 9.0.0886: horizontal mouse scroll only works in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
30980
diff
changeset
|
2169 #endif |
33ca088dbd3e
patch 9.0.0886: horizontal mouse scroll only works in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
30980
diff
changeset
|
2170 !virtual_active() |
33ca088dbd3e
patch 9.0.0886: horizontal mouse scroll only works in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
30980
diff
changeset
|
2171 && (long)leftcol > scroll_line_len(curwin->w_cursor.lnum)) |
33ca088dbd3e
patch 9.0.0886: horizontal mouse scroll only works in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
30980
diff
changeset
|
2172 { |
33ca088dbd3e
patch 9.0.0886: horizontal mouse scroll only works in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
30980
diff
changeset
|
2173 curwin->w_cursor.lnum = ui_find_longest_lnum(); |
33ca088dbd3e
patch 9.0.0886: horizontal mouse scroll only works in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
30980
diff
changeset
|
2174 curwin->w_cursor.col = 0; |
33ca088dbd3e
patch 9.0.0886: horizontal mouse scroll only works in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
30980
diff
changeset
|
2175 } |
33ca088dbd3e
patch 9.0.0886: horizontal mouse scroll only works in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
30980
diff
changeset
|
2176 |
31133
cc0c4141fb73
patch 9.0.0901: setting w_leftcol and handling side effects is confusing
Bram Moolenaar <Bram@vim.org>
parents:
31103
diff
changeset
|
2177 return set_leftcol((colnr_T)leftcol); |
31103
33ca088dbd3e
patch 9.0.0886: horizontal mouse scroll only works in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
30980
diff
changeset
|
2178 } |
33ca088dbd3e
patch 9.0.0886: horizontal mouse scroll only works in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
30980
diff
changeset
|
2179 |
33ca088dbd3e
patch 9.0.0886: horizontal mouse scroll only works in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
30980
diff
changeset
|
2180 /* |
31144
388ef91ae4f5
patch 9.0.0906: mouse scroll code is not optimal
Bram Moolenaar <Bram@vim.org>
parents:
31135
diff
changeset
|
2181 * Normal and Visual modes implementation for scrolling in direction |
388ef91ae4f5
patch 9.0.0906: mouse scroll code is not optimal
Bram Moolenaar <Bram@vim.org>
parents:
31135
diff
changeset
|
2182 * "cap->arg", which is one of the MSCR_ values. |
18135
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2183 */ |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2184 void |
31135
759b181807f7
patch 9.0.0902: some mouse scroll code is not in a good place
Bram Moolenaar <Bram@vim.org>
parents:
31133
diff
changeset
|
2185 nv_mousescroll(cmdarg_T *cap) |
18135
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2186 { |
31135
759b181807f7
patch 9.0.0902: some mouse scroll code is not in a good place
Bram Moolenaar <Bram@vim.org>
parents:
31133
diff
changeset
|
2187 win_T *old_curwin = curwin; |
18135
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2188 |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2189 if (mouse_row >= 0 && mouse_col >= 0) |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2190 { |
31135
759b181807f7
patch 9.0.0902: some mouse scroll code is not in a good place
Bram Moolenaar <Bram@vim.org>
parents:
31133
diff
changeset
|
2191 // Find the window at the mouse pointer coordinates. |
31144
388ef91ae4f5
patch 9.0.0906: mouse scroll code is not optimal
Bram Moolenaar <Bram@vim.org>
parents:
31135
diff
changeset
|
2192 // NOTE: Must restore "curwin" to "old_curwin" before returning! |
31135
759b181807f7
patch 9.0.0902: some mouse scroll code is not in a good place
Bram Moolenaar <Bram@vim.org>
parents:
31133
diff
changeset
|
2193 int row = mouse_row; |
759b181807f7
patch 9.0.0902: some mouse scroll code is not in a good place
Bram Moolenaar <Bram@vim.org>
parents:
31133
diff
changeset
|
2194 int col = mouse_col; |
31144
388ef91ae4f5
patch 9.0.0906: mouse scroll code is not optimal
Bram Moolenaar <Bram@vim.org>
parents:
31135
diff
changeset
|
2195 curwin = mouse_find_win(&row, &col, FIND_POPUP); |
388ef91ae4f5
patch 9.0.0906: mouse scroll code is not optimal
Bram Moolenaar <Bram@vim.org>
parents:
31135
diff
changeset
|
2196 if (curwin == NULL) |
388ef91ae4f5
patch 9.0.0906: mouse scroll code is not optimal
Bram Moolenaar <Bram@vim.org>
parents:
31135
diff
changeset
|
2197 { |
388ef91ae4f5
patch 9.0.0906: mouse scroll code is not optimal
Bram Moolenaar <Bram@vim.org>
parents:
31135
diff
changeset
|
2198 curwin = old_curwin; |
18135
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2199 return; |
31144
388ef91ae4f5
patch 9.0.0906: mouse scroll code is not optimal
Bram Moolenaar <Bram@vim.org>
parents:
31135
diff
changeset
|
2200 } |
388ef91ae4f5
patch 9.0.0906: mouse scroll code is not optimal
Bram Moolenaar <Bram@vim.org>
parents:
31135
diff
changeset
|
2201 |
18763
49b78d6465e5
patch 8.1.2371: FEAT_TEXT_PROP is a confusing name
Bram Moolenaar <Bram@vim.org>
parents:
18691
diff
changeset
|
2202 #ifdef FEAT_PROP_POPUP |
31144
388ef91ae4f5
patch 9.0.0906: mouse scroll code is not optimal
Bram Moolenaar <Bram@vim.org>
parents:
31135
diff
changeset
|
2203 if (WIN_IS_POPUP(curwin) && !curwin->w_has_scrollbar) |
388ef91ae4f5
patch 9.0.0906: mouse scroll code is not optimal
Bram Moolenaar <Bram@vim.org>
parents:
31135
diff
changeset
|
2204 { |
31135
759b181807f7
patch 9.0.0902: some mouse scroll code is not in a good place
Bram Moolenaar <Bram@vim.org>
parents:
31133
diff
changeset
|
2205 // cannot scroll this popup window |
31144
388ef91ae4f5
patch 9.0.0906: mouse scroll code is not optimal
Bram Moolenaar <Bram@vim.org>
parents:
31135
diff
changeset
|
2206 curwin = old_curwin; |
18135
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2207 return; |
31144
388ef91ae4f5
patch 9.0.0906: mouse scroll code is not optimal
Bram Moolenaar <Bram@vim.org>
parents:
31135
diff
changeset
|
2208 } |
18135
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2209 #endif |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2210 curbuf = curwin->w_buffer; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2211 } |
31103
33ca088dbd3e
patch 9.0.0886: horizontal mouse scroll only works in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
30980
diff
changeset
|
2212 |
31144
388ef91ae4f5
patch 9.0.0906: mouse scroll code is not optimal
Bram Moolenaar <Bram@vim.org>
parents:
31135
diff
changeset
|
2213 // Call the common mouse scroll function shared with other modes. |
388ef91ae4f5
patch 9.0.0906: mouse scroll code is not optimal
Bram Moolenaar <Bram@vim.org>
parents:
31135
diff
changeset
|
2214 do_mousescroll(cap); |
31103
33ca088dbd3e
patch 9.0.0886: horizontal mouse scroll only works in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
30980
diff
changeset
|
2215 |
31135
759b181807f7
patch 9.0.0902: some mouse scroll code is not in a good place
Bram Moolenaar <Bram@vim.org>
parents:
31133
diff
changeset
|
2216 #ifdef FEAT_SYN_HL |
759b181807f7
patch 9.0.0902: some mouse scroll code is not in a good place
Bram Moolenaar <Bram@vim.org>
parents:
31133
diff
changeset
|
2217 if (curwin != old_curwin && curwin->w_p_cul) |
18135
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2218 redraw_for_cursorline(curwin); |
31135
759b181807f7
patch 9.0.0902: some mouse scroll code is not in a good place
Bram Moolenaar <Bram@vim.org>
parents:
31133
diff
changeset
|
2219 #endif |
18135
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2220 curwin->w_redr_status = TRUE; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2221 curwin = old_curwin; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2222 curbuf = curwin->w_buffer; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2223 } |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2224 |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2225 /* |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2226 * Mouse clicks and drags. |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2227 */ |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2228 void |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2229 nv_mouse(cmdarg_T *cap) |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2230 { |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2231 (void)do_mouse(cap->oap, cap->cmdchar, BACKWARD, cap->count1, 0); |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2232 } |
18150
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2233 |
24784
288565c9b4e0
patch 8.2.2930: when a popup is visible a mouse move my restart Visual mode
Bram Moolenaar <Bram@vim.org>
parents:
23964
diff
changeset
|
2234 static int held_button = MOUSE_RELEASE; |
288565c9b4e0
patch 8.2.2930: when a popup is visible a mouse move my restart Visual mode
Bram Moolenaar <Bram@vim.org>
parents:
23964
diff
changeset
|
2235 |
288565c9b4e0
patch 8.2.2930: when a popup is visible a mouse move my restart Visual mode
Bram Moolenaar <Bram@vim.org>
parents:
23964
diff
changeset
|
2236 void |
288565c9b4e0
patch 8.2.2930: when a popup is visible a mouse move my restart Visual mode
Bram Moolenaar <Bram@vim.org>
parents:
23964
diff
changeset
|
2237 reset_held_button() |
288565c9b4e0
patch 8.2.2930: when a popup is visible a mouse move my restart Visual mode
Bram Moolenaar <Bram@vim.org>
parents:
23964
diff
changeset
|
2238 { |
288565c9b4e0
patch 8.2.2930: when a popup is visible a mouse move my restart Visual mode
Bram Moolenaar <Bram@vim.org>
parents:
23964
diff
changeset
|
2239 held_button = MOUSE_RELEASE; |
288565c9b4e0
patch 8.2.2930: when a popup is visible a mouse move my restart Visual mode
Bram Moolenaar <Bram@vim.org>
parents:
23964
diff
changeset
|
2240 } |
288565c9b4e0
patch 8.2.2930: when a popup is visible a mouse move my restart Visual mode
Bram Moolenaar <Bram@vim.org>
parents:
23964
diff
changeset
|
2241 |
18150
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2242 /* |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2243 * Check if typebuf 'tp' contains a terminal mouse code and returns the |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2244 * modifiers found in typebuf in 'modifiers'. |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2245 */ |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2246 int |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2247 check_termcode_mouse( |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2248 char_u *tp, |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2249 int *slen, |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2250 char_u *key_name, |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2251 char_u *modifiers_start, |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2252 int idx, |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2253 int *modifiers) |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2254 { |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2255 int j; |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2256 char_u *p; |
31135
759b181807f7
patch 9.0.0902: some mouse scroll code is not in a good place
Bram Moolenaar <Bram@vim.org>
parents:
31133
diff
changeset
|
2257 #if !defined(UNIX) || defined(FEAT_MOUSE_XTERM) || defined(FEAT_GUI) \ |
18150
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2258 || defined(FEAT_MOUSE_GPM) || defined(FEAT_SYSMOUSE) |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2259 char_u bytes[6]; |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2260 int num_bytes; |
31135
759b181807f7
patch 9.0.0902: some mouse scroll code is not in a good place
Bram Moolenaar <Bram@vim.org>
parents:
31133
diff
changeset
|
2261 #endif |
18150
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2262 int mouse_code = 0; // init for GCC |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2263 int is_click, is_drag; |
21114
d0265fdadec9
patch 8.2.1108: mouse left-right scroll is not supported in terminal window
Bram Moolenaar <Bram@vim.org>
parents:
19526
diff
changeset
|
2264 int is_release, release_is_ambiguous; |
18150
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2265 int wheel_code = 0; |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2266 int current_button; |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2267 static int orig_num_clicks = 1; |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2268 static int orig_mouse_code = 0x0; |
31135
759b181807f7
patch 9.0.0902: some mouse scroll code is not in a good place
Bram Moolenaar <Bram@vim.org>
parents:
31133
diff
changeset
|
2269 #ifdef CHECK_DOUBLE_CLICK |
18150
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2270 static int orig_mouse_col = 0; |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2271 static int orig_mouse_row = 0; |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2272 static struct timeval orig_mouse_time = {0, 0}; |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2273 // time of previous mouse click |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2274 struct timeval mouse_time; // time of current mouse click |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2275 long timediff; // elapsed time in msec |
31135
759b181807f7
patch 9.0.0902: some mouse scroll code is not in a good place
Bram Moolenaar <Bram@vim.org>
parents:
31133
diff
changeset
|
2276 #endif |
18150
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2277 |
21114
d0265fdadec9
patch 8.2.1108: mouse left-right scroll is not supported in terminal window
Bram Moolenaar <Bram@vim.org>
parents:
19526
diff
changeset
|
2278 is_click = is_drag = is_release = release_is_ambiguous = FALSE; |
18150
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2279 |
31135
759b181807f7
patch 9.0.0902: some mouse scroll code is not in a good place
Bram Moolenaar <Bram@vim.org>
parents:
31133
diff
changeset
|
2280 #if !defined(UNIX) || defined(FEAT_MOUSE_XTERM) || defined(FEAT_GUI) \ |
18150
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2281 || defined(FEAT_MOUSE_GPM) || defined(FEAT_SYSMOUSE) |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2282 if (key_name[0] == KS_MOUSE |
31135
759b181807f7
patch 9.0.0902: some mouse scroll code is not in a good place
Bram Moolenaar <Bram@vim.org>
parents:
31133
diff
changeset
|
2283 # ifdef FEAT_MOUSE_GPM |
18150
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2284 || key_name[0] == KS_GPM_MOUSE |
31135
759b181807f7
patch 9.0.0902: some mouse scroll code is not in a good place
Bram Moolenaar <Bram@vim.org>
parents:
31133
diff
changeset
|
2285 # endif |
18150
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2286 ) |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2287 { |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2288 /* |
21271
51ff7e5abdda
patch 8.2.1186: with SGR mouse codes balloon doesn't show up after click
Bram Moolenaar <Bram@vim.org>
parents:
21114
diff
changeset
|
2289 * For xterm we get "<t_mouse>scr", where s == encoded button state: |
18150
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2290 * 0x20 = left button down |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2291 * 0x21 = middle button down |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2292 * 0x22 = right button down |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2293 * 0x23 = any button release |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2294 * 0x60 = button 4 down (scroll wheel down) |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2295 * 0x61 = button 5 down (scroll wheel up) |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2296 * add 0x04 for SHIFT |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2297 * add 0x08 for ALT |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2298 * add 0x10 for CTRL |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2299 * add 0x20 for mouse drag (0x40 is drag with left button) |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2300 * add 0x40 for mouse move (0x80 is move, 0x81 too) |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2301 * 0x43 (drag + release) is also move |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2302 * c == column + ' ' + 1 == column + 33 |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2303 * r == row + ' ' + 1 == row + 33 |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2304 * |
21271
51ff7e5abdda
patch 8.2.1186: with SGR mouse codes balloon doesn't show up after click
Bram Moolenaar <Bram@vim.org>
parents:
21114
diff
changeset
|
2305 * The coordinates are passed on through global variables. Ugly, but |
51ff7e5abdda
patch 8.2.1186: with SGR mouse codes balloon doesn't show up after click
Bram Moolenaar <Bram@vim.org>
parents:
21114
diff
changeset
|
2306 * this avoids trouble with mouse clicks at an unexpected moment and |
51ff7e5abdda
patch 8.2.1186: with SGR mouse codes balloon doesn't show up after click
Bram Moolenaar <Bram@vim.org>
parents:
21114
diff
changeset
|
2307 * allows for mapping them. |
18150
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2308 */ |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2309 for (;;) |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2310 { |
31194
fa26d002eb2a
patch 9.0.0931: MS-Windows: mouse column limited to 223
Bram Moolenaar <Bram@vim.org>
parents:
31166
diff
changeset
|
2311 // For the GUI and for MS-Windows two bytes each are used for row |
fa26d002eb2a
patch 9.0.0931: MS-Windows: mouse column limited to 223
Bram Moolenaar <Bram@vim.org>
parents:
31166
diff
changeset
|
2312 // and column. Allows for more than 223 columns. |
fa26d002eb2a
patch 9.0.0931: MS-Windows: mouse column limited to 223
Bram Moolenaar <Bram@vim.org>
parents:
31166
diff
changeset
|
2313 # if defined(FEAT_GUI) || defined(MSWIN) |
fa26d002eb2a
patch 9.0.0931: MS-Windows: mouse column limited to 223
Bram Moolenaar <Bram@vim.org>
parents:
31166
diff
changeset
|
2314 if (TRUE |
fa26d002eb2a
patch 9.0.0931: MS-Windows: mouse column limited to 223
Bram Moolenaar <Bram@vim.org>
parents:
31166
diff
changeset
|
2315 # if defined(FEAT_GUI) && !defined(MSWIN) |
fa26d002eb2a
patch 9.0.0931: MS-Windows: mouse column limited to 223
Bram Moolenaar <Bram@vim.org>
parents:
31166
diff
changeset
|
2316 && gui.in_use |
fa26d002eb2a
patch 9.0.0931: MS-Windows: mouse column limited to 223
Bram Moolenaar <Bram@vim.org>
parents:
31166
diff
changeset
|
2317 # endif |
fa26d002eb2a
patch 9.0.0931: MS-Windows: mouse column limited to 223
Bram Moolenaar <Bram@vim.org>
parents:
31166
diff
changeset
|
2318 ) |
18150
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2319 { |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2320 num_bytes = get_bytes_from_buf(tp + *slen, bytes, 5); |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2321 if (num_bytes == -1) // not enough coordinates |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2322 return -1; |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2323 mouse_code = bytes[0]; |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2324 mouse_col = 128 * (bytes[1] - ' ' - 1) |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2325 + bytes[2] - ' ' - 1; |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2326 mouse_row = 128 * (bytes[3] - ' ' - 1) |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2327 + bytes[4] - ' ' - 1; |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2328 } |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2329 else |
31135
759b181807f7
patch 9.0.0902: some mouse scroll code is not in a good place
Bram Moolenaar <Bram@vim.org>
parents:
31133
diff
changeset
|
2330 # endif |
18150
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2331 { |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2332 num_bytes = get_bytes_from_buf(tp + *slen, bytes, 3); |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2333 if (num_bytes == -1) // not enough coordinates |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2334 return -1; |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2335 mouse_code = bytes[0]; |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2336 mouse_col = bytes[1] - ' ' - 1; |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2337 mouse_row = bytes[2] - ' ' - 1; |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2338 } |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2339 *slen += num_bytes; |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2340 |
21271
51ff7e5abdda
patch 8.2.1186: with SGR mouse codes balloon doesn't show up after click
Bram Moolenaar <Bram@vim.org>
parents:
21114
diff
changeset
|
2341 // If the following bytes is also a mouse code and it has the same |
51ff7e5abdda
patch 8.2.1186: with SGR mouse codes balloon doesn't show up after click
Bram Moolenaar <Bram@vim.org>
parents:
21114
diff
changeset
|
2342 // code, dump this one and get the next. This makes dragging a |
51ff7e5abdda
patch 8.2.1186: with SGR mouse codes balloon doesn't show up after click
Bram Moolenaar <Bram@vim.org>
parents:
21114
diff
changeset
|
2343 // whole lot faster. |
31135
759b181807f7
patch 9.0.0902: some mouse scroll code is not in a good place
Bram Moolenaar <Bram@vim.org>
parents:
31133
diff
changeset
|
2344 # ifdef FEAT_GUI |
18150
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2345 if (gui.in_use) |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2346 j = 3; |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2347 else |
31135
759b181807f7
patch 9.0.0902: some mouse scroll code is not in a good place
Bram Moolenaar <Bram@vim.org>
parents:
31133
diff
changeset
|
2348 # endif |
18150
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2349 j = get_termcode_len(idx); |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2350 if (STRNCMP(tp, tp + *slen, (size_t)j) == 0 |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2351 && tp[*slen + j] == mouse_code |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2352 && tp[*slen + j + 1] != NUL |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2353 && tp[*slen + j + 2] != NUL |
31135
759b181807f7
patch 9.0.0902: some mouse scroll code is not in a good place
Bram Moolenaar <Bram@vim.org>
parents:
31133
diff
changeset
|
2354 # ifdef FEAT_GUI |
18150
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2355 && (!gui.in_use |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2356 || (tp[*slen + j + 3] != NUL |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2357 && tp[*slen + j + 4] != NUL)) |
31135
759b181807f7
patch 9.0.0902: some mouse scroll code is not in a good place
Bram Moolenaar <Bram@vim.org>
parents:
31133
diff
changeset
|
2358 # endif |
18150
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2359 ) |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2360 *slen += j; |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2361 else |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2362 break; |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2363 } |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2364 } |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2365 |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2366 if (key_name[0] == KS_URXVT_MOUSE |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2367 || key_name[0] == KS_SGR_MOUSE |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2368 || key_name[0] == KS_SGR_MOUSE_RELEASE) |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2369 { |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2370 // URXVT 1015 mouse reporting mode: |
21271
51ff7e5abdda
patch 8.2.1186: with SGR mouse codes balloon doesn't show up after click
Bram Moolenaar <Bram@vim.org>
parents:
21114
diff
changeset
|
2371 // Almost identical to xterm mouse mode, except the values are decimal |
51ff7e5abdda
patch 8.2.1186: with SGR mouse codes balloon doesn't show up after click
Bram Moolenaar <Bram@vim.org>
parents:
21114
diff
changeset
|
2372 // instead of bytes. |
18150
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2373 // |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2374 // \033[%d;%d;%dM |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2375 // ^-- row |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2376 // ^----- column |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2377 // ^-------- code |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2378 // |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2379 // SGR 1006 mouse reporting mode: |
21271
51ff7e5abdda
patch 8.2.1186: with SGR mouse codes balloon doesn't show up after click
Bram Moolenaar <Bram@vim.org>
parents:
21114
diff
changeset
|
2380 // Almost identical to xterm mouse mode, except the values are decimal |
51ff7e5abdda
patch 8.2.1186: with SGR mouse codes balloon doesn't show up after click
Bram Moolenaar <Bram@vim.org>
parents:
21114
diff
changeset
|
2381 // instead of bytes. |
18150
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2382 // |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2383 // \033[<%d;%d;%dM |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2384 // ^-- row |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2385 // ^----- column |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2386 // ^-------- code |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2387 // |
28809
d0241e74bfdb
patch 8.2.4928: various white space and cosmetic mistakes
Bram Moolenaar <Bram@vim.org>
parents:
28773
diff
changeset
|
2388 // \033[<%d;%d;%dm : mouse release event |
18150
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2389 // ^-- row |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2390 // ^----- column |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2391 // ^-------- code |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2392 p = modifiers_start; |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2393 if (p == NULL) |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2394 return -1; |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2395 |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2396 mouse_code = getdigits(&p); |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2397 if (*p++ != ';') |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2398 return -1; |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2399 |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2400 // when mouse reporting is SGR, add 32 to mouse code |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2401 if (key_name[0] == KS_SGR_MOUSE |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2402 || key_name[0] == KS_SGR_MOUSE_RELEASE) |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2403 mouse_code += 32; |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2404 |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2405 mouse_col = getdigits(&p) - 1; |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2406 if (*p++ != ';') |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2407 return -1; |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2408 |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2409 mouse_row = getdigits(&p) - 1; |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2410 |
21271
51ff7e5abdda
patch 8.2.1186: with SGR mouse codes balloon doesn't show up after click
Bram Moolenaar <Bram@vim.org>
parents:
21114
diff
changeset
|
2411 // The modifiers were the mouse coordinates, not the modifier keys |
51ff7e5abdda
patch 8.2.1186: with SGR mouse codes balloon doesn't show up after click
Bram Moolenaar <Bram@vim.org>
parents:
21114
diff
changeset
|
2412 // (alt/shift/ctrl/meta) state. |
18150
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2413 *modifiers = 0; |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2414 } |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2415 |
21114
d0265fdadec9
patch 8.2.1108: mouse left-right scroll is not supported in terminal window
Bram Moolenaar <Bram@vim.org>
parents:
19526
diff
changeset
|
2416 if (key_name[0] == KS_SGR_MOUSE |
d0265fdadec9
patch 8.2.1108: mouse left-right scroll is not supported in terminal window
Bram Moolenaar <Bram@vim.org>
parents:
19526
diff
changeset
|
2417 || key_name[0] == KS_SGR_MOUSE_RELEASE) |
d0265fdadec9
patch 8.2.1108: mouse left-right scroll is not supported in terminal window
Bram Moolenaar <Bram@vim.org>
parents:
19526
diff
changeset
|
2418 { |
d0265fdadec9
patch 8.2.1108: mouse left-right scroll is not supported in terminal window
Bram Moolenaar <Bram@vim.org>
parents:
19526
diff
changeset
|
2419 if (key_name[0] == KS_SGR_MOUSE_RELEASE) |
21271
51ff7e5abdda
patch 8.2.1186: with SGR mouse codes balloon doesn't show up after click
Bram Moolenaar <Bram@vim.org>
parents:
21114
diff
changeset
|
2420 { |
21114
d0265fdadec9
patch 8.2.1108: mouse left-right scroll is not supported in terminal window
Bram Moolenaar <Bram@vim.org>
parents:
19526
diff
changeset
|
2421 is_release = TRUE; |
21271
51ff7e5abdda
patch 8.2.1186: with SGR mouse codes balloon doesn't show up after click
Bram Moolenaar <Bram@vim.org>
parents:
21114
diff
changeset
|
2422 // This is used below to set held_button. |
51ff7e5abdda
patch 8.2.1186: with SGR mouse codes balloon doesn't show up after click
Bram Moolenaar <Bram@vim.org>
parents:
21114
diff
changeset
|
2423 mouse_code |= MOUSE_RELEASE; |
51ff7e5abdda
patch 8.2.1186: with SGR mouse codes balloon doesn't show up after click
Bram Moolenaar <Bram@vim.org>
parents:
21114
diff
changeset
|
2424 } |
21114
d0265fdadec9
patch 8.2.1108: mouse left-right scroll is not supported in terminal window
Bram Moolenaar <Bram@vim.org>
parents:
19526
diff
changeset
|
2425 } |
d0265fdadec9
patch 8.2.1108: mouse left-right scroll is not supported in terminal window
Bram Moolenaar <Bram@vim.org>
parents:
19526
diff
changeset
|
2426 else |
d0265fdadec9
patch 8.2.1108: mouse left-right scroll is not supported in terminal window
Bram Moolenaar <Bram@vim.org>
parents:
19526
diff
changeset
|
2427 { |
d0265fdadec9
patch 8.2.1108: mouse left-right scroll is not supported in terminal window
Bram Moolenaar <Bram@vim.org>
parents:
19526
diff
changeset
|
2428 release_is_ambiguous = TRUE; |
d0265fdadec9
patch 8.2.1108: mouse left-right scroll is not supported in terminal window
Bram Moolenaar <Bram@vim.org>
parents:
19526
diff
changeset
|
2429 if ((mouse_code & MOUSE_RELEASE) == MOUSE_RELEASE) |
d0265fdadec9
patch 8.2.1108: mouse left-right scroll is not supported in terminal window
Bram Moolenaar <Bram@vim.org>
parents:
19526
diff
changeset
|
2430 is_release = TRUE; |
d0265fdadec9
patch 8.2.1108: mouse left-right scroll is not supported in terminal window
Bram Moolenaar <Bram@vim.org>
parents:
19526
diff
changeset
|
2431 } |
d0265fdadec9
patch 8.2.1108: mouse left-right scroll is not supported in terminal window
Bram Moolenaar <Bram@vim.org>
parents:
19526
diff
changeset
|
2432 |
18150
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2433 if (key_name[0] == KS_MOUSE |
31135
759b181807f7
patch 9.0.0902: some mouse scroll code is not in a good place
Bram Moolenaar <Bram@vim.org>
parents:
31133
diff
changeset
|
2434 # ifdef FEAT_MOUSE_GPM |
18150
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2435 || key_name[0] == KS_GPM_MOUSE |
31135
759b181807f7
patch 9.0.0902: some mouse scroll code is not in a good place
Bram Moolenaar <Bram@vim.org>
parents:
31133
diff
changeset
|
2436 # endif |
759b181807f7
patch 9.0.0902: some mouse scroll code is not in a good place
Bram Moolenaar <Bram@vim.org>
parents:
31133
diff
changeset
|
2437 # ifdef FEAT_MOUSE_URXVT |
18150
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2438 || key_name[0] == KS_URXVT_MOUSE |
31135
759b181807f7
patch 9.0.0902: some mouse scroll code is not in a good place
Bram Moolenaar <Bram@vim.org>
parents:
31133
diff
changeset
|
2439 # endif |
18150
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2440 || key_name[0] == KS_SGR_MOUSE |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2441 || key_name[0] == KS_SGR_MOUSE_RELEASE) |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2442 { |
31135
759b181807f7
patch 9.0.0902: some mouse scroll code is not in a good place
Bram Moolenaar <Bram@vim.org>
parents:
31133
diff
changeset
|
2443 # if !defined(MSWIN) |
18150
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2444 /* |
21271
51ff7e5abdda
patch 8.2.1186: with SGR mouse codes balloon doesn't show up after click
Bram Moolenaar <Bram@vim.org>
parents:
21114
diff
changeset
|
2445 * Handle old style mouse events. |
18150
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2446 * Recognize the xterm mouse wheel, but not in the GUI, the |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2447 * Linux console with GPM and the MS-DOS or Win32 console |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2448 * (multi-clicks use >= 0x60). |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2449 */ |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2450 if (mouse_code >= MOUSEWHEEL_LOW |
31135
759b181807f7
patch 9.0.0902: some mouse scroll code is not in a good place
Bram Moolenaar <Bram@vim.org>
parents:
31133
diff
changeset
|
2451 # ifdef FEAT_GUI |
18150
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2452 && !gui.in_use |
31135
759b181807f7
patch 9.0.0902: some mouse scroll code is not in a good place
Bram Moolenaar <Bram@vim.org>
parents:
31133
diff
changeset
|
2453 # endif |
759b181807f7
patch 9.0.0902: some mouse scroll code is not in a good place
Bram Moolenaar <Bram@vim.org>
parents:
31133
diff
changeset
|
2454 # ifdef FEAT_MOUSE_GPM |
18150
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2455 && key_name[0] != KS_GPM_MOUSE |
31135
759b181807f7
patch 9.0.0902: some mouse scroll code is not in a good place
Bram Moolenaar <Bram@vim.org>
parents:
31133
diff
changeset
|
2456 # endif |
18150
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2457 ) |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2458 { |
31135
759b181807f7
patch 9.0.0902: some mouse scroll code is not in a good place
Bram Moolenaar <Bram@vim.org>
parents:
31133
diff
changeset
|
2459 # if defined(UNIX) |
18150
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2460 if (use_xterm_mouse() > 1 && mouse_code >= 0x80) |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2461 // mouse-move event, using MOUSE_DRAG works |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2462 mouse_code = MOUSE_DRAG; |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2463 else |
31135
759b181807f7
patch 9.0.0902: some mouse scroll code is not in a good place
Bram Moolenaar <Bram@vim.org>
parents:
31133
diff
changeset
|
2464 # endif |
18150
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2465 // Keep the mouse_code before it's changed, so that we |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2466 // remember that it was a mouse wheel click. |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2467 wheel_code = mouse_code; |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2468 } |
31135
759b181807f7
patch 9.0.0902: some mouse scroll code is not in a good place
Bram Moolenaar <Bram@vim.org>
parents:
31133
diff
changeset
|
2469 # ifdef FEAT_MOUSE_XTERM |
18150
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2470 else if (held_button == MOUSE_RELEASE |
31135
759b181807f7
patch 9.0.0902: some mouse scroll code is not in a good place
Bram Moolenaar <Bram@vim.org>
parents:
31133
diff
changeset
|
2471 # ifdef FEAT_GUI |
18150
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2472 && !gui.in_use |
31135
759b181807f7
patch 9.0.0902: some mouse scroll code is not in a good place
Bram Moolenaar <Bram@vim.org>
parents:
31133
diff
changeset
|
2473 # endif |
18150
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2474 && (mouse_code == 0x23 || mouse_code == 0x24 |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2475 || mouse_code == 0x40 || mouse_code == 0x41)) |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2476 { |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2477 // Apparently 0x23 and 0x24 are used by rxvt scroll wheel. |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2478 // And 0x40 and 0x41 are used by some xterm emulator. |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2479 wheel_code = mouse_code - (mouse_code >= 0x40 ? 0x40 : 0x23) |
29591
eb07470d0395
patch 9.0.0136: after CTRL-Left-mouse click a mouse scroll also has CTRL
Bram Moolenaar <Bram@vim.org>
parents:
29451
diff
changeset
|
2480 + MOUSEWHEEL_LOW; |
18150
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2481 } |
31135
759b181807f7
patch 9.0.0902: some mouse scroll code is not in a good place
Bram Moolenaar <Bram@vim.org>
parents:
31133
diff
changeset
|
2482 # endif |
18150
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2483 |
31135
759b181807f7
patch 9.0.0902: some mouse scroll code is not in a good place
Bram Moolenaar <Bram@vim.org>
parents:
31133
diff
changeset
|
2484 # if defined(UNIX) |
18150
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2485 else if (use_xterm_mouse() > 1) |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2486 { |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2487 if (mouse_code & MOUSE_DRAG_XTERM) |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2488 mouse_code |= MOUSE_DRAG; |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2489 } |
31135
759b181807f7
patch 9.0.0902: some mouse scroll code is not in a good place
Bram Moolenaar <Bram@vim.org>
parents:
31133
diff
changeset
|
2490 # endif |
759b181807f7
patch 9.0.0902: some mouse scroll code is not in a good place
Bram Moolenaar <Bram@vim.org>
parents:
31133
diff
changeset
|
2491 # ifdef FEAT_XCLIPBOARD |
18150
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2492 else if (!(mouse_code & MOUSE_DRAG & ~MOUSE_CLICK_MASK)) |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2493 { |
21114
d0265fdadec9
patch 8.2.1108: mouse left-right scroll is not supported in terminal window
Bram Moolenaar <Bram@vim.org>
parents:
19526
diff
changeset
|
2494 if (is_release) |
18150
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2495 stop_xterm_trace(); |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2496 else |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2497 start_xterm_trace(mouse_code); |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2498 } |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2499 # endif |
31135
759b181807f7
patch 9.0.0902: some mouse scroll code is not in a good place
Bram Moolenaar <Bram@vim.org>
parents:
31133
diff
changeset
|
2500 # endif |
18150
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2501 } |
31135
759b181807f7
patch 9.0.0902: some mouse scroll code is not in a good place
Bram Moolenaar <Bram@vim.org>
parents:
31133
diff
changeset
|
2502 #endif // !UNIX || FEAT_MOUSE_XTERM |
759b181807f7
patch 9.0.0902: some mouse scroll code is not in a good place
Bram Moolenaar <Bram@vim.org>
parents:
31133
diff
changeset
|
2503 #ifdef FEAT_MOUSE_NET |
18150
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2504 if (key_name[0] == KS_NETTERM_MOUSE) |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2505 { |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2506 int mc, mr; |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2507 |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2508 // expect a rather limited sequence like: balancing { |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2509 // \033}6,45\r |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2510 // '6' is the row, 45 is the column |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2511 p = tp + *slen; |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2512 mr = getdigits(&p); |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2513 if (*p++ != ',') |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2514 return -1; |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2515 mc = getdigits(&p); |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2516 if (*p++ != '\r') |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2517 return -1; |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2518 |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2519 mouse_col = mc - 1; |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2520 mouse_row = mr - 1; |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2521 mouse_code = MOUSE_LEFT; |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2522 *slen += (int)(p - (tp + *slen)); |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2523 } |
31135
759b181807f7
patch 9.0.0902: some mouse scroll code is not in a good place
Bram Moolenaar <Bram@vim.org>
parents:
31133
diff
changeset
|
2524 #endif // FEAT_MOUSE_NET |
759b181807f7
patch 9.0.0902: some mouse scroll code is not in a good place
Bram Moolenaar <Bram@vim.org>
parents:
31133
diff
changeset
|
2525 #ifdef FEAT_MOUSE_JSB |
18150
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2526 if (key_name[0] == KS_JSBTERM_MOUSE) |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2527 { |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2528 int mult, val, iter, button, status; |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2529 |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2530 /* |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2531 * JSBTERM Input Model |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2532 * \033[0~zw uniq escape sequence |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2533 * (L-x) Left button pressed - not pressed x not reporting |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2534 * (M-x) Middle button pressed - not pressed x not reporting |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2535 * (R-x) Right button pressed - not pressed x not reporting |
21271
51ff7e5abdda
patch 8.2.1186: with SGR mouse codes balloon doesn't show up after click
Bram Moolenaar <Bram@vim.org>
parents:
21114
diff
changeset
|
2536 * (SDmdu) Single , Double click, m: mouse move, d: button down, |
51ff7e5abdda
patch 8.2.1186: with SGR mouse codes balloon doesn't show up after click
Bram Moolenaar <Bram@vim.org>
parents:
21114
diff
changeset
|
2537 * u: button up |
18150
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2538 * ### X cursor position padded to 3 digits |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2539 * ### Y cursor position padded to 3 digits |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2540 * (s-x) SHIFT key pressed - not pressed x not reporting |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2541 * (c-x) CTRL key pressed - not pressed x not reporting |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2542 * \033\\ terminating sequence |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2543 */ |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2544 p = tp + *slen; |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2545 button = mouse_code = 0; |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2546 switch (*p++) |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2547 { |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2548 case 'L': button = 1; break; |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2549 case '-': break; |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2550 case 'x': break; // ignore sequence |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2551 default: return -1; // Unknown Result |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2552 } |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2553 switch (*p++) |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2554 { |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2555 case 'M': button |= 2; break; |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2556 case '-': break; |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2557 case 'x': break; // ignore sequence |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2558 default: return -1; // Unknown Result |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2559 } |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2560 switch (*p++) |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2561 { |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2562 case 'R': button |= 4; break; |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2563 case '-': break; |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2564 case 'x': break; // ignore sequence |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2565 default: return -1; // Unknown Result |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2566 } |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2567 status = *p++; |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2568 for (val = 0, mult = 100, iter = 0; iter < 3; iter++, |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2569 mult /= 10, p++) |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2570 if (*p >= '0' && *p <= '9') |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2571 val += (*p - '0') * mult; |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2572 else |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2573 return -1; |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2574 mouse_col = val; |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2575 for (val = 0, mult = 100, iter = 0; iter < 3; iter++, |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2576 mult /= 10, p++) |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2577 if (*p >= '0' && *p <= '9') |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2578 val += (*p - '0') * mult; |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2579 else |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2580 return -1; |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2581 mouse_row = val; |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2582 switch (*p++) |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2583 { |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2584 case 's': button |= 8; break; // SHIFT key Pressed |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2585 case '-': break; // Not Pressed |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2586 case 'x': break; // Not Reporting |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2587 default: return -1; // Unknown Result |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2588 } |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2589 switch (*p++) |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2590 { |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2591 case 'c': button |= 16; break; // CTRL key Pressed |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2592 case '-': break; // Not Pressed |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2593 case 'x': break; // Not Reporting |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2594 default: return -1; // Unknown Result |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2595 } |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2596 if (*p++ != '\033') |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2597 return -1; |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2598 if (*p++ != '\\') |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2599 return -1; |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2600 switch (status) |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2601 { |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2602 case 'D': // Double Click |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2603 case 'S': // Single Click |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2604 if (button & 1) mouse_code |= MOUSE_LEFT; |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2605 if (button & 2) mouse_code |= MOUSE_MIDDLE; |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2606 if (button & 4) mouse_code |= MOUSE_RIGHT; |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2607 if (button & 8) mouse_code |= MOUSE_SHIFT; |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2608 if (button & 16) mouse_code |= MOUSE_CTRL; |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2609 break; |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2610 case 'm': // Mouse move |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2611 if (button & 1) mouse_code |= MOUSE_LEFT; |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2612 if (button & 2) mouse_code |= MOUSE_MIDDLE; |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2613 if (button & 4) mouse_code |= MOUSE_RIGHT; |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2614 if (button & 8) mouse_code |= MOUSE_SHIFT; |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2615 if (button & 16) mouse_code |= MOUSE_CTRL; |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2616 if ((button & 7) != 0) |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2617 { |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2618 held_button = mouse_code; |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2619 mouse_code |= MOUSE_DRAG; |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2620 } |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2621 is_drag = TRUE; |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2622 showmode(); |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2623 break; |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2624 case 'd': // Button Down |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2625 if (button & 1) mouse_code |= MOUSE_LEFT; |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2626 if (button & 2) mouse_code |= MOUSE_MIDDLE; |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2627 if (button & 4) mouse_code |= MOUSE_RIGHT; |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2628 if (button & 8) mouse_code |= MOUSE_SHIFT; |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2629 if (button & 16) mouse_code |= MOUSE_CTRL; |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2630 break; |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2631 case 'u': // Button Up |
21114
d0265fdadec9
patch 8.2.1108: mouse left-right scroll is not supported in terminal window
Bram Moolenaar <Bram@vim.org>
parents:
19526
diff
changeset
|
2632 is_release = TRUE; |
18150
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2633 if (button & 1) |
21114
d0265fdadec9
patch 8.2.1108: mouse left-right scroll is not supported in terminal window
Bram Moolenaar <Bram@vim.org>
parents:
19526
diff
changeset
|
2634 mouse_code |= MOUSE_LEFT; |
18150
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2635 if (button & 2) |
21114
d0265fdadec9
patch 8.2.1108: mouse left-right scroll is not supported in terminal window
Bram Moolenaar <Bram@vim.org>
parents:
19526
diff
changeset
|
2636 mouse_code |= MOUSE_MIDDLE; |
18150
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2637 if (button & 4) |
21114
d0265fdadec9
patch 8.2.1108: mouse left-right scroll is not supported in terminal window
Bram Moolenaar <Bram@vim.org>
parents:
19526
diff
changeset
|
2638 mouse_code |= MOUSE_RIGHT; |
18150
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2639 if (button & 8) |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2640 mouse_code |= MOUSE_SHIFT; |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2641 if (button & 16) |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2642 mouse_code |= MOUSE_CTRL; |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2643 break; |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2644 default: return -1; // Unknown Result |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2645 } |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2646 |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2647 *slen += (p - (tp + *slen)); |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2648 } |
31135
759b181807f7
patch 9.0.0902: some mouse scroll code is not in a good place
Bram Moolenaar <Bram@vim.org>
parents:
31133
diff
changeset
|
2649 #endif // FEAT_MOUSE_JSB |
759b181807f7
patch 9.0.0902: some mouse scroll code is not in a good place
Bram Moolenaar <Bram@vim.org>
parents:
31133
diff
changeset
|
2650 #ifdef FEAT_MOUSE_DEC |
18150
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2651 if (key_name[0] == KS_DEC_MOUSE) |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2652 { |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2653 /* |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2654 * The DEC Locator Input Model |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2655 * Netterm delivers the code sequence: |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2656 * \033[2;4;24;80&w (left button down) |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2657 * \033[3;0;24;80&w (left button up) |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2658 * \033[6;1;24;80&w (right button down) |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2659 * \033[7;0;24;80&w (right button up) |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2660 * CSI Pe ; Pb ; Pr ; Pc ; Pp & w |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2661 * Pe is the event code |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2662 * Pb is the button code |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2663 * Pr is the row coordinate |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2664 * Pc is the column coordinate |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2665 * Pp is the third coordinate (page number) |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2666 * Pe, the event code indicates what event caused this report |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2667 * The following event codes are defined: |
21271
51ff7e5abdda
patch 8.2.1186: with SGR mouse codes balloon doesn't show up after click
Bram Moolenaar <Bram@vim.org>
parents:
21114
diff
changeset
|
2668 * 0 - request, the terminal received an explicit request for a |
28809
d0241e74bfdb
patch 8.2.4928: various white space and cosmetic mistakes
Bram Moolenaar <Bram@vim.org>
parents:
28773
diff
changeset
|
2669 * locator report, but the locator is unavailable |
21271
51ff7e5abdda
patch 8.2.1186: with SGR mouse codes balloon doesn't show up after click
Bram Moolenaar <Bram@vim.org>
parents:
21114
diff
changeset
|
2670 * 1 - request, the terminal received an explicit request for a |
28809
d0241e74bfdb
patch 8.2.4928: various white space and cosmetic mistakes
Bram Moolenaar <Bram@vim.org>
parents:
28773
diff
changeset
|
2671 * locator report |
18150
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2672 * 2 - left button down |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2673 * 3 - left button up |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2674 * 4 - middle button down |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2675 * 5 - middle button up |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2676 * 6 - right button down |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2677 * 7 - right button up |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2678 * 8 - fourth button down |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2679 * 9 - fourth button up |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2680 * 10 - locator outside filter rectangle |
21271
51ff7e5abdda
patch 8.2.1186: with SGR mouse codes balloon doesn't show up after click
Bram Moolenaar <Bram@vim.org>
parents:
21114
diff
changeset
|
2681 * Pb, the button code, ASCII decimal 0-15 indicating which buttons are |
51ff7e5abdda
patch 8.2.1186: with SGR mouse codes balloon doesn't show up after click
Bram Moolenaar <Bram@vim.org>
parents:
21114
diff
changeset
|
2682 * down if any. The state of the four buttons on the locator |
51ff7e5abdda
patch 8.2.1186: with SGR mouse codes balloon doesn't show up after click
Bram Moolenaar <Bram@vim.org>
parents:
21114
diff
changeset
|
2683 * correspond to the low four bits of the decimal value, "1" means |
51ff7e5abdda
patch 8.2.1186: with SGR mouse codes balloon doesn't show up after click
Bram Moolenaar <Bram@vim.org>
parents:
21114
diff
changeset
|
2684 * button depressed |
18150
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2685 * 0 - no buttons down, |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2686 * 1 - right, |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2687 * 2 - middle, |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2688 * 4 - left, |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2689 * 8 - fourth |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2690 * Pr is the row coordinate of the locator position in the page, |
21271
51ff7e5abdda
patch 8.2.1186: with SGR mouse codes balloon doesn't show up after click
Bram Moolenaar <Bram@vim.org>
parents:
21114
diff
changeset
|
2691 * encoded as an ASCII decimal value. If Pr is omitted, the locator |
51ff7e5abdda
patch 8.2.1186: with SGR mouse codes balloon doesn't show up after click
Bram Moolenaar <Bram@vim.org>
parents:
21114
diff
changeset
|
2692 * position is undefined (outside the terminal window for example). |
51ff7e5abdda
patch 8.2.1186: with SGR mouse codes balloon doesn't show up after click
Bram Moolenaar <Bram@vim.org>
parents:
21114
diff
changeset
|
2693 * Pc is the column coordinate of the locator position in the page, |
51ff7e5abdda
patch 8.2.1186: with SGR mouse codes balloon doesn't show up after click
Bram Moolenaar <Bram@vim.org>
parents:
21114
diff
changeset
|
2694 * encoded as an ASCII decimal value. If Pc is omitted, the locator |
51ff7e5abdda
patch 8.2.1186: with SGR mouse codes balloon doesn't show up after click
Bram Moolenaar <Bram@vim.org>
parents:
21114
diff
changeset
|
2695 * position is undefined (outside the terminal window for example). |
51ff7e5abdda
patch 8.2.1186: with SGR mouse codes balloon doesn't show up after click
Bram Moolenaar <Bram@vim.org>
parents:
21114
diff
changeset
|
2696 * Pp is the page coordinate of the locator position encoded as an |
51ff7e5abdda
patch 8.2.1186: with SGR mouse codes balloon doesn't show up after click
Bram Moolenaar <Bram@vim.org>
parents:
21114
diff
changeset
|
2697 * ASCII decimal value. The page coordinate may be omitted if the |
51ff7e5abdda
patch 8.2.1186: with SGR mouse codes balloon doesn't show up after click
Bram Moolenaar <Bram@vim.org>
parents:
21114
diff
changeset
|
2698 * locator is on page one (the default). We ignore it anyway. |
18150
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2699 */ |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2700 int Pe, Pb, Pr, Pc; |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2701 |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2702 p = tp + *slen; |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2703 |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2704 // get event status |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2705 Pe = getdigits(&p); |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2706 if (*p++ != ';') |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2707 return -1; |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2708 |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2709 // get button status |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2710 Pb = getdigits(&p); |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2711 if (*p++ != ';') |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2712 return -1; |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2713 |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2714 // get row status |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2715 Pr = getdigits(&p); |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2716 if (*p++ != ';') |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2717 return -1; |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2718 |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2719 // get column status |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2720 Pc = getdigits(&p); |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2721 |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2722 // the page parameter is optional |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2723 if (*p == ';') |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2724 { |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2725 p++; |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2726 (void)getdigits(&p); |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2727 } |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2728 if (*p++ != '&') |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2729 return -1; |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2730 if (*p++ != 'w') |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2731 return -1; |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2732 |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2733 mouse_code = 0; |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2734 switch (Pe) |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2735 { |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2736 case 0: return -1; // position request while unavailable |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2737 case 1: // a response to a locator position request includes |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2738 // the status of all buttons |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2739 Pb &= 7; // mask off and ignore fourth button |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2740 if (Pb & 4) |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2741 mouse_code = MOUSE_LEFT; |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2742 if (Pb & 2) |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2743 mouse_code = MOUSE_MIDDLE; |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2744 if (Pb & 1) |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2745 mouse_code = MOUSE_RIGHT; |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2746 if (Pb) |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2747 { |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2748 held_button = mouse_code; |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2749 mouse_code |= MOUSE_DRAG; |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2750 WantQueryMouse = TRUE; |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2751 } |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2752 is_drag = TRUE; |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2753 showmode(); |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2754 break; |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2755 case 2: mouse_code = MOUSE_LEFT; |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2756 WantQueryMouse = TRUE; |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2757 break; |
21114
d0265fdadec9
patch 8.2.1108: mouse left-right scroll is not supported in terminal window
Bram Moolenaar <Bram@vim.org>
parents:
19526
diff
changeset
|
2758 case 3: mouse_code = MOUSE_LEFT; |
d0265fdadec9
patch 8.2.1108: mouse left-right scroll is not supported in terminal window
Bram Moolenaar <Bram@vim.org>
parents:
19526
diff
changeset
|
2759 is_release = TRUE; |
18150
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2760 break; |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2761 case 4: mouse_code = MOUSE_MIDDLE; |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2762 WantQueryMouse = TRUE; |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2763 break; |
21114
d0265fdadec9
patch 8.2.1108: mouse left-right scroll is not supported in terminal window
Bram Moolenaar <Bram@vim.org>
parents:
19526
diff
changeset
|
2764 case 5: mouse_code = MOUSE_MIDDLE; |
d0265fdadec9
patch 8.2.1108: mouse left-right scroll is not supported in terminal window
Bram Moolenaar <Bram@vim.org>
parents:
19526
diff
changeset
|
2765 is_release = TRUE; |
18150
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2766 break; |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2767 case 6: mouse_code = MOUSE_RIGHT; |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2768 WantQueryMouse = TRUE; |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2769 break; |
21114
d0265fdadec9
patch 8.2.1108: mouse left-right scroll is not supported in terminal window
Bram Moolenaar <Bram@vim.org>
parents:
19526
diff
changeset
|
2770 case 7: mouse_code = MOUSE_RIGHT; |
d0265fdadec9
patch 8.2.1108: mouse left-right scroll is not supported in terminal window
Bram Moolenaar <Bram@vim.org>
parents:
19526
diff
changeset
|
2771 is_release = TRUE; |
18150
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2772 break; |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2773 case 8: return -1; // fourth button down |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2774 case 9: return -1; // fourth button up |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2775 case 10: return -1; // mouse outside of filter rectangle |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2776 default: return -1; // should never occur |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2777 } |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2778 |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2779 mouse_col = Pc - 1; |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2780 mouse_row = Pr - 1; |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2781 |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2782 *slen += (int)(p - (tp + *slen)); |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2783 } |
31135
759b181807f7
patch 9.0.0902: some mouse scroll code is not in a good place
Bram Moolenaar <Bram@vim.org>
parents:
31133
diff
changeset
|
2784 #endif // FEAT_MOUSE_DEC |
759b181807f7
patch 9.0.0902: some mouse scroll code is not in a good place
Bram Moolenaar <Bram@vim.org>
parents:
31133
diff
changeset
|
2785 #ifdef FEAT_MOUSE_PTERM |
18150
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2786 if (key_name[0] == KS_PTERM_MOUSE) |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2787 { |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2788 int button, num_clicks, action; |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2789 |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2790 p = tp + *slen; |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2791 |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2792 action = getdigits(&p); |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2793 if (*p++ != ';') |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2794 return -1; |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2795 |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2796 mouse_row = getdigits(&p); |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2797 if (*p++ != ';') |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2798 return -1; |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2799 mouse_col = getdigits(&p); |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2800 if (*p++ != ';') |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2801 return -1; |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2802 |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2803 button = getdigits(&p); |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2804 mouse_code = 0; |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2805 |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2806 switch (button) |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2807 { |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2808 case 4: mouse_code = MOUSE_LEFT; break; |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2809 case 1: mouse_code = MOUSE_RIGHT; break; |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2810 case 2: mouse_code = MOUSE_MIDDLE; break; |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2811 default: return -1; |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2812 } |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2813 |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2814 switch (action) |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2815 { |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2816 case 31: // Initial press |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2817 if (*p++ != ';') |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2818 return -1; |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2819 |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2820 num_clicks = getdigits(&p); // Not used |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2821 break; |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2822 |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2823 case 32: // Release |
21114
d0265fdadec9
patch 8.2.1108: mouse left-right scroll is not supported in terminal window
Bram Moolenaar <Bram@vim.org>
parents:
19526
diff
changeset
|
2824 is_release = TRUE; |
18150
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2825 break; |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2826 |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2827 case 33: // Drag |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2828 held_button = mouse_code; |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2829 mouse_code |= MOUSE_DRAG; |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2830 break; |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2831 |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2832 default: |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2833 return -1; |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2834 } |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2835 |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2836 if (*p++ != 't') |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2837 return -1; |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2838 |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2839 *slen += (p - (tp + *slen)); |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2840 } |
31135
759b181807f7
patch 9.0.0902: some mouse scroll code is not in a good place
Bram Moolenaar <Bram@vim.org>
parents:
31133
diff
changeset
|
2841 #endif // FEAT_MOUSE_PTERM |
18150
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2842 |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2843 // Interpret the mouse code |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2844 current_button = (mouse_code & MOUSE_CLICK_MASK); |
21114
d0265fdadec9
patch 8.2.1108: mouse left-right scroll is not supported in terminal window
Bram Moolenaar <Bram@vim.org>
parents:
19526
diff
changeset
|
2845 if (is_release) |
d0265fdadec9
patch 8.2.1108: mouse left-right scroll is not supported in terminal window
Bram Moolenaar <Bram@vim.org>
parents:
19526
diff
changeset
|
2846 current_button |= MOUSE_RELEASE; |
d0265fdadec9
patch 8.2.1108: mouse left-right scroll is not supported in terminal window
Bram Moolenaar <Bram@vim.org>
parents:
19526
diff
changeset
|
2847 |
18150
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2848 if (current_button == MOUSE_RELEASE |
31135
759b181807f7
patch 9.0.0902: some mouse scroll code is not in a good place
Bram Moolenaar <Bram@vim.org>
parents:
31133
diff
changeset
|
2849 #ifdef FEAT_MOUSE_XTERM |
18150
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2850 && wheel_code == 0 |
31135
759b181807f7
patch 9.0.0902: some mouse scroll code is not in a good place
Bram Moolenaar <Bram@vim.org>
parents:
31133
diff
changeset
|
2851 #endif |
18150
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2852 ) |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2853 { |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2854 /* |
21271
51ff7e5abdda
patch 8.2.1186: with SGR mouse codes balloon doesn't show up after click
Bram Moolenaar <Bram@vim.org>
parents:
21114
diff
changeset
|
2855 * If we get a mouse drag or release event when there is no mouse |
51ff7e5abdda
patch 8.2.1186: with SGR mouse codes balloon doesn't show up after click
Bram Moolenaar <Bram@vim.org>
parents:
21114
diff
changeset
|
2856 * button held down (held_button == MOUSE_RELEASE), produce a K_IGNORE |
51ff7e5abdda
patch 8.2.1186: with SGR mouse codes balloon doesn't show up after click
Bram Moolenaar <Bram@vim.org>
parents:
21114
diff
changeset
|
2857 * below. |
51ff7e5abdda
patch 8.2.1186: with SGR mouse codes balloon doesn't show up after click
Bram Moolenaar <Bram@vim.org>
parents:
21114
diff
changeset
|
2858 * (can happen when you hold down two buttons and then let them go, or |
51ff7e5abdda
patch 8.2.1186: with SGR mouse codes balloon doesn't show up after click
Bram Moolenaar <Bram@vim.org>
parents:
21114
diff
changeset
|
2859 * click in the menu bar, but not on a menu, and drag into the text). |
18150
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2860 */ |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2861 if ((mouse_code & MOUSE_DRAG) == MOUSE_DRAG) |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2862 is_drag = TRUE; |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2863 current_button = held_button; |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2864 } |
29591
eb07470d0395
patch 9.0.0136: after CTRL-Left-mouse click a mouse scroll also has CTRL
Bram Moolenaar <Bram@vim.org>
parents:
29451
diff
changeset
|
2865 else |
18150
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2866 { |
29591
eb07470d0395
patch 9.0.0136: after CTRL-Left-mouse click a mouse scroll also has CTRL
Bram Moolenaar <Bram@vim.org>
parents:
29451
diff
changeset
|
2867 if (wheel_code == 0) |
eb07470d0395
patch 9.0.0136: after CTRL-Left-mouse click a mouse scroll also has CTRL
Bram Moolenaar <Bram@vim.org>
parents:
29451
diff
changeset
|
2868 { |
31135
759b181807f7
patch 9.0.0902: some mouse scroll code is not in a good place
Bram Moolenaar <Bram@vim.org>
parents:
31133
diff
changeset
|
2869 #ifdef CHECK_DOUBLE_CLICK |
759b181807f7
patch 9.0.0902: some mouse scroll code is not in a good place
Bram Moolenaar <Bram@vim.org>
parents:
31133
diff
changeset
|
2870 # ifdef FEAT_MOUSE_GPM |
18150
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2871 /* |
21271
51ff7e5abdda
patch 8.2.1186: with SGR mouse codes balloon doesn't show up after click
Bram Moolenaar <Bram@vim.org>
parents:
21114
diff
changeset
|
2872 * Only for Unix, when GUI not active, we handle multi-clicks here, but |
51ff7e5abdda
patch 8.2.1186: with SGR mouse codes balloon doesn't show up after click
Bram Moolenaar <Bram@vim.org>
parents:
21114
diff
changeset
|
2873 * not for GPM mouse events. |
18150
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2874 */ |
31135
759b181807f7
patch 9.0.0902: some mouse scroll code is not in a good place
Bram Moolenaar <Bram@vim.org>
parents:
31133
diff
changeset
|
2875 # ifdef FEAT_GUI |
18150
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2876 if (key_name[0] != KS_GPM_MOUSE && !gui.in_use) |
31135
759b181807f7
patch 9.0.0902: some mouse scroll code is not in a good place
Bram Moolenaar <Bram@vim.org>
parents:
31133
diff
changeset
|
2877 # else |
18150
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2878 if (key_name[0] != KS_GPM_MOUSE) |
31135
759b181807f7
patch 9.0.0902: some mouse scroll code is not in a good place
Bram Moolenaar <Bram@vim.org>
parents:
31133
diff
changeset
|
2879 # endif |
759b181807f7
patch 9.0.0902: some mouse scroll code is not in a good place
Bram Moolenaar <Bram@vim.org>
parents:
31133
diff
changeset
|
2880 # else |
759b181807f7
patch 9.0.0902: some mouse scroll code is not in a good place
Bram Moolenaar <Bram@vim.org>
parents:
31133
diff
changeset
|
2881 # ifdef FEAT_GUI |
18150
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2882 if (!gui.in_use) |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2883 # endif |
31135
759b181807f7
patch 9.0.0902: some mouse scroll code is not in a good place
Bram Moolenaar <Bram@vim.org>
parents:
31133
diff
changeset
|
2884 # endif |
18150
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2885 { |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2886 /* |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2887 * Compute the time elapsed since the previous mouse click. |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2888 */ |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2889 gettimeofday(&mouse_time, NULL); |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2890 if (orig_mouse_time.tv_sec == 0) |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2891 { |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2892 /* |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2893 * Avoid computing the difference between mouse_time |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2894 * and orig_mouse_time for the first click, as the |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2895 * difference would be huge and would cause |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2896 * multiplication overflow. |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2897 */ |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2898 timediff = p_mouset; |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2899 } |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2900 else |
18691
fb07fe556e67
patch 8.1.2337: double-click time sometimes miscomputed
Bram Moolenaar <Bram@vim.org>
parents:
18658
diff
changeset
|
2901 timediff = time_diff_ms(&orig_mouse_time, &mouse_time); |
18150
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2902 orig_mouse_time = mouse_time; |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2903 if (mouse_code == orig_mouse_code |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2904 && timediff < p_mouset |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2905 && orig_num_clicks != 4 |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2906 && orig_mouse_col == mouse_col |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2907 && orig_mouse_row == mouse_row |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2908 && (is_mouse_topline(curwin) |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2909 // Double click in tab pages line also works |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2910 // when window contents changes. |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2911 || (mouse_row == 0 && firstwin->w_winrow > 0)) |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2912 ) |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2913 ++orig_num_clicks; |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2914 else |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2915 orig_num_clicks = 1; |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2916 orig_mouse_col = mouse_col; |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2917 orig_mouse_row = mouse_row; |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2918 set_mouse_topline(curwin); |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2919 } |
31135
759b181807f7
patch 9.0.0902: some mouse scroll code is not in a good place
Bram Moolenaar <Bram@vim.org>
parents:
31133
diff
changeset
|
2920 # if defined(FEAT_GUI) || defined(FEAT_MOUSE_GPM) |
18150
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2921 else |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2922 orig_num_clicks = NUM_MOUSE_CLICKS(mouse_code); |
31135
759b181807f7
patch 9.0.0902: some mouse scroll code is not in a good place
Bram Moolenaar <Bram@vim.org>
parents:
31133
diff
changeset
|
2923 # endif |
759b181807f7
patch 9.0.0902: some mouse scroll code is not in a good place
Bram Moolenaar <Bram@vim.org>
parents:
31133
diff
changeset
|
2924 #else |
18150
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2925 orig_num_clicks = NUM_MOUSE_CLICKS(mouse_code); |
31135
759b181807f7
patch 9.0.0902: some mouse scroll code is not in a good place
Bram Moolenaar <Bram@vim.org>
parents:
31133
diff
changeset
|
2926 #endif |
18150
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2927 is_click = TRUE; |
29591
eb07470d0395
patch 9.0.0136: after CTRL-Left-mouse click a mouse scroll also has CTRL
Bram Moolenaar <Bram@vim.org>
parents:
29451
diff
changeset
|
2928 } |
eb07470d0395
patch 9.0.0136: after CTRL-Left-mouse click a mouse scroll also has CTRL
Bram Moolenaar <Bram@vim.org>
parents:
29451
diff
changeset
|
2929 orig_mouse_code = mouse_code; |
18150
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2930 } |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2931 if (!is_drag) |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2932 held_button = mouse_code & MOUSE_CLICK_MASK; |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2933 |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2934 /* |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2935 * Translate the actual mouse event into a pseudo mouse event. |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2936 * First work out what modifiers are to be used. |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2937 */ |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2938 if (orig_mouse_code & MOUSE_SHIFT) |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2939 *modifiers |= MOD_MASK_SHIFT; |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2940 if (orig_mouse_code & MOUSE_CTRL) |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2941 *modifiers |= MOD_MASK_CTRL; |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2942 if (orig_mouse_code & MOUSE_ALT) |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2943 *modifiers |= MOD_MASK_ALT; |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2944 if (orig_num_clicks == 2) |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2945 *modifiers |= MOD_MASK_2CLICK; |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2946 else if (orig_num_clicks == 3) |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2947 *modifiers |= MOD_MASK_3CLICK; |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2948 else if (orig_num_clicks == 4) |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2949 *modifiers |= MOD_MASK_4CLICK; |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2950 |
21271
51ff7e5abdda
patch 8.2.1186: with SGR mouse codes balloon doesn't show up after click
Bram Moolenaar <Bram@vim.org>
parents:
21114
diff
changeset
|
2951 // Work out our pseudo mouse event. Note that MOUSE_RELEASE gets added, |
51ff7e5abdda
patch 8.2.1186: with SGR mouse codes balloon doesn't show up after click
Bram Moolenaar <Bram@vim.org>
parents:
21114
diff
changeset
|
2952 // then it's not mouse up/down. |
18150
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2953 key_name[0] = KS_EXTRA; |
21114
d0265fdadec9
patch 8.2.1108: mouse left-right scroll is not supported in terminal window
Bram Moolenaar <Bram@vim.org>
parents:
19526
diff
changeset
|
2954 if (wheel_code != 0 && (!is_release || release_is_ambiguous)) |
18150
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2955 { |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2956 if (wheel_code & MOUSE_CTRL) |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2957 *modifiers |= MOD_MASK_CTRL; |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2958 if (wheel_code & MOUSE_ALT) |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2959 *modifiers |= MOD_MASK_ALT; |
21114
d0265fdadec9
patch 8.2.1108: mouse left-right scroll is not supported in terminal window
Bram Moolenaar <Bram@vim.org>
parents:
19526
diff
changeset
|
2960 |
d0265fdadec9
patch 8.2.1108: mouse left-right scroll is not supported in terminal window
Bram Moolenaar <Bram@vim.org>
parents:
19526
diff
changeset
|
2961 if (wheel_code & 1 && wheel_code & 2) |
d0265fdadec9
patch 8.2.1108: mouse left-right scroll is not supported in terminal window
Bram Moolenaar <Bram@vim.org>
parents:
19526
diff
changeset
|
2962 key_name[1] = (int)KE_MOUSELEFT; |
d0265fdadec9
patch 8.2.1108: mouse left-right scroll is not supported in terminal window
Bram Moolenaar <Bram@vim.org>
parents:
19526
diff
changeset
|
2963 else if (wheel_code & 2) |
d0265fdadec9
patch 8.2.1108: mouse left-right scroll is not supported in terminal window
Bram Moolenaar <Bram@vim.org>
parents:
19526
diff
changeset
|
2964 key_name[1] = (int)KE_MOUSERIGHT; |
d0265fdadec9
patch 8.2.1108: mouse left-right scroll is not supported in terminal window
Bram Moolenaar <Bram@vim.org>
parents:
19526
diff
changeset
|
2965 else if (wheel_code & 1) |
d0265fdadec9
patch 8.2.1108: mouse left-right scroll is not supported in terminal window
Bram Moolenaar <Bram@vim.org>
parents:
19526
diff
changeset
|
2966 key_name[1] = (int)KE_MOUSEUP; |
d0265fdadec9
patch 8.2.1108: mouse left-right scroll is not supported in terminal window
Bram Moolenaar <Bram@vim.org>
parents:
19526
diff
changeset
|
2967 else |
d0265fdadec9
patch 8.2.1108: mouse left-right scroll is not supported in terminal window
Bram Moolenaar <Bram@vim.org>
parents:
19526
diff
changeset
|
2968 key_name[1] = (int)KE_MOUSEDOWN; |
d0265fdadec9
patch 8.2.1108: mouse left-right scroll is not supported in terminal window
Bram Moolenaar <Bram@vim.org>
parents:
19526
diff
changeset
|
2969 |
18150
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2970 held_button = MOUSE_RELEASE; |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2971 } |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2972 else |
21271
51ff7e5abdda
patch 8.2.1186: with SGR mouse codes balloon doesn't show up after click
Bram Moolenaar <Bram@vim.org>
parents:
21114
diff
changeset
|
2973 key_name[1] = get_pseudo_mouse_code(current_button, is_click, is_drag); |
51ff7e5abdda
patch 8.2.1186: with SGR mouse codes balloon doesn't show up after click
Bram Moolenaar <Bram@vim.org>
parents:
21114
diff
changeset
|
2974 |
18150
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2975 |
21271
51ff7e5abdda
patch 8.2.1186: with SGR mouse codes balloon doesn't show up after click
Bram Moolenaar <Bram@vim.org>
parents:
21114
diff
changeset
|
2976 // Make sure the mouse position is valid. Some terminals may return weird |
51ff7e5abdda
patch 8.2.1186: with SGR mouse codes balloon doesn't show up after click
Bram Moolenaar <Bram@vim.org>
parents:
21114
diff
changeset
|
2977 // values. |
18150
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2978 if (mouse_col >= Columns) |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2979 mouse_col = Columns - 1; |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2980 if (mouse_row >= Rows) |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2981 mouse_row = Rows - 1; |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2982 |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2983 return 0; |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18141
diff
changeset
|
2984 } |
18135
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2985 |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2986 // Functions also used for popup windows. |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2987 |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2988 /* |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2989 * Compute the buffer line position from the screen position "rowp" / "colp" in |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2990 * window "win". |
21339
608f674c6035
patch 8.2.1220: memory access error when dragging a popup window
Bram Moolenaar <Bram@vim.org>
parents:
21271
diff
changeset
|
2991 * "plines_cache" can be NULL (no cache) or an array with "Rows" entries that |
608f674c6035
patch 8.2.1220: memory access error when dragging a popup window
Bram Moolenaar <Bram@vim.org>
parents:
21271
diff
changeset
|
2992 * caches the plines_win() result from a previous call. Entry is zero if not |
608f674c6035
patch 8.2.1220: memory access error when dragging a popup window
Bram Moolenaar <Bram@vim.org>
parents:
21271
diff
changeset
|
2993 * computed yet. There must be no text or setting changes since the entry is |
608f674c6035
patch 8.2.1220: memory access error when dragging a popup window
Bram Moolenaar <Bram@vim.org>
parents:
21271
diff
changeset
|
2994 * put in the cache. |
18135
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2995 * Returns TRUE if the position is below the last line. |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2996 */ |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2997 int |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2998 mouse_comp_pos( |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2999 win_T *win, |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3000 int *rowp, |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3001 int *colp, |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3002 linenr_T *lnump, |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3003 int *plines_cache) |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3004 { |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3005 int col = *colp; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3006 int row = *rowp; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3007 linenr_T lnum; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3008 int retval = FALSE; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3009 int off; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3010 int count; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3011 |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3012 #ifdef FEAT_RIGHTLEFT |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3013 if (win->w_p_rl) |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3014 col = win->w_width - 1 - col; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3015 #endif |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3016 |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3017 lnum = win->w_topline; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3018 |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3019 while (row > 0) |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3020 { |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3021 int cache_idx = lnum - win->w_topline; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3022 |
21339
608f674c6035
patch 8.2.1220: memory access error when dragging a popup window
Bram Moolenaar <Bram@vim.org>
parents:
21271
diff
changeset
|
3023 // Only "Rows" lines are cached, with folding we'll run out of entries |
608f674c6035
patch 8.2.1220: memory access error when dragging a popup window
Bram Moolenaar <Bram@vim.org>
parents:
21271
diff
changeset
|
3024 // and use the slow way. |
608f674c6035
patch 8.2.1220: memory access error when dragging a popup window
Bram Moolenaar <Bram@vim.org>
parents:
21271
diff
changeset
|
3025 if (plines_cache != NULL && cache_idx < Rows |
608f674c6035
patch 8.2.1220: memory access error when dragging a popup window
Bram Moolenaar <Bram@vim.org>
parents:
21271
diff
changeset
|
3026 && plines_cache[cache_idx] > 0) |
18135
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3027 count = plines_cache[cache_idx]; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3028 else |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3029 { |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3030 #ifdef FEAT_DIFF |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3031 // Don't include filler lines in "count" |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3032 if (win->w_p_diff |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3033 # ifdef FEAT_FOLDING |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3034 && !hasFoldingWin(win, lnum, NULL, NULL, TRUE, NULL) |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3035 # endif |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3036 ) |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3037 { |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3038 if (lnum == win->w_topline) |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3039 row -= win->w_topfill; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3040 else |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3041 row -= diff_check_fill(win, lnum); |
31154
7e48ddb8b079
patch 9.0.0911: with 'smoothscroll' set mouse click position may be wrong
Bram Moolenaar <Bram@vim.org>
parents:
31144
diff
changeset
|
3042 count = plines_win_nofill(win, lnum, FALSE); |
18135
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3043 } |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3044 else |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3045 #endif |
31154
7e48ddb8b079
patch 9.0.0911: with 'smoothscroll' set mouse click position may be wrong
Bram Moolenaar <Bram@vim.org>
parents:
31144
diff
changeset
|
3046 count = plines_win(win, lnum, FALSE); |
21339
608f674c6035
patch 8.2.1220: memory access error when dragging a popup window
Bram Moolenaar <Bram@vim.org>
parents:
21271
diff
changeset
|
3047 if (plines_cache != NULL && cache_idx < Rows) |
18135
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3048 plines_cache[cache_idx] = count; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3049 } |
31154
7e48ddb8b079
patch 9.0.0911: with 'smoothscroll' set mouse click position may be wrong
Bram Moolenaar <Bram@vim.org>
parents:
31144
diff
changeset
|
3050 |
7e48ddb8b079
patch 9.0.0911: with 'smoothscroll' set mouse click position may be wrong
Bram Moolenaar <Bram@vim.org>
parents:
31144
diff
changeset
|
3051 if (win->w_skipcol > 0 && lnum == win->w_topline) |
7e48ddb8b079
patch 9.0.0911: with 'smoothscroll' set mouse click position may be wrong
Bram Moolenaar <Bram@vim.org>
parents:
31144
diff
changeset
|
3052 { |
7e48ddb8b079
patch 9.0.0911: with 'smoothscroll' set mouse click position may be wrong
Bram Moolenaar <Bram@vim.org>
parents:
31144
diff
changeset
|
3053 // Adjust for 'smoothscroll' clipping the top screen lines. |
7e48ddb8b079
patch 9.0.0911: with 'smoothscroll' set mouse click position may be wrong
Bram Moolenaar <Bram@vim.org>
parents:
31144
diff
changeset
|
3054 // A similar formula is used in curs_columns(). |
7e48ddb8b079
patch 9.0.0911: with 'smoothscroll' set mouse click position may be wrong
Bram Moolenaar <Bram@vim.org>
parents:
31144
diff
changeset
|
3055 int width1 = win->w_width - win_col_off(win); |
7e48ddb8b079
patch 9.0.0911: with 'smoothscroll' set mouse click position may be wrong
Bram Moolenaar <Bram@vim.org>
parents:
31144
diff
changeset
|
3056 int skip_lines = 0; |
7e48ddb8b079
patch 9.0.0911: with 'smoothscroll' set mouse click position may be wrong
Bram Moolenaar <Bram@vim.org>
parents:
31144
diff
changeset
|
3057 if (win->w_skipcol > width1) |
7e48ddb8b079
patch 9.0.0911: with 'smoothscroll' set mouse click position may be wrong
Bram Moolenaar <Bram@vim.org>
parents:
31144
diff
changeset
|
3058 skip_lines = (win->w_skipcol - width1) |
7e48ddb8b079
patch 9.0.0911: with 'smoothscroll' set mouse click position may be wrong
Bram Moolenaar <Bram@vim.org>
parents:
31144
diff
changeset
|
3059 / (width1 + win_col_off2(win)) + 1; |
7e48ddb8b079
patch 9.0.0911: with 'smoothscroll' set mouse click position may be wrong
Bram Moolenaar <Bram@vim.org>
parents:
31144
diff
changeset
|
3060 else if (win->w_skipcol > 0) |
7e48ddb8b079
patch 9.0.0911: with 'smoothscroll' set mouse click position may be wrong
Bram Moolenaar <Bram@vim.org>
parents:
31144
diff
changeset
|
3061 skip_lines = 1; |
7e48ddb8b079
patch 9.0.0911: with 'smoothscroll' set mouse click position may be wrong
Bram Moolenaar <Bram@vim.org>
parents:
31144
diff
changeset
|
3062 count -= skip_lines; |
7e48ddb8b079
patch 9.0.0911: with 'smoothscroll' set mouse click position may be wrong
Bram Moolenaar <Bram@vim.org>
parents:
31144
diff
changeset
|
3063 } |
7e48ddb8b079
patch 9.0.0911: with 'smoothscroll' set mouse click position may be wrong
Bram Moolenaar <Bram@vim.org>
parents:
31144
diff
changeset
|
3064 |
18135
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3065 if (count > row) |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3066 break; // Position is in this buffer line. |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3067 #ifdef FEAT_FOLDING |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3068 (void)hasFoldingWin(win, lnum, NULL, &lnum, TRUE, NULL); |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3069 #endif |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3070 if (lnum == win->w_buffer->b_ml.ml_line_count) |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3071 { |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3072 retval = TRUE; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3073 break; // past end of file |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3074 } |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3075 row -= count; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3076 ++lnum; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3077 } |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3078 |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3079 if (!retval) |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3080 { |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3081 // Compute the column without wrapping. |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3082 off = win_col_off(win) - win_col_off2(win); |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3083 if (col < off) |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3084 col = off; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3085 col += row * (win->w_width - off); |
31154
7e48ddb8b079
patch 9.0.0911: with 'smoothscroll' set mouse click position may be wrong
Bram Moolenaar <Bram@vim.org>
parents:
31144
diff
changeset
|
3086 |
7e48ddb8b079
patch 9.0.0911: with 'smoothscroll' set mouse click position may be wrong
Bram Moolenaar <Bram@vim.org>
parents:
31144
diff
changeset
|
3087 // Add skip column for the topline. |
7e48ddb8b079
patch 9.0.0911: with 'smoothscroll' set mouse click position may be wrong
Bram Moolenaar <Bram@vim.org>
parents:
31144
diff
changeset
|
3088 if (lnum == win->w_topline) |
7e48ddb8b079
patch 9.0.0911: with 'smoothscroll' set mouse click position may be wrong
Bram Moolenaar <Bram@vim.org>
parents:
31144
diff
changeset
|
3089 col += win->w_skipcol; |
18135
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3090 } |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3091 |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3092 if (!win->w_p_wrap) |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3093 col += win->w_leftcol; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3094 |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3095 // skip line number and fold column in front of the line |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3096 col -= win_col_off(win); |
22788
c8a4ad051d23
patch 8.2.1942: insufficient test coverage for the Netbeans interface
Bram Moolenaar <Bram@vim.org>
parents:
22176
diff
changeset
|
3097 if (col <= 0) |
18135
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3098 { |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3099 #ifdef FEAT_NETBEANS_INTG |
22788
c8a4ad051d23
patch 8.2.1942: insufficient test coverage for the Netbeans interface
Bram Moolenaar <Bram@vim.org>
parents:
22176
diff
changeset
|
3100 // if mouse is clicked on the gutter, then inform the netbeans server |
c8a4ad051d23
patch 8.2.1942: insufficient test coverage for the Netbeans interface
Bram Moolenaar <Bram@vim.org>
parents:
22176
diff
changeset
|
3101 if (*colp < win_col_off(win)) |
c8a4ad051d23
patch 8.2.1942: insufficient test coverage for the Netbeans interface
Bram Moolenaar <Bram@vim.org>
parents:
22176
diff
changeset
|
3102 netbeans_gutter_click(lnum); |
18135
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3103 #endif |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3104 col = 0; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3105 } |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3106 |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3107 *colp = col; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3108 *rowp = row; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3109 *lnump = lnum; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3110 return retval; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3111 } |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3112 |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3113 /* |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3114 * Find the window at screen position "*rowp" and "*colp". The positions are |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3115 * updated to become relative to the top-left of the window. |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3116 * When "popup" is FAIL_POPUP and the position is in a popup window then NULL |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3117 * is returned. When "popup" is IGNORE_POPUP then do not even check popup |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3118 * windows. |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3119 * Returns NULL when something is wrong. |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3120 */ |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3121 win_T * |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3122 mouse_find_win(int *rowp, int *colp, mouse_find_T popup UNUSED) |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3123 { |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3124 frame_T *fp; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3125 win_T *wp; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3126 |
18763
49b78d6465e5
patch 8.1.2371: FEAT_TEXT_PROP is a confusing name
Bram Moolenaar <Bram@vim.org>
parents:
18691
diff
changeset
|
3127 #ifdef FEAT_PROP_POPUP |
18135
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3128 win_T *pwp = NULL; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3129 |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3130 if (popup != IGNORE_POPUP) |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3131 { |
18613
fa995154904e
patch 8.1.2300: redraw breaks going through list of popup windows
Bram Moolenaar <Bram@vim.org>
parents:
18508
diff
changeset
|
3132 popup_reset_handled(POPUP_HANDLED_1); |
fa995154904e
patch 8.1.2300: redraw breaks going through list of popup windows
Bram Moolenaar <Bram@vim.org>
parents:
18508
diff
changeset
|
3133 while ((wp = find_next_popup(TRUE, POPUP_HANDLED_1)) != NULL) |
18135
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3134 { |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3135 if (*rowp >= wp->w_winrow && *rowp < wp->w_winrow + popup_height(wp) |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3136 && *colp >= wp->w_wincol |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3137 && *colp < wp->w_wincol + popup_width(wp)) |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3138 pwp = wp; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3139 } |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3140 if (pwp != NULL) |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3141 { |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3142 if (popup == FAIL_POPUP) |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3143 return NULL; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3144 *rowp -= pwp->w_winrow; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3145 *colp -= pwp->w_wincol; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3146 return pwp; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3147 } |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3148 } |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3149 #endif |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3150 |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3151 fp = topframe; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3152 *rowp -= firstwin->w_winrow; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3153 for (;;) |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3154 { |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3155 if (fp->fr_layout == FR_LEAF) |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3156 break; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3157 if (fp->fr_layout == FR_ROW) |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3158 { |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3159 for (fp = fp->fr_child; fp->fr_next != NULL; fp = fp->fr_next) |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3160 { |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3161 if (*colp < fp->fr_width) |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3162 break; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3163 *colp -= fp->fr_width; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3164 } |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3165 } |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3166 else // fr_layout == FR_COL |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3167 { |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3168 for (fp = fp->fr_child; fp->fr_next != NULL; fp = fp->fr_next) |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3169 { |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3170 if (*rowp < fp->fr_height) |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3171 break; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3172 *rowp -= fp->fr_height; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3173 } |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3174 } |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3175 } |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3176 // When using a timer that closes a window the window might not actually |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3177 // exist. |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3178 FOR_ALL_WINDOWS(wp) |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3179 if (wp == fp->fr_win) |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3180 { |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3181 #ifdef FEAT_MENU |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3182 *rowp -= wp->w_winbar_height; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3183 #endif |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3184 return wp; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3185 } |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3186 return NULL; |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3187 } |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3188 |
18763
49b78d6465e5
patch 8.1.2371: FEAT_TEXT_PROP is a confusing name
Bram Moolenaar <Bram@vim.org>
parents:
18691
diff
changeset
|
3189 #if defined(NEED_VCOL2COL) || defined(FEAT_BEVAL) || defined(FEAT_PROP_POPUP) \ |
28073
f4115d080c1b
patch 8.2.4561: build failure with some combination of features
Bram Moolenaar <Bram@vim.org>
parents:
28069
diff
changeset
|
3190 || defined(FEAT_EVAL) || defined(PROTO) |
18135
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3191 /* |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3192 * Convert a virtual (screen) column to a character column. |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3193 * The first column is one. |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3194 */ |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3195 int |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3196 vcol2col(win_T *wp, linenr_T lnum, int vcol) |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3197 { |
29451
057c26b5c33a
patch 9.0.0067: cannot show virtual text
Bram Moolenaar <Bram@vim.org>
parents:
29413
diff
changeset
|
3198 char_u *line; |
057c26b5c33a
patch 9.0.0067: cannot show virtual text
Bram Moolenaar <Bram@vim.org>
parents:
29413
diff
changeset
|
3199 chartabsize_T cts; |
18135
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3200 |
29451
057c26b5c33a
patch 9.0.0067: cannot show virtual text
Bram Moolenaar <Bram@vim.org>
parents:
29413
diff
changeset
|
3201 // try to advance to the specified column |
057c26b5c33a
patch 9.0.0067: cannot show virtual text
Bram Moolenaar <Bram@vim.org>
parents:
29413
diff
changeset
|
3202 line = ml_get_buf(wp->w_buffer, lnum, FALSE); |
057c26b5c33a
patch 9.0.0067: cannot show virtual text
Bram Moolenaar <Bram@vim.org>
parents:
29413
diff
changeset
|
3203 init_chartabsize_arg(&cts, wp, lnum, 0, line, line); |
057c26b5c33a
patch 9.0.0067: cannot show virtual text
Bram Moolenaar <Bram@vim.org>
parents:
29413
diff
changeset
|
3204 while (cts.cts_vcol < vcol && *cts.cts_ptr != NUL) |
18135
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3205 { |
29451
057c26b5c33a
patch 9.0.0067: cannot show virtual text
Bram Moolenaar <Bram@vim.org>
parents:
29413
diff
changeset
|
3206 cts.cts_vcol += win_lbr_chartabsize(&cts, NULL); |
057c26b5c33a
patch 9.0.0067: cannot show virtual text
Bram Moolenaar <Bram@vim.org>
parents:
29413
diff
changeset
|
3207 MB_PTR_ADV(cts.cts_ptr); |
18135
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3208 } |
29451
057c26b5c33a
patch 9.0.0067: cannot show virtual text
Bram Moolenaar <Bram@vim.org>
parents:
29413
diff
changeset
|
3209 clear_chartabsize_arg(&cts); |
057c26b5c33a
patch 9.0.0067: cannot show virtual text
Bram Moolenaar <Bram@vim.org>
parents:
29413
diff
changeset
|
3210 |
057c26b5c33a
patch 9.0.0067: cannot show virtual text
Bram Moolenaar <Bram@vim.org>
parents:
29413
diff
changeset
|
3211 return (int)(cts.cts_ptr - line); |
18135
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3212 } |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3213 #endif |
18623
3089b422b9dc
patch 8.1.2304: cannot get the mouse position when getting a mouse click
Bram Moolenaar <Bram@vim.org>
parents:
18613
diff
changeset
|
3214 |
3089b422b9dc
patch 8.1.2304: cannot get the mouse position when getting a mouse click
Bram Moolenaar <Bram@vim.org>
parents:
18613
diff
changeset
|
3215 #if defined(FEAT_EVAL) || defined(PROTO) |
31135
759b181807f7
patch 9.0.0902: some mouse scroll code is not in a good place
Bram Moolenaar <Bram@vim.org>
parents:
31133
diff
changeset
|
3216 /* |
759b181807f7
patch 9.0.0902: some mouse scroll code is not in a good place
Bram Moolenaar <Bram@vim.org>
parents:
31133
diff
changeset
|
3217 * "getmousepos()" function. |
759b181807f7
patch 9.0.0902: some mouse scroll code is not in a good place
Bram Moolenaar <Bram@vim.org>
parents:
31133
diff
changeset
|
3218 */ |
18623
3089b422b9dc
patch 8.1.2304: cannot get the mouse position when getting a mouse click
Bram Moolenaar <Bram@vim.org>
parents:
18613
diff
changeset
|
3219 void |
3089b422b9dc
patch 8.1.2304: cannot get the mouse position when getting a mouse click
Bram Moolenaar <Bram@vim.org>
parents:
18613
diff
changeset
|
3220 f_getmousepos(typval_T *argvars UNUSED, typval_T *rettv) |
3089b422b9dc
patch 8.1.2304: cannot get the mouse position when getting a mouse click
Bram Moolenaar <Bram@vim.org>
parents:
18613
diff
changeset
|
3221 { |
3089b422b9dc
patch 8.1.2304: cannot get the mouse position when getting a mouse click
Bram Moolenaar <Bram@vim.org>
parents:
18613
diff
changeset
|
3222 dict_T *d; |
3089b422b9dc
patch 8.1.2304: cannot get the mouse position when getting a mouse click
Bram Moolenaar <Bram@vim.org>
parents:
18613
diff
changeset
|
3223 win_T *wp; |
3089b422b9dc
patch 8.1.2304: cannot get the mouse position when getting a mouse click
Bram Moolenaar <Bram@vim.org>
parents:
18613
diff
changeset
|
3224 int row = mouse_row; |
3089b422b9dc
patch 8.1.2304: cannot get the mouse position when getting a mouse click
Bram Moolenaar <Bram@vim.org>
parents:
18613
diff
changeset
|
3225 int col = mouse_col; |
3089b422b9dc
patch 8.1.2304: cannot get the mouse position when getting a mouse click
Bram Moolenaar <Bram@vim.org>
parents:
18613
diff
changeset
|
3226 varnumber_T winid = 0; |
3089b422b9dc
patch 8.1.2304: cannot get the mouse position when getting a mouse click
Bram Moolenaar <Bram@vim.org>
parents:
18613
diff
changeset
|
3227 varnumber_T winrow = 0; |
3089b422b9dc
patch 8.1.2304: cannot get the mouse position when getting a mouse click
Bram Moolenaar <Bram@vim.org>
parents:
18613
diff
changeset
|
3228 varnumber_T wincol = 0; |
28069
236b80af9833
patch 8.2.4559: getmousepos() returns the screen column
Bram Moolenaar <Bram@vim.org>
parents:
28061
diff
changeset
|
3229 linenr_T lnum = 0; |
18623
3089b422b9dc
patch 8.1.2304: cannot get the mouse position when getting a mouse click
Bram Moolenaar <Bram@vim.org>
parents:
18613
diff
changeset
|
3230 varnumber_T column = 0; |
3089b422b9dc
patch 8.1.2304: cannot get the mouse position when getting a mouse click
Bram Moolenaar <Bram@vim.org>
parents:
18613
diff
changeset
|
3231 |
29175
755ab148288b
patch 8.2.5107: some callers of rettv_list_alloc() check for not OK
Bram Moolenaar <Bram@vim.org>
parents:
28942
diff
changeset
|
3232 if (rettv_dict_alloc(rettv) == FAIL) |
18623
3089b422b9dc
patch 8.1.2304: cannot get the mouse position when getting a mouse click
Bram Moolenaar <Bram@vim.org>
parents:
18613
diff
changeset
|
3233 return; |
3089b422b9dc
patch 8.1.2304: cannot get the mouse position when getting a mouse click
Bram Moolenaar <Bram@vim.org>
parents:
18613
diff
changeset
|
3234 d = rettv->vval.v_dict; |
3089b422b9dc
patch 8.1.2304: cannot get the mouse position when getting a mouse click
Bram Moolenaar <Bram@vim.org>
parents:
18613
diff
changeset
|
3235 |
3089b422b9dc
patch 8.1.2304: cannot get the mouse position when getting a mouse click
Bram Moolenaar <Bram@vim.org>
parents:
18613
diff
changeset
|
3236 dict_add_number(d, "screenrow", (varnumber_T)mouse_row + 1); |
3089b422b9dc
patch 8.1.2304: cannot get the mouse position when getting a mouse click
Bram Moolenaar <Bram@vim.org>
parents:
18613
diff
changeset
|
3237 dict_add_number(d, "screencol", (varnumber_T)mouse_col + 1); |
3089b422b9dc
patch 8.1.2304: cannot get the mouse position when getting a mouse click
Bram Moolenaar <Bram@vim.org>
parents:
18613
diff
changeset
|
3238 |
3089b422b9dc
patch 8.1.2304: cannot get the mouse position when getting a mouse click
Bram Moolenaar <Bram@vim.org>
parents:
18613
diff
changeset
|
3239 wp = mouse_find_win(&row, &col, FIND_POPUP); |
3089b422b9dc
patch 8.1.2304: cannot get the mouse position when getting a mouse click
Bram Moolenaar <Bram@vim.org>
parents:
18613
diff
changeset
|
3240 if (wp != NULL) |
3089b422b9dc
patch 8.1.2304: cannot get the mouse position when getting a mouse click
Bram Moolenaar <Bram@vim.org>
parents:
18613
diff
changeset
|
3241 { |
3089b422b9dc
patch 8.1.2304: cannot get the mouse position when getting a mouse click
Bram Moolenaar <Bram@vim.org>
parents:
18613
diff
changeset
|
3242 int top_off = 0; |
3089b422b9dc
patch 8.1.2304: cannot get the mouse position when getting a mouse click
Bram Moolenaar <Bram@vim.org>
parents:
18613
diff
changeset
|
3243 int left_off = 0; |
3089b422b9dc
patch 8.1.2304: cannot get the mouse position when getting a mouse click
Bram Moolenaar <Bram@vim.org>
parents:
18613
diff
changeset
|
3244 int height = wp->w_height + wp->w_status_height; |
3089b422b9dc
patch 8.1.2304: cannot get the mouse position when getting a mouse click
Bram Moolenaar <Bram@vim.org>
parents:
18613
diff
changeset
|
3245 |
31135
759b181807f7
patch 9.0.0902: some mouse scroll code is not in a good place
Bram Moolenaar <Bram@vim.org>
parents:
31133
diff
changeset
|
3246 # ifdef FEAT_PROP_POPUP |
18623
3089b422b9dc
patch 8.1.2304: cannot get the mouse position when getting a mouse click
Bram Moolenaar <Bram@vim.org>
parents:
18613
diff
changeset
|
3247 if (WIN_IS_POPUP(wp)) |
3089b422b9dc
patch 8.1.2304: cannot get the mouse position when getting a mouse click
Bram Moolenaar <Bram@vim.org>
parents:
18613
diff
changeset
|
3248 { |
3089b422b9dc
patch 8.1.2304: cannot get the mouse position when getting a mouse click
Bram Moolenaar <Bram@vim.org>
parents:
18613
diff
changeset
|
3249 top_off = popup_top_extra(wp); |
3089b422b9dc
patch 8.1.2304: cannot get the mouse position when getting a mouse click
Bram Moolenaar <Bram@vim.org>
parents:
18613
diff
changeset
|
3250 left_off = popup_left_extra(wp); |
3089b422b9dc
patch 8.1.2304: cannot get the mouse position when getting a mouse click
Bram Moolenaar <Bram@vim.org>
parents:
18613
diff
changeset
|
3251 height = popup_height(wp); |
3089b422b9dc
patch 8.1.2304: cannot get the mouse position when getting a mouse click
Bram Moolenaar <Bram@vim.org>
parents:
18613
diff
changeset
|
3252 } |
31135
759b181807f7
patch 9.0.0902: some mouse scroll code is not in a good place
Bram Moolenaar <Bram@vim.org>
parents:
31133
diff
changeset
|
3253 # endif |
18623
3089b422b9dc
patch 8.1.2304: cannot get the mouse position when getting a mouse click
Bram Moolenaar <Bram@vim.org>
parents:
18613
diff
changeset
|
3254 if (row < height) |
3089b422b9dc
patch 8.1.2304: cannot get the mouse position when getting a mouse click
Bram Moolenaar <Bram@vim.org>
parents:
18613
diff
changeset
|
3255 { |
3089b422b9dc
patch 8.1.2304: cannot get the mouse position when getting a mouse click
Bram Moolenaar <Bram@vim.org>
parents:
18613
diff
changeset
|
3256 winid = wp->w_id; |
3089b422b9dc
patch 8.1.2304: cannot get the mouse position when getting a mouse click
Bram Moolenaar <Bram@vim.org>
parents:
18613
diff
changeset
|
3257 winrow = row + 1; |
3089b422b9dc
patch 8.1.2304: cannot get the mouse position when getting a mouse click
Bram Moolenaar <Bram@vim.org>
parents:
18613
diff
changeset
|
3258 wincol = col + 1; |
3089b422b9dc
patch 8.1.2304: cannot get the mouse position when getting a mouse click
Bram Moolenaar <Bram@vim.org>
parents:
18613
diff
changeset
|
3259 row -= top_off; |
3089b422b9dc
patch 8.1.2304: cannot get the mouse position when getting a mouse click
Bram Moolenaar <Bram@vim.org>
parents:
18613
diff
changeset
|
3260 col -= left_off; |
3089b422b9dc
patch 8.1.2304: cannot get the mouse position when getting a mouse click
Bram Moolenaar <Bram@vim.org>
parents:
18613
diff
changeset
|
3261 if (row >= 0 && row < wp->w_height && col >= 0 && col < wp->w_width) |
3089b422b9dc
patch 8.1.2304: cannot get the mouse position when getting a mouse click
Bram Moolenaar <Bram@vim.org>
parents:
18613
diff
changeset
|
3262 { |
28087
4c60e656e054
patch 8.2.4568: getmousepos() does not compute the column below the last line
Bram Moolenaar <Bram@vim.org>
parents:
28073
diff
changeset
|
3263 (void)mouse_comp_pos(wp, &row, &col, &lnum, NULL); |
4c60e656e054
patch 8.2.4568: getmousepos() does not compute the column below the last line
Bram Moolenaar <Bram@vim.org>
parents:
28073
diff
changeset
|
3264 col = vcol2col(wp, lnum, col); |
18623
3089b422b9dc
patch 8.1.2304: cannot get the mouse position when getting a mouse click
Bram Moolenaar <Bram@vim.org>
parents:
18613
diff
changeset
|
3265 column = col + 1; |
3089b422b9dc
patch 8.1.2304: cannot get the mouse position when getting a mouse click
Bram Moolenaar <Bram@vim.org>
parents:
18613
diff
changeset
|
3266 } |
3089b422b9dc
patch 8.1.2304: cannot get the mouse position when getting a mouse click
Bram Moolenaar <Bram@vim.org>
parents:
18613
diff
changeset
|
3267 } |
3089b422b9dc
patch 8.1.2304: cannot get the mouse position when getting a mouse click
Bram Moolenaar <Bram@vim.org>
parents:
18613
diff
changeset
|
3268 } |
3089b422b9dc
patch 8.1.2304: cannot get the mouse position when getting a mouse click
Bram Moolenaar <Bram@vim.org>
parents:
18613
diff
changeset
|
3269 dict_add_number(d, "winid", winid); |
3089b422b9dc
patch 8.1.2304: cannot get the mouse position when getting a mouse click
Bram Moolenaar <Bram@vim.org>
parents:
18613
diff
changeset
|
3270 dict_add_number(d, "winrow", winrow); |
3089b422b9dc
patch 8.1.2304: cannot get the mouse position when getting a mouse click
Bram Moolenaar <Bram@vim.org>
parents:
18613
diff
changeset
|
3271 dict_add_number(d, "wincol", wincol); |
28069
236b80af9833
patch 8.2.4559: getmousepos() returns the screen column
Bram Moolenaar <Bram@vim.org>
parents:
28061
diff
changeset
|
3272 dict_add_number(d, "line", (varnumber_T)lnum); |
18623
3089b422b9dc
patch 8.1.2304: cannot get the mouse position when getting a mouse click
Bram Moolenaar <Bram@vim.org>
parents:
18613
diff
changeset
|
3273 dict_add_number(d, "column", column); |
3089b422b9dc
patch 8.1.2304: cannot get the mouse position when getting a mouse click
Bram Moolenaar <Bram@vim.org>
parents:
18613
diff
changeset
|
3274 } |
3089b422b9dc
patch 8.1.2304: cannot get the mouse position when getting a mouse click
Bram Moolenaar <Bram@vim.org>
parents:
18613
diff
changeset
|
3275 #endif |