comparison src/mouse.c @ 18141:2cc67e54edf8 v8.1.2065

patch 8.1.2065: compiler warning building non-GUI with MinGW. Commit: https://github.com/vim/vim/commit/910c378d9342e0de8c6736c83ebdbbb597267056 Author: Bram Moolenaar <Bram@vim.org> Date: Sun Sep 22 14:11:50 2019 +0200 patch 8.1.2065: compiler warning building non-GUI with MinGW. Problem: Compiler warning building non-GUI with MinGW. Solution: Adjust #ifdefs. (Yegappan Lakshmanan, closes https://github.com/vim/vim/issues/4964)
author Bram Moolenaar <Bram@vim.org>
date Sun, 22 Sep 2019 14:15:04 +0200
parents 1868ec23360e
children 0ec6521e9d80
comparison
equal deleted inserted replaced
18140:697fc783e9ab 18141:2cc67e54edf8
12 */ 12 */
13 13
14 #include "vim.h" 14 #include "vim.h"
15 15
16 #if defined(FEAT_MOUSE) || defined(PROTO) 16 #if defined(FEAT_MOUSE) || defined(PROTO)
17
18 static int get_fpos_of_mouse(pos_T *mpos);
19 17
20 /* 18 /*
21 * Get class of a character for selection: same class means same word. 19 * Get class of a character for selection: same class means same word.
22 * 0: blank 20 * 0: blank
23 * 1: punctuation groups 21 * 1: punctuation groups
99 break; 97 break;
100 } 98 }
101 pos->col = col; 99 pos->col = col;
102 } 100 }
103 } 101 }
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
104 148
105 /* 149 /*
106 * Do the appropriate action for the current mouse click in the current mode. 150 * Do the appropriate action for the current mouse click in the current mode.
107 * Not used for Command-line mode. 151 * Not used for Command-line mode.
108 * 152 *
467 if (mouse_model_popup()) 511 if (mouse_model_popup())
468 { 512 {
469 if (which_button == MOUSE_RIGHT 513 if (which_button == MOUSE_RIGHT
470 && !(mod_mask & (MOD_MASK_SHIFT | MOD_MASK_CTRL))) 514 && !(mod_mask & (MOD_MASK_SHIFT | MOD_MASK_CTRL)))
471 { 515 {
472 #if defined(FEAT_GUI_MOTIF) || defined(FEAT_GUI_GTK) \ 516 #ifdef USE_POPUP_SETPOS
473 || defined(FEAT_GUI_ATHENA) || defined(FEAT_GUI_MSWIN) \
474 || defined(FEAT_GUI_MAC) || defined(FEAT_GUI_PHOTON) \
475 || defined(FEAT_TERM_POPUP_MENU)
476 # ifdef FEAT_GUI 517 # ifdef FEAT_GUI
477 if (gui.in_use) 518 if (gui.in_use)
478 { 519 {
479 # if defined(FEAT_GUI_MOTIF) || defined(FEAT_GUI_GTK) \ 520 # if defined(FEAT_GUI_MOTIF) || defined(FEAT_GUI_GTK) \
480 || defined(FEAT_GUI_PHOTON) || defined(FEAT_GUI_MAC) 521 || defined(FEAT_GUI_PHOTON) || defined(FEAT_GUI_MAC)
2230 return wp; 2271 return wp;
2231 } 2272 }
2232 return NULL; 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 #if defined(NEED_VCOL2COL) || defined(FEAT_BEVAL) || defined(FEAT_TEXT_PROP) \ 2276 #if defined(NEED_VCOL2COL) || defined(FEAT_BEVAL) || defined(FEAT_TEXT_PROP) \
2281 || defined(PROTO) 2277 || defined(PROTO)
2282 /* 2278 /*
2283 * Convert a virtual (screen) column to a character column. 2279 * Convert a virtual (screen) column to a character column.
2284 * The first column is one. 2280 * The first column is one.