|
15 | 15 |
|
16 | 16 | #if defined(FEAT_MOUSE) || defined(PROTO) |
17 | 17 |
|
18 | | -static int get_fpos_of_mouse(pos_T *mpos); |
19 | | - |
20 | 18 | /* |
21 | 19 | * Get class of a character for selection: same class means same word. |
22 | 20 | * 0: blank |
@@ -102,6 +100,52 @@ find_end_of_word(pos_T *pos) |
102 | 100 | } |
103 | 101 | } |
104 | 102 |
|
| 103 | +#if defined(FEAT_GUI_MOTIF) || defined(FEAT_GUI_GTK) \ |
| 104 | + || defined(FEAT_GUI_ATHENA) || defined(FEAT_GUI_MSWIN) \ |
| 105 | + || defined(FEAT_GUI_MAC) || defined(FEAT_GUI_PHOTON) \ |
| 106 | + || defined(FEAT_TERM_POPUP_MENU) |
| 107 | +# define USE_POPUP_SETPOS |
| 108 | +# define NEED_VCOL2COL |
| 109 | + |
| 110 | +/* |
| 111 | + * Translate window coordinates to buffer position without any side effects |
| 112 | + */ |
| 113 | + static int |
| 114 | +get_fpos_of_mouse(pos_T *mpos) |
| 115 | +{ |
| 116 | + win_T *wp; |
| 117 | + int row = mouse_row; |
| 118 | + int col = mouse_col; |
| 119 | + |
| 120 | + if (row < 0 || col < 0) // check if it makes sense |
| 121 | + return IN_UNKNOWN; |
| 122 | + |
| 123 | + // find the window where the row is in |
| 124 | + wp = mouse_find_win(&row, &col, FAIL_POPUP); |
| 125 | + if (wp == NULL) |
| 126 | + return IN_UNKNOWN; |
| 127 | + // winpos and height may change in win_enter()! |
| 128 | + if (row >= wp->w_height) // In (or below) status line |
| 129 | + return IN_STATUS_LINE; |
| 130 | + if (col >= wp->w_width) // In vertical separator line |
| 131 | + return IN_SEP_LINE; |
| 132 | + |
| 133 | + if (wp != curwin) |
| 134 | + return IN_UNKNOWN; |
| 135 | + |
| 136 | + // compute the position in the buffer line from the posn on the screen |
| 137 | + if (mouse_comp_pos(curwin, &row, &col, &mpos->lnum, NULL)) |
| 138 | + return IN_STATUS_LINE; // past bottom |
| 139 | + |
| 140 | + mpos->col = vcol2col(wp, mpos->lnum, col); |
| 141 | + |
| 142 | + if (mpos->col > 0) |
| 143 | + --mpos->col; |
| 144 | + mpos->coladd = 0; |
| 145 | + return IN_BUFFER; |
| 146 | +} |
| 147 | +#endif |
| 148 | + |
105 | 149 | /* |
106 | 150 | * Do the appropriate action for the current mouse click in the current mode. |
107 | 151 | * Not used for Command-line mode. |
@@ -469,10 +513,7 @@ do_mouse( |
469 | 513 | if (which_button == MOUSE_RIGHT |
470 | 514 | && !(mod_mask & (MOD_MASK_SHIFT | MOD_MASK_CTRL))) |
471 | 515 | { |
472 | | -#if defined(FEAT_GUI_MOTIF) || defined(FEAT_GUI_GTK) \ |
473 | | - || defined(FEAT_GUI_ATHENA) || defined(FEAT_GUI_MSWIN) \ |
474 | | - || defined(FEAT_GUI_MAC) || defined(FEAT_GUI_PHOTON) \ |
475 | | - || defined(FEAT_TERM_POPUP_MENU) |
| 516 | +#ifdef USE_POPUP_SETPOS |
476 | 517 | # ifdef FEAT_GUI |
477 | 518 | if (gui.in_use) |
478 | 519 | { |
@@ -2232,51 +2273,6 @@ mouse_find_win(int *rowp, int *colp, mouse_find_T popup UNUSED) |
2232 | 2273 | return NULL; |
2233 | 2274 | } |
2234 | 2275 |
|
2235 | | -#if defined(FEAT_GUI_MOTIF) || defined(FEAT_GUI_GTK) || defined(FEAT_GUI_MAC) \ |
2236 | | - || defined(FEAT_GUI_ATHENA) || defined(FEAT_GUI_MSWIN) \ |
2237 | | - || defined(FEAT_GUI_PHOTON) || defined(FEAT_TERM_POPUP_MENU) \ |
2238 | | - || defined(PROTO) |
2239 | | -# define NEED_VCOL2COL |
2240 | | - |
2241 | | -/* |
2242 | | - * Translate window coordinates to buffer position without any side effects |
2243 | | - */ |
2244 | | - static int |
2245 | | -get_fpos_of_mouse(pos_T *mpos) |
2246 | | -{ |
2247 | | - win_T *wp; |
2248 | | - int row = mouse_row; |
2249 | | - int col = mouse_col; |
2250 | | - |
2251 | | - if (row < 0 || col < 0) // check if it makes sense |
2252 | | - return IN_UNKNOWN; |
2253 | | - |
2254 | | - // find the window where the row is in |
2255 | | - wp = mouse_find_win(&row, &col, FAIL_POPUP); |
2256 | | - if (wp == NULL) |
2257 | | - return IN_UNKNOWN; |
2258 | | - // winpos and height may change in win_enter()! |
2259 | | - if (row >= wp->w_height) // In (or below) status line |
2260 | | - return IN_STATUS_LINE; |
2261 | | - if (col >= wp->w_width) // In vertical separator line |
2262 | | - return IN_SEP_LINE; |
2263 | | - |
2264 | | - if (wp != curwin) |
2265 | | - return IN_UNKNOWN; |
2266 | | - |
2267 | | - // compute the position in the buffer line from the posn on the screen |
2268 | | - if (mouse_comp_pos(curwin, &row, &col, &mpos->lnum, NULL)) |
2269 | | - return IN_STATUS_LINE; // past bottom |
2270 | | - |
2271 | | - mpos->col = vcol2col(wp, mpos->lnum, col); |
2272 | | - |
2273 | | - if (mpos->col > 0) |
2274 | | - --mpos->col; |
2275 | | - mpos->coladd = 0; |
2276 | | - return IN_BUFFER; |
2277 | | -} |
2278 | | -#endif |
2279 | | - |
2280 | 2276 | #if defined(NEED_VCOL2COL) || defined(FEAT_BEVAL) || defined(FEAT_TEXT_PROP) \ |
2281 | 2277 | || defined(PROTO) |
2282 | 2278 | /* |
|
0 commit comments