Mercurial > vim
comparison src/popupmnu.c @ 13234:6e972d830e13 v8.0.1491
patch 8.0.1491: the minimum width of the popup menu is hard coded
commit https://github.com/vim/vim/commit/a8f04aa275984183bab5bb583b128f38c64abb69
Author: Bram Moolenaar <Bram@vim.org>
Date: Sat Feb 10 15:36:55 2018 +0100
patch 8.0.1491: the minimum width of the popup menu is hard coded
Problem: The minimum width of the popup menu is hard coded.
Solution: Add the 'pumwidth' option. (Christian Brabandt, James McCoy,
closes #2314)
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Sat, 10 Feb 2018 15:45:06 +0100 |
parents | 5045d3076db0 |
children | 5b0faf628a55 |
comparison
equal
deleted
inserted
replaced
13233:eaa9d3821fb0 | 13234:6e972d830e13 |
---|---|
65 } | 65 } |
66 } | 66 } |
67 } | 67 } |
68 | 68 |
69 /* | 69 /* |
70 * Return the minimum width of the popup menu. | |
71 */ | |
72 static int | |
73 pum_get_width(void) | |
74 { | |
75 return p_pw == 0 ? PUM_DEF_WIDTH : p_pw; | |
76 } | |
77 | |
78 /* | |
70 * Show the popup menu with items "array[size]". | 79 * Show the popup menu with items "array[size]". |
71 * "array" must remain valid until pum_undisplay() is called! | 80 * "array" must remain valid until pum_undisplay() is called! |
72 * When possible the leftmost character is aligned with screen column "col". | 81 * When possible the leftmost character is aligned with screen column "col". |
73 * The menu appears above the screen line "row" or at "row" + "height" - 1. | 82 * The menu appears above the screen line "row" or at "row" + "height" - 1. |
74 */ | 83 */ |
91 win_T *pvwin; | 100 win_T *pvwin; |
92 #endif | 101 #endif |
93 | 102 |
94 do | 103 do |
95 { | 104 { |
96 def_width = PUM_DEF_WIDTH; | 105 def_width = pum_get_width(); |
97 above_row = 0; | 106 above_row = 0; |
98 below_row = cmdline_row; | 107 below_row = cmdline_row; |
99 | 108 |
100 /* Pretend the pum is already there to avoid that must_redraw is set | 109 /* Pretend the pum is already there to avoid that must_redraw is set |
101 * when 'cuc' is on. */ | 110 * when 'cuc' is on. */ |
214 pum_scrollbar = 0; | 223 pum_scrollbar = 0; |
215 | 224 |
216 if (def_width < max_width) | 225 if (def_width < max_width) |
217 def_width = max_width; | 226 def_width = max_width; |
218 | 227 |
219 if (((col < Columns - PUM_DEF_WIDTH || col < Columns - max_width) | 228 if (((col < Columns - pum_get_width() || col < Columns - max_width) |
220 #ifdef FEAT_RIGHTLEFT | 229 #ifdef FEAT_RIGHTLEFT |
221 && !curwin->w_p_rl) | 230 && !curwin->w_p_rl) |
222 || (curwin->w_p_rl && (col > PUM_DEF_WIDTH || col > max_width) | 231 || (curwin->w_p_rl && (col > pum_get_width() || col > max_width) |
223 #endif | 232 #endif |
224 )) | 233 )) |
225 { | 234 { |
226 /* align pum column with "col" */ | 235 /* align pum column with "col" */ |
227 pum_col = col; | 236 pum_col = col; |
228 | 237 |
238 /* start with the maximum space available */ | |
229 #ifdef FEAT_RIGHTLEFT | 239 #ifdef FEAT_RIGHTLEFT |
230 if (curwin->w_p_rl) | 240 if (curwin->w_p_rl) |
231 pum_width = pum_col - pum_scrollbar + 1; | 241 pum_width = pum_col - pum_scrollbar + 1; |
232 else | 242 else |
233 #endif | 243 #endif |
234 pum_width = Columns - pum_col - pum_scrollbar; | 244 pum_width = Columns - pum_col - pum_scrollbar; |
235 | 245 |
236 if (pum_width > max_width + pum_kind_width + pum_extra_width + 1 | 246 if (pum_width > max_width + pum_kind_width + pum_extra_width + 1 |
237 && pum_width > PUM_DEF_WIDTH) | 247 && pum_width > pum_get_width()) |
238 { | 248 { |
249 /* the width is too much, make it narrower */ | |
239 pum_width = max_width + pum_kind_width + pum_extra_width + 1; | 250 pum_width = max_width + pum_kind_width + pum_extra_width + 1; |
240 if (pum_width < PUM_DEF_WIDTH) | 251 if (pum_width < pum_get_width()) |
241 pum_width = PUM_DEF_WIDTH; | 252 pum_width = pum_get_width(); |
242 } | 253 } |
254 else if (((col > pum_get_width() || col > max_width) | |
255 #ifdef FEAT_RIGHTLEFT | |
256 && !curwin->w_p_rl) | |
257 || (curwin->w_p_rl && (col < Columns - pum_get_width() | |
258 || col < Columns - max_width) | |
259 #endif | |
260 )) | |
261 { | |
262 /* align right pum edge with "col" */ | |
263 #ifdef FEAT_RIGHTLEFT | |
264 if (curwin->w_p_rl) | |
265 { | |
266 pum_col = col + max_width + pum_scrollbar + 1; | |
267 if (pum_col >= Columns) | |
268 pum_col = Columns - 1; | |
269 } | |
270 else | |
271 #endif | |
272 { | |
273 pum_col = col - max_width - pum_scrollbar; | |
274 if (pum_col < 0) | |
275 pum_col = 0; | |
276 } | |
277 | |
278 #ifdef FEAT_RIGHTLEFT | |
279 if (curwin->w_p_rl) | |
280 pum_width = W_ENDCOL(curwin) - pum_col - pum_scrollbar + 1; | |
281 else | |
282 #endif | |
283 pum_width = pum_col - pum_scrollbar; | |
284 | |
285 if (pum_width < pum_get_width()) | |
286 { | |
287 pum_width = pum_get_width(); | |
288 #ifdef FEAT_RIGHTLEFT | |
289 if (curwin->w_p_rl) | |
290 { | |
291 if (pum_width > pum_col) | |
292 pum_width = pum_col; | |
293 } | |
294 else | |
295 #endif | |
296 { | |
297 if (pum_width >= Columns - pum_col) | |
298 pum_width = Columns - pum_col - 1; | |
299 } | |
300 } | |
301 else if (pum_width > max_width + pum_kind_width | |
302 + pum_extra_width + 1 | |
303 && pum_width > pum_get_width()) | |
304 { | |
305 pum_width = max_width + pum_kind_width | |
306 + pum_extra_width + 1; | |
307 if (pum_width < pum_get_width()) | |
308 pum_width = pum_get_width(); | |
309 } | |
310 } | |
311 | |
243 } | 312 } |
244 else if (Columns < def_width) | 313 else if (Columns < def_width) |
245 { | 314 { |
246 /* not enough room, will use what we have */ | 315 /* not enough room, will use what we have */ |
247 #ifdef FEAT_RIGHTLEFT | 316 #ifdef FEAT_RIGHTLEFT |
252 pum_col = 0; | 321 pum_col = 0; |
253 pum_width = Columns - 1; | 322 pum_width = Columns - 1; |
254 } | 323 } |
255 else | 324 else |
256 { | 325 { |
257 if (max_width > PUM_DEF_WIDTH) | 326 if (max_width > pum_get_width()) |
258 max_width = PUM_DEF_WIDTH; /* truncate */ | 327 max_width = pum_get_width(); /* truncate */ |
259 #ifdef FEAT_RIGHTLEFT | 328 #ifdef FEAT_RIGHTLEFT |
260 if (curwin->w_p_rl) | 329 if (curwin->w_p_rl) |
261 pum_col = max_width - 1; | 330 pum_col = max_width - 1; |
262 else | 331 else |
263 #endif | 332 #endif |
1003 { | 1072 { |
1004 if (mouse_row != balloon_mouse_row || mouse_col != balloon_mouse_col) | 1073 if (mouse_row != balloon_mouse_row || mouse_col != balloon_mouse_col) |
1005 ui_remove_balloon(); | 1074 ui_remove_balloon(); |
1006 } | 1075 } |
1007 # endif | 1076 # endif |
1008 #endif | 1077 |
1078 #endif |