blob: 4a67e241edbeeff39d637152def94b178afa8e1c [file] [log] [blame]
Bram Moolenaar4d784b22019-05-25 19:51:39 +02001/* vi:set ts=8 sts=4 sw=4 noet:
2 *
3 * VIM - Vi IMproved by Bram Moolenaar
4 *
5 * Do ":help uganda" in Vim to read a list of people who contributed.
6 * Do ":help credits" in Vim to see a list of people who contributed.
7 * See README.txt for an overview of the Vim source code.
8 */
9
10/*
11 * Implementation of popup windows. See ":help popup".
12 */
13
14#include "vim.h"
15
16#ifdef FEAT_TEXT_PROP
17
Bram Moolenaarac1f1bc2019-05-30 21:24:26 +020018typedef struct {
19 char *pp_name;
20 poppos_T pp_val;
21} poppos_entry_T;
22
23static poppos_entry_T poppos_entries[] = {
24 {"botleft", POPPOS_BOTLEFT},
25 {"topleft", POPPOS_TOPLEFT},
26 {"botright", POPPOS_BOTRIGHT},
27 {"topright", POPPOS_TOPRIGHT},
28 {"center", POPPOS_CENTER}
29};
30
Bram Moolenaar4d784b22019-05-25 19:51:39 +020031/*
Bram Moolenaarcc31ad92019-05-30 19:25:06 +020032 * Get option value for"key", which is "line" or "col".
33 * Handles "cursor+N" and "cursor-N".
34 */
35 static int
Bram Moolenaarac1f1bc2019-05-30 21:24:26 +020036popup_options_one(dict_T *dict, char_u *key)
Bram Moolenaarcc31ad92019-05-30 19:25:06 +020037{
38 dictitem_T *di;
39 char_u *val;
40 char_u *s;
41 char_u *endp;
42 int n = 0;
43
44 di = dict_find(dict, key, -1);
45 if (di == NULL)
46 return 0;
47
48 val = tv_get_string(&di->di_tv);
49 if (STRNCMP(val, "cursor", 6) != 0)
50 return dict_get_number(dict, key);
51
52 setcursor_mayforce(TRUE);
53 s = val + 6;
54 if (*s != NUL)
55 {
56 n = strtol((char *)s, (char **)&endp, 10);
57 if (endp != NULL && *skipwhite(endp) != NUL)
58 {
59 semsg(_(e_invexpr2), val);
60 return 0;
61 }
62 }
63
64 if (STRCMP(key, "line") == 0)
65 n = screen_screenrow() + 1 + n;
66 else // "col"
67 n = screen_screencol() + 1 + n;
68
69 if (n < 1)
70 n = 1;
71 return n;
72}
73
Bram Moolenaarac1f1bc2019-05-30 21:24:26 +020074 static void
75get_pos_options(win_T *wp, dict_T *dict)
76{
77 char_u *str;
78 int nr;
79
80 nr = popup_options_one(dict, (char_u *)"line");
81 if (nr > 0)
82 wp->w_wantline = nr;
83 nr = popup_options_one(dict, (char_u *)"col");
84 if (nr > 0)
85 wp->w_wantcol = nr;
86
Bram Moolenaar042fb4b2019-06-02 14:49:56 +020087 wp->w_popup_fixed = dict_get_number(dict, (char_u *)"fixed") != 0;
88
Bram Moolenaarac1f1bc2019-05-30 21:24:26 +020089 str = dict_get_string(dict, (char_u *)"pos", FALSE);
90 if (str != NULL)
91 {
92 for (nr = 0;
93 nr < (int)(sizeof(poppos_entries) / sizeof(poppos_entry_T));
94 ++nr)
95 if (STRCMP(str, poppos_entries[nr].pp_name) == 0)
96 {
97 wp->w_popup_pos = poppos_entries[nr].pp_val;
98 nr = -1;
99 break;
100 }
101 if (nr != -1)
102 semsg(_(e_invarg2), str);
103 }
104}
105
Bram Moolenaar2fd8e352019-06-01 20:16:48 +0200106 static void
107get_padding_border(dict_T *dict, int *array, char *name, int max_val)
108{
109 dictitem_T *di;
110
111 vim_memset(array, 0, sizeof(int) * 4);
112 di = dict_find(dict, (char_u *)name, -1);
113 if (di != NULL)
114 {
115 if (di->di_tv.v_type != VAR_LIST)
116 emsg(_(e_listreq));
117 else
118 {
119 list_T *list = di->di_tv.vval.v_list;
120 listitem_T *li;
121 int i;
122 int nr;
123
124 for (i = 0; i < 4; ++i)
125 array[i] = 1;
126 if (list != NULL)
127 for (i = 0, li = list->lv_first; i < 4 && i < list->lv_len;
128 ++i, li = li->li_next)
129 {
130 nr = (int)tv_get_number(&li->li_tv);
131 if (nr >= 0)
132 array[i] = nr > max_val ? max_val : nr;
133 }
134 }
135 }
136}
137
Bram Moolenaarcc31ad92019-05-30 19:25:06 +0200138/*
Bram Moolenaar4d784b22019-05-25 19:51:39 +0200139 * Go through the options in "dict" and apply them to buffer "buf" displayed in
140 * popup window "wp".
Bram Moolenaarcc31ad92019-05-30 19:25:06 +0200141 * When called from f_popup_atcursor() "atcursor" is TRUE.
Bram Moolenaar4d784b22019-05-25 19:51:39 +0200142 */
143 static void
Bram Moolenaarcc31ad92019-05-30 19:25:06 +0200144apply_options(win_T *wp, buf_T *buf UNUSED, dict_T *dict, int atcursor)
Bram Moolenaar4d784b22019-05-25 19:51:39 +0200145{
Bram Moolenaar402502d2019-05-30 22:07:36 +0200146 int nr;
147 char_u *str;
148 dictitem_T *di;
Bram Moolenaar790498b2019-06-01 22:15:29 +0200149 int i;
Bram Moolenaar51fe3b12019-05-26 20:10:06 +0200150
Bram Moolenaar60cdb302019-05-27 21:54:10 +0200151 wp->w_minwidth = dict_get_number(dict, (char_u *)"minwidth");
152 wp->w_minheight = dict_get_number(dict, (char_u *)"minheight");
Bram Moolenaar4d784b22019-05-25 19:51:39 +0200153 wp->w_maxwidth = dict_get_number(dict, (char_u *)"maxwidth");
154 wp->w_maxheight = dict_get_number(dict, (char_u *)"maxheight");
Bram Moolenaar60cdb302019-05-27 21:54:10 +0200155
Bram Moolenaarcc31ad92019-05-30 19:25:06 +0200156 if (atcursor)
157 {
Bram Moolenaarac1f1bc2019-05-30 21:24:26 +0200158 wp->w_popup_pos = POPPOS_BOTLEFT;
Bram Moolenaarcc31ad92019-05-30 19:25:06 +0200159 setcursor_mayforce(TRUE);
160 wp->w_wantline = screen_screenrow();
Bram Moolenaarac1f1bc2019-05-30 21:24:26 +0200161 if (wp->w_wantline == 0) // cursor in first line
162 {
163 wp->w_wantline = 2;
164 wp->w_popup_pos = POPPOS_TOPLEFT;
165 }
Bram Moolenaarcc31ad92019-05-30 19:25:06 +0200166 wp->w_wantcol = screen_screencol() + 1;
167 }
168
Bram Moolenaarac1f1bc2019-05-30 21:24:26 +0200169 get_pos_options(wp, dict);
Bram Moolenaar60cdb302019-05-27 21:54:10 +0200170
Bram Moolenaar4d784b22019-05-25 19:51:39 +0200171 wp->w_zindex = dict_get_number(dict, (char_u *)"zindex");
Bram Moolenaar51fe3b12019-05-26 20:10:06 +0200172
Bram Moolenaar35d5af62019-05-26 20:44:10 +0200173#if defined(FEAT_TIMERS)
Bram Moolenaar51fe3b12019-05-26 20:10:06 +0200174 // Add timer to close the popup after some time.
175 nr = dict_get_number(dict, (char_u *)"time");
176 if (nr > 0)
177 {
178 char_u cbbuf[50];
179 char_u *ptr = cbbuf;
180 typval_T tv;
181
182 vim_snprintf((char *)cbbuf, sizeof(cbbuf),
183 "{_ -> popup_close(%d)}", wp->w_id);
184 if (get_lambda_tv(&ptr, &tv, TRUE) == OK)
185 {
186 wp->w_popup_timer = create_timer(nr, 0);
Bram Moolenaarbf0eff02019-06-01 17:13:36 +0200187 wp->w_popup_timer->tr_callback = get_callback(&tv);
188 clear_tv(&tv);
Bram Moolenaar51fe3b12019-05-26 20:10:06 +0200189 }
190 }
Bram Moolenaar35d5af62019-05-26 20:44:10 +0200191#endif
Bram Moolenaar51fe3b12019-05-26 20:10:06 +0200192
Bram Moolenaar402502d2019-05-30 22:07:36 +0200193 // Option values resulting in setting an option.
Bram Moolenaarbf0eff02019-06-01 17:13:36 +0200194 str = dict_get_string(dict, (char_u *)"highlight", FALSE);
Bram Moolenaar20c023a2019-05-26 21:03:24 +0200195 if (str != NULL)
196 set_string_option_direct_in_win(wp, (char_u *)"wincolor", -1,
197 str, OPT_FREE|OPT_LOCAL, 0);
Bram Moolenaarbf0eff02019-06-01 17:13:36 +0200198
Bram Moolenaar402502d2019-05-30 22:07:36 +0200199 di = dict_find(dict, (char_u *)"wrap", -1);
200 if (di != NULL)
201 {
202 nr = dict_get_number(dict, (char_u *)"wrap");
203 wp->w_p_wrap = nr != 0;
204 }
Bram Moolenaarbf0eff02019-06-01 17:13:36 +0200205
Bram Moolenaar9eaac892019-06-01 22:49:29 +0200206 di = dict_find(dict, (char_u *)"callback", -1);
207 if (di != NULL)
208 {
209 callback_T callback = get_callback(&di->di_tv);
210
211 if (callback.cb_name != NULL)
212 set_callback(&wp->w_close_cb, &callback);
213 }
214
Bram Moolenaarbf0eff02019-06-01 17:13:36 +0200215 di = dict_find(dict, (char_u *)"filter", -1);
216 if (di != NULL)
217 {
218 callback_T callback = get_callback(&di->di_tv);
219
220 if (callback.cb_name != NULL)
221 set_callback(&wp->w_filter_cb, &callback);
222 }
Bram Moolenaar2fd8e352019-06-01 20:16:48 +0200223
224 get_padding_border(dict, wp->w_popup_padding, "padding", 999);
225 get_padding_border(dict, wp->w_popup_border, "border", 1);
Bram Moolenaar790498b2019-06-01 22:15:29 +0200226
227 for (i = 0; i < 4; ++i)
228 VIM_CLEAR(wp->w_border_highlight[i]);
229 di = dict_find(dict, (char_u *)"borderhighlight", -1);
230 if (di != NULL)
231 {
232 if (di->di_tv.v_type != VAR_LIST)
233 emsg(_(e_listreq));
234 else
235 {
236 list_T *list = di->di_tv.vval.v_list;
237 listitem_T *li;
238
239 if (list != NULL)
240 for (i = 0, li = list->lv_first; i < 4 && i < list->lv_len;
241 ++i, li = li->li_next)
242 {
243 str = tv_get_string(&li->li_tv);
244 if (*str != NUL)
245 wp->w_border_highlight[i] = vim_strsave(str);
246 }
247 if (list->lv_len == 1 && wp->w_border_highlight[0] != NULL)
248 for (i = 1; i < 4; ++i)
249 wp->w_border_highlight[i] =
250 vim_strsave(wp->w_border_highlight[0]);
251 }
252 }
253
254 for (i = 0; i < 8; ++i)
255 wp->w_border_char[i] = 0;
256 di = dict_find(dict, (char_u *)"borderchars", -1);
257 if (di != NULL)
258 {
259 if (di->di_tv.v_type != VAR_LIST)
260 emsg(_(e_listreq));
261 else
262 {
263 list_T *list = di->di_tv.vval.v_list;
264 listitem_T *li;
265
266 if (list != NULL)
267 for (i = 0, li = list->lv_first; i < 8 && i < list->lv_len;
268 ++i, li = li->li_next)
269 {
270 str = tv_get_string(&li->li_tv);
271 if (*str != NUL)
272 wp->w_border_char[i] = mb_ptr2char(str);
273 }
274 if (list->lv_len == 1)
275 for (i = 1; i < 8; ++i)
276 wp->w_border_char[i] = wp->w_border_char[0];
277 if (list->lv_len == 2)
278 {
279 for (i = 4; i < 8; ++i)
280 wp->w_border_char[i] = wp->w_border_char[1];
281 for (i = 1; i < 4; ++i)
282 wp->w_border_char[i] = wp->w_border_char[0];
283 }
284 }
285 }
Bram Moolenaar4d784b22019-05-25 19:51:39 +0200286}
287
288/*
Bram Moolenaar7a8d0272019-05-26 23:32:06 +0200289 * Add lines to the popup from a list of strings.
290 */
291 static void
292add_popup_strings(buf_T *buf, list_T *l)
293{
294 listitem_T *li;
295 linenr_T lnum = 0;
296 char_u *p;
297
298 for (li = l->lv_first; li != NULL; li = li->li_next)
299 if (li->li_tv.v_type == VAR_STRING)
300 {
301 p = li->li_tv.vval.v_string;
302 ml_append_buf(buf, lnum++,
303 p == NULL ? (char_u *)"" : p, (colnr_T)0, TRUE);
304 }
305}
306
307/*
308 * Add lines to the popup from a list of dictionaries.
309 */
310 static void
311add_popup_dicts(buf_T *buf, list_T *l)
312{
313 listitem_T *li;
314 listitem_T *pli;
315 linenr_T lnum = 0;
316 char_u *p;
317 dict_T *dict;
318
319 // first add the text lines
320 for (li = l->lv_first; li != NULL; li = li->li_next)
321 {
322 if (li->li_tv.v_type != VAR_DICT)
323 {
324 emsg(_(e_dictreq));
325 return;
326 }
327 dict = li->li_tv.vval.v_dict;
328 p = dict == NULL ? NULL
329 : dict_get_string(dict, (char_u *)"text", FALSE);
330 ml_append_buf(buf, lnum++,
331 p == NULL ? (char_u *)"" : p, (colnr_T)0, TRUE);
332 }
333
334 // add the text properties
335 lnum = 1;
336 for (li = l->lv_first; li != NULL; li = li->li_next, ++lnum)
337 {
338 dictitem_T *di;
339 list_T *plist;
340
341 dict = li->li_tv.vval.v_dict;
342 di = dict_find(dict, (char_u *)"props", -1);
343 if (di != NULL)
344 {
345 if (di->di_tv.v_type != VAR_LIST)
346 {
347 emsg(_(e_listreq));
348 return;
349 }
350 plist = di->di_tv.vval.v_list;
351 if (plist != NULL)
352 {
353 for (pli = plist->lv_first; pli != NULL; pli = pli->li_next)
354 {
355 if (pli->li_tv.v_type != VAR_DICT)
356 {
357 emsg(_(e_dictreq));
358 return;
359 }
360 dict = pli->li_tv.vval.v_dict;
361 if (dict != NULL)
362 {
363 int col = dict_get_number(dict, (char_u *)"col");
364
365 prop_add_common( lnum, col, dict, buf, NULL);
366 }
367 }
368 }
369 }
370 }
371}
372
373/*
Bram Moolenaar60cdb302019-05-27 21:54:10 +0200374 * Adjust the position and size of the popup to fit on the screen.
375 */
Bram Moolenaar17146962019-05-30 00:12:11 +0200376 void
Bram Moolenaar60cdb302019-05-27 21:54:10 +0200377popup_adjust_position(win_T *wp)
378{
Bram Moolenaar88c4e1f2019-05-29 23:14:28 +0200379 linenr_T lnum;
380 int wrapped = 0;
381 int maxwidth;
Bram Moolenaarac1f1bc2019-05-30 21:24:26 +0200382 int center_vert = FALSE;
383 int center_hor = FALSE;
Bram Moolenaar042fb4b2019-06-02 14:49:56 +0200384 int allow_adjust_left = !wp->w_popup_fixed;
Bram Moolenaar399d8982019-06-02 15:34:29 +0200385 int top_extra = wp->w_popup_border[0] + wp->w_popup_padding[0];
386 int right_extra = wp->w_popup_border[1] + wp->w_popup_padding[1];
387 int bot_extra = wp->w_popup_border[2] + wp->w_popup_padding[2];
388 int left_extra = wp->w_popup_border[3] + wp->w_popup_padding[3];
389 int extra_height = top_extra + bot_extra;
390 int extra_width = left_extra + right_extra;
Bram Moolenaar88c4e1f2019-05-29 23:14:28 +0200391
Bram Moolenaarac1f1bc2019-05-30 21:24:26 +0200392 wp->w_winrow = 0;
393 wp->w_wincol = 0;
394 if (wp->w_popup_pos == POPPOS_CENTER)
395 {
396 // center after computing the size
397 center_vert = TRUE;
398 center_hor = TRUE;
399 }
Bram Moolenaar60cdb302019-05-27 21:54:10 +0200400 else
Bram Moolenaarac1f1bc2019-05-30 21:24:26 +0200401 {
402 if (wp->w_wantline == 0)
403 center_vert = TRUE;
404 else if (wp->w_popup_pos == POPPOS_TOPLEFT
405 || wp->w_popup_pos == POPPOS_TOPRIGHT)
406 {
407 wp->w_winrow = wp->w_wantline - 1;
408 if (wp->w_winrow >= Rows)
409 wp->w_winrow = Rows - 1;
410 }
Bram Moolenaar60cdb302019-05-27 21:54:10 +0200411
Bram Moolenaarac1f1bc2019-05-30 21:24:26 +0200412 if (wp->w_wantcol == 0)
413 center_hor = TRUE;
414 else if (wp->w_popup_pos == POPPOS_TOPLEFT
415 || wp->w_popup_pos == POPPOS_BOTLEFT)
416 {
417 wp->w_wincol = wp->w_wantcol - 1;
418 if (wp->w_wincol >= Columns - 3)
419 wp->w_wincol = Columns - 3;
420 }
421 }
Bram Moolenaar60cdb302019-05-27 21:54:10 +0200422
Bram Moolenaarac1f1bc2019-05-30 21:24:26 +0200423 // When centering or right aligned, use maximum width.
Bram Moolenaar042fb4b2019-06-02 14:49:56 +0200424 // When left aligned use the space available, but shift to the left when we
425 // hit the right of the screen.
Bram Moolenaar88c4e1f2019-05-29 23:14:28 +0200426 maxwidth = Columns - wp->w_wincol;
427 if (wp->w_maxwidth > 0 && maxwidth > wp->w_maxwidth)
Bram Moolenaar042fb4b2019-06-02 14:49:56 +0200428 {
429 allow_adjust_left = FALSE;
Bram Moolenaar88c4e1f2019-05-29 23:14:28 +0200430 maxwidth = wp->w_maxwidth;
Bram Moolenaar042fb4b2019-06-02 14:49:56 +0200431 }
Bram Moolenaar88c4e1f2019-05-29 23:14:28 +0200432
433 // Compute width based on longest text line and the 'wrap' option.
434 // TODO: more accurate wrapping
435 wp->w_width = 0;
436 for (lnum = 1; lnum <= wp->w_buffer->b_ml.ml_line_count; ++lnum)
437 {
438 int len = vim_strsize(ml_get_buf(wp->w_buffer, lnum, FALSE));
439
Bram Moolenaar042fb4b2019-06-02 14:49:56 +0200440 if (wp->w_p_wrap)
Bram Moolenaar88c4e1f2019-05-29 23:14:28 +0200441 {
Bram Moolenaar042fb4b2019-06-02 14:49:56 +0200442 while (len > maxwidth)
443 {
444 ++wrapped;
445 len -= maxwidth;
446 wp->w_width = maxwidth;
447 }
448 }
449 else if (len > maxwidth
450 && allow_adjust_left
451 && (wp->w_popup_pos == POPPOS_TOPLEFT
452 || wp->w_popup_pos == POPPOS_BOTLEFT))
453 {
454 // adjust leftwise to fit text on screen
455 int shift_by = ( len - maxwidth );
456
457 if ( shift_by > wp->w_wincol )
458 {
459 int truncate_shift = shift_by - wp->w_wincol;
460 len -= truncate_shift;
461 shift_by -= truncate_shift;
462 }
463
464 wp->w_wincol -= shift_by;
465 maxwidth += shift_by;
Bram Moolenaar88c4e1f2019-05-29 23:14:28 +0200466 wp->w_width = maxwidth;
467 }
468 if (wp->w_width < len)
469 wp->w_width = len;
470 }
471
Bram Moolenaar60cdb302019-05-27 21:54:10 +0200472 if (wp->w_minwidth > 0 && wp->w_width < wp->w_minwidth)
473 wp->w_width = wp->w_minwidth;
Bram Moolenaar88c4e1f2019-05-29 23:14:28 +0200474 if (wp->w_width > maxwidth)
475 wp->w_width = maxwidth;
Bram Moolenaarac1f1bc2019-05-30 21:24:26 +0200476 if (center_hor)
477 wp->w_wincol = (Columns - wp->w_width) / 2;
478 else if (wp->w_popup_pos == POPPOS_BOTRIGHT
479 || wp->w_popup_pos == POPPOS_TOPRIGHT)
480 {
481 // Right aligned: move to the right if needed.
482 // No truncation, because that would change the height.
Bram Moolenaar399d8982019-06-02 15:34:29 +0200483 if (wp->w_width + extra_width < wp->w_wantcol)
484 wp->w_wincol = wp->w_wantcol - (wp->w_width + extra_width);
Bram Moolenaarac1f1bc2019-05-30 21:24:26 +0200485 }
Bram Moolenaar60cdb302019-05-27 21:54:10 +0200486
487 if (wp->w_height <= 1)
Bram Moolenaar88c4e1f2019-05-29 23:14:28 +0200488 wp->w_height = wp->w_buffer->b_ml.ml_line_count + wrapped;
Bram Moolenaar60cdb302019-05-27 21:54:10 +0200489 if (wp->w_minheight > 0 && wp->w_height < wp->w_minheight)
490 wp->w_height = wp->w_minheight;
491 if (wp->w_maxheight > 0 && wp->w_height > wp->w_maxheight)
492 wp->w_height = wp->w_maxheight;
493 if (wp->w_height > Rows - wp->w_winrow)
494 wp->w_height = Rows - wp->w_winrow;
Bram Moolenaar17146962019-05-30 00:12:11 +0200495
Bram Moolenaarac1f1bc2019-05-30 21:24:26 +0200496 if (center_vert)
497 wp->w_winrow = (Rows - wp->w_height) / 2;
498 else if (wp->w_popup_pos == POPPOS_BOTRIGHT
499 || wp->w_popup_pos == POPPOS_BOTLEFT)
500 {
Bram Moolenaar399d8982019-06-02 15:34:29 +0200501 if ((wp->w_height + extra_height) <= wp->w_wantline)
Bram Moolenaarac1f1bc2019-05-30 21:24:26 +0200502 // bottom aligned: may move down
Bram Moolenaar399d8982019-06-02 15:34:29 +0200503 wp->w_winrow = wp->w_wantline - (wp->w_height + extra_height);
Bram Moolenaarac1f1bc2019-05-30 21:24:26 +0200504 else
505 // not enough space, make top aligned
506 wp->w_winrow = wp->w_wantline + 1;
507 }
508
Bram Moolenaar17146962019-05-30 00:12:11 +0200509 wp->w_popup_last_changedtick = CHANGEDTICK(wp->w_buffer);
Bram Moolenaar60cdb302019-05-27 21:54:10 +0200510}
511
512/*
Bram Moolenaar4d784b22019-05-25 19:51:39 +0200513 * popup_create({text}, {options})
Bram Moolenaarcc31ad92019-05-30 19:25:06 +0200514 * popup_atcursor({text}, {options})
515 * When called from f_popup_atcursor() "atcursor" is TRUE.
Bram Moolenaar4d784b22019-05-25 19:51:39 +0200516 */
Bram Moolenaarcc31ad92019-05-30 19:25:06 +0200517 static void
518popup_create(typval_T *argvars, typval_T *rettv, int atcursor)
Bram Moolenaar4d784b22019-05-25 19:51:39 +0200519{
520 win_T *wp;
521 buf_T *buf;
522 dict_T *d;
523 int nr;
524
525 // Check arguments look OK.
Bram Moolenaar7b29dd82019-06-02 13:22:11 +0200526 if (!(argvars[0].v_type == VAR_STRING && argvars[0].vval.v_string != NULL)
527 && !(argvars[0].v_type == VAR_LIST && argvars[0].vval.v_list != NULL))
Bram Moolenaar4d784b22019-05-25 19:51:39 +0200528 {
529 emsg(_(e_listreq));
530 return;
531 }
532 if (argvars[1].v_type != VAR_DICT || argvars[1].vval.v_dict == NULL)
533 {
534 emsg(_(e_dictreq));
535 return;
536 }
537 d = argvars[1].vval.v_dict;
538
539 // Create the window and buffer.
540 wp = win_alloc_popup_win();
541 if (wp == NULL)
542 return;
543 rettv->vval.v_number = wp->w_id;
Bram Moolenaarac1f1bc2019-05-30 21:24:26 +0200544 wp->w_popup_pos = POPPOS_TOPLEFT;
Bram Moolenaar4d784b22019-05-25 19:51:39 +0200545
546 buf = buflist_new(NULL, NULL, (linenr_T)0, BLN_NEW|BLN_LISTED|BLN_DUMMY);
547 if (buf == NULL)
548 return;
549 ml_open(buf);
Bram Moolenaarcacc6a52019-05-30 15:22:43 +0200550
551 win_init_popup_win(wp, buf);
552
553 set_local_options_default(wp);
Bram Moolenaar20c023a2019-05-26 21:03:24 +0200554 set_string_option_direct_in_buf(buf, (char_u *)"buftype", -1,
Bram Moolenaar4d784b22019-05-25 19:51:39 +0200555 (char_u *)"popup", OPT_FREE|OPT_LOCAL, 0);
Bram Moolenaar20c023a2019-05-26 21:03:24 +0200556 set_string_option_direct_in_buf(buf, (char_u *)"bufhidden", -1,
Bram Moolenaar4d784b22019-05-25 19:51:39 +0200557 (char_u *)"hide", OPT_FREE|OPT_LOCAL, 0);
Bram Moolenaar4d784b22019-05-25 19:51:39 +0200558 buf->b_p_ul = -1; // no undo
559 buf->b_p_swf = FALSE; // no swap file
560 buf->b_p_bl = FALSE; // unlisted buffer
Bram Moolenaar868b7b62019-05-29 21:44:40 +0200561 buf->b_locked = TRUE;
Bram Moolenaarac1f1bc2019-05-30 21:24:26 +0200562 wp->w_p_wrap = TRUE; // 'wrap' is default on
563
Bram Moolenaar54fabd42019-05-30 19:03:22 +0200564 // Avoid that 'buftype' is reset when this buffer is entered.
565 buf->b_p_initialized = TRUE;
Bram Moolenaar4d784b22019-05-25 19:51:39 +0200566
Bram Moolenaar4d784b22019-05-25 19:51:39 +0200567 nr = (int)dict_get_number(d, (char_u *)"tab");
568 if (nr == 0)
569 {
570 // popup on current tab
Bram Moolenaar9c27b1c2019-05-26 18:48:13 +0200571 wp->w_next = curtab->tp_first_popupwin;
572 curtab->tp_first_popupwin = wp;
Bram Moolenaar4d784b22019-05-25 19:51:39 +0200573 }
574 else if (nr < 0)
575 {
576 // global popup
577 wp->w_next = first_popupwin;
578 first_popupwin = wp;
579 }
580 else
581 // TODO: find tab page "nr"
582 emsg("Not implemented yet");
583
584 // Add text to the buffer.
585 if (argvars[0].v_type == VAR_STRING)
Bram Moolenaar7a8d0272019-05-26 23:32:06 +0200586 {
Bram Moolenaar4d784b22019-05-25 19:51:39 +0200587 // just a string
588 ml_append_buf(buf, 0, argvars[0].vval.v_string, (colnr_T)0, TRUE);
Bram Moolenaar4d784b22019-05-25 19:51:39 +0200589 }
590 else
Bram Moolenaar7a8d0272019-05-26 23:32:06 +0200591 {
592 list_T *l = argvars[0].vval.v_list;
593
Bram Moolenaar7b29dd82019-06-02 13:22:11 +0200594 if (l->lv_len > 0)
595 {
596 if (l->lv_first->li_tv.v_type == VAR_STRING)
597 // list of strings
598 add_popup_strings(buf, l);
599 else
600 // list of dictionaries
601 add_popup_dicts(buf, l);
602 }
Bram Moolenaar7a8d0272019-05-26 23:32:06 +0200603 }
Bram Moolenaar4d784b22019-05-25 19:51:39 +0200604
605 // Delete the line of the empty buffer.
606 curbuf = buf;
607 ml_delete(buf->b_ml.ml_line_count, FALSE);
608 curbuf = curwin->w_buffer;
609
610 // Deal with options.
Bram Moolenaarcc31ad92019-05-30 19:25:06 +0200611 apply_options(wp, buf, argvars[1].vval.v_dict, atcursor);
Bram Moolenaar4d784b22019-05-25 19:51:39 +0200612
613 // set default values
614 if (wp->w_zindex == 0)
615 wp->w_zindex = 50;
616
Bram Moolenaar60cdb302019-05-27 21:54:10 +0200617 popup_adjust_position(wp);
Bram Moolenaar4d784b22019-05-25 19:51:39 +0200618
619 wp->w_vsep_width = 0;
620
621 redraw_all_later(NOT_VALID);
622}
623
624/*
Bram Moolenaarcc31ad92019-05-30 19:25:06 +0200625 * popup_create({text}, {options})
626 */
627 void
628f_popup_create(typval_T *argvars, typval_T *rettv)
629{
630 popup_create(argvars, rettv, FALSE);
631}
632
633/*
634 * popup_atcursor({text}, {options})
635 */
636 void
637f_popup_atcursor(typval_T *argvars, typval_T *rettv)
638{
639 popup_create(argvars, rettv, TRUE);
640}
641
642/*
Bram Moolenaar2cd0dce2019-05-26 22:17:52 +0200643 * Find the popup window with window-ID "id".
644 * If the popup window does not exist NULL is returned.
645 * If the window is not a popup window, and error message is given.
646 */
647 static win_T *
648find_popup_win(int id)
649{
650 win_T *wp = win_id2wp(id);
651
652 if (wp != NULL && !bt_popup(wp->w_buffer))
653 {
654 semsg(_("E993: window %d is not a popup window"), id);
655 return NULL;
656 }
657 return wp;
658}
659
660/*
661 * Return TRUE if there any popups that are not hidden.
662 */
663 int
664popup_any_visible(void)
665{
666 win_T *wp;
667
668 for (wp = first_popupwin; wp != NULL; wp = wp->w_next)
Bram Moolenaarbf0ecb22019-05-27 10:04:40 +0200669 if ((wp->w_popup_flags & POPF_HIDDEN) == 0)
Bram Moolenaar2cd0dce2019-05-26 22:17:52 +0200670 return TRUE;
671 for (wp = curtab->tp_first_popupwin; wp != NULL; wp = wp->w_next)
Bram Moolenaarbf0ecb22019-05-27 10:04:40 +0200672 if ((wp->w_popup_flags & POPF_HIDDEN) == 0)
Bram Moolenaar2cd0dce2019-05-26 22:17:52 +0200673 return TRUE;
674 return FALSE;
675}
676
677/*
Bram Moolenaar9eaac892019-06-01 22:49:29 +0200678 * Invoke the close callback for window "wp" with value "result".
679 * Careful: The callback may make "wp" invalid!
680 */
681 static void
682invoke_popup_callback(win_T *wp, typval_T *result)
683{
684 typval_T rettv;
685 int dummy;
686 typval_T argv[3];
687
688 argv[0].v_type = VAR_NUMBER;
689 argv[0].vval.v_number = (varnumber_T)wp->w_id;
690
691 if (result != NULL && result->v_type != VAR_UNKNOWN)
692 copy_tv(result, &argv[1]);
693 else
694 {
695 argv[1].v_type = VAR_NUMBER;
696 argv[1].vval.v_number = 0;
697 }
698
699 argv[2].v_type = VAR_UNKNOWN;
700
701 call_callback(&wp->w_close_cb, -1,
702 &rettv, 2, argv, NULL, 0L, 0L, &dummy, TRUE, NULL);
703 if (result != NULL)
704 clear_tv(&argv[1]);
705 clear_tv(&rettv);
706}
707
708/*
Bram Moolenaar4d784b22019-05-25 19:51:39 +0200709 * popup_close({id})
710 */
711 void
712f_popup_close(typval_T *argvars, typval_T *rettv UNUSED)
713{
Bram Moolenaar2cd0dce2019-05-26 22:17:52 +0200714 int id = (int)tv_get_number(argvars);
Bram Moolenaar9eaac892019-06-01 22:49:29 +0200715 win_T *wp = find_popup_win(id);
Bram Moolenaar4d784b22019-05-25 19:51:39 +0200716
Bram Moolenaar9eaac892019-06-01 22:49:29 +0200717 if (wp != NULL)
718 {
719 if (wp->w_close_cb.cb_name != NULL)
720 // Careful: This may make "wp" invalid.
721 invoke_popup_callback(wp, &argvars[1]);
722
723 popup_close(id);
724 }
Bram Moolenaar2cd0dce2019-05-26 22:17:52 +0200725}
726
727/*
728 * popup_hide({id})
729 */
730 void
731f_popup_hide(typval_T *argvars, typval_T *rettv UNUSED)
732{
733 int id = (int)tv_get_number(argvars);
734 win_T *wp = find_popup_win(id);
735
Bram Moolenaarbf0ecb22019-05-27 10:04:40 +0200736 if (wp != NULL && (wp->w_popup_flags & POPF_HIDDEN) == 0)
Bram Moolenaar2cd0dce2019-05-26 22:17:52 +0200737 {
Bram Moolenaarbf0ecb22019-05-27 10:04:40 +0200738 wp->w_popup_flags |= POPF_HIDDEN;
Bram Moolenaarc6896e22019-05-30 22:32:34 +0200739 --wp->w_buffer->b_nwindows;
Bram Moolenaar2cd0dce2019-05-26 22:17:52 +0200740 redraw_all_later(NOT_VALID);
741 }
742}
743
744/*
745 * popup_show({id})
746 */
747 void
748f_popup_show(typval_T *argvars, typval_T *rettv UNUSED)
749{
750 int id = (int)tv_get_number(argvars);
751 win_T *wp = find_popup_win(id);
752
Bram Moolenaarbf0ecb22019-05-27 10:04:40 +0200753 if (wp != NULL && (wp->w_popup_flags & POPF_HIDDEN) != 0)
Bram Moolenaar2cd0dce2019-05-26 22:17:52 +0200754 {
Bram Moolenaarbf0ecb22019-05-27 10:04:40 +0200755 wp->w_popup_flags &= ~POPF_HIDDEN;
Bram Moolenaarc6896e22019-05-30 22:32:34 +0200756 ++wp->w_buffer->b_nwindows;
Bram Moolenaar2cd0dce2019-05-26 22:17:52 +0200757 redraw_all_later(NOT_VALID);
758 }
Bram Moolenaar4d784b22019-05-25 19:51:39 +0200759}
760
Bram Moolenaar51fe3b12019-05-26 20:10:06 +0200761 static void
Bram Moolenaar2cd0dce2019-05-26 22:17:52 +0200762popup_free(win_T *wp)
Bram Moolenaar51fe3b12019-05-26 20:10:06 +0200763{
Bram Moolenaar868b7b62019-05-29 21:44:40 +0200764 wp->w_buffer->b_locked = FALSE;
Bram Moolenaar51fe3b12019-05-26 20:10:06 +0200765 if (wp->w_winrow + wp->w_height >= cmdline_row)
766 clear_cmdline = TRUE;
767 win_free_popup(wp);
768 redraw_all_later(NOT_VALID);
769}
770
Bram Moolenaarec583842019-05-26 14:11:23 +0200771/*
772 * Close a popup window by Window-id.
Bram Moolenaar9eaac892019-06-01 22:49:29 +0200773 * Does not invoke the callback.
Bram Moolenaarec583842019-05-26 14:11:23 +0200774 */
Bram Moolenaar4d784b22019-05-25 19:51:39 +0200775 void
Bram Moolenaarec583842019-05-26 14:11:23 +0200776popup_close(int id)
Bram Moolenaar4d784b22019-05-25 19:51:39 +0200777{
778 win_T *wp;
Bram Moolenaarec583842019-05-26 14:11:23 +0200779 tabpage_T *tp;
Bram Moolenaar4d784b22019-05-25 19:51:39 +0200780 win_T *prev = NULL;
781
Bram Moolenaarec583842019-05-26 14:11:23 +0200782 // go through global popups
Bram Moolenaar4d784b22019-05-25 19:51:39 +0200783 for (wp = first_popupwin; wp != NULL; prev = wp, wp = wp->w_next)
Bram Moolenaarec583842019-05-26 14:11:23 +0200784 if (wp->w_id == id)
Bram Moolenaar4d784b22019-05-25 19:51:39 +0200785 {
786 if (prev == NULL)
787 first_popupwin = wp->w_next;
788 else
789 prev->w_next = wp->w_next;
Bram Moolenaar2cd0dce2019-05-26 22:17:52 +0200790 popup_free(wp);
Bram Moolenaarec583842019-05-26 14:11:23 +0200791 return;
Bram Moolenaar4d784b22019-05-25 19:51:39 +0200792 }
793
Bram Moolenaarec583842019-05-26 14:11:23 +0200794 // go through tab-local popups
795 FOR_ALL_TABPAGES(tp)
796 popup_close_tabpage(tp, id);
797}
798
799/*
800 * Close a popup window with Window-id "id" in tabpage "tp".
801 */
802 void
803popup_close_tabpage(tabpage_T *tp, int id)
804{
805 win_T *wp;
Bram Moolenaar9c27b1c2019-05-26 18:48:13 +0200806 win_T **root = &tp->tp_first_popupwin;
Bram Moolenaarec583842019-05-26 14:11:23 +0200807 win_T *prev = NULL;
808
Bram Moolenaarec583842019-05-26 14:11:23 +0200809 for (wp = *root; wp != NULL; prev = wp, wp = wp->w_next)
810 if (wp->w_id == id)
811 {
812 if (prev == NULL)
813 *root = wp->w_next;
814 else
815 prev->w_next = wp->w_next;
Bram Moolenaar2cd0dce2019-05-26 22:17:52 +0200816 popup_free(wp);
Bram Moolenaarec583842019-05-26 14:11:23 +0200817 return;
818 }
Bram Moolenaar4d784b22019-05-25 19:51:39 +0200819}
820
821 void
822close_all_popups(void)
823{
824 while (first_popupwin != NULL)
825 popup_close(first_popupwin->w_id);
Bram Moolenaar9c27b1c2019-05-26 18:48:13 +0200826 while (curtab->tp_first_popupwin != NULL)
827 popup_close(curtab->tp_first_popupwin->w_id);
Bram Moolenaar4d784b22019-05-25 19:51:39 +0200828}
829
830 void
831ex_popupclear(exarg_T *eap UNUSED)
832{
833 close_all_popups();
834}
835
Bram Moolenaar60cdb302019-05-27 21:54:10 +0200836/*
837 * popup_move({id}, {options})
838 */
839 void
840f_popup_move(typval_T *argvars, typval_T *rettv UNUSED)
841{
842 dict_T *d;
843 int nr;
844 int id = (int)tv_get_number(argvars);
845 win_T *wp = find_popup_win(id);
846
847 if (wp == NULL)
848 return; // invalid {id}
849
850 if (argvars[1].v_type != VAR_DICT || argvars[1].vval.v_dict == NULL)
851 {
852 emsg(_(e_dictreq));
853 return;
854 }
855 d = argvars[1].vval.v_dict;
856
857 if ((nr = dict_get_number(d, (char_u *)"minwidth")) > 0)
858 wp->w_minwidth = nr;
859 if ((nr = dict_get_number(d, (char_u *)"minheight")) > 0)
860 wp->w_minheight = nr;
861 if ((nr = dict_get_number(d, (char_u *)"maxwidth")) > 0)
862 wp->w_maxwidth = nr;
863 if ((nr = dict_get_number(d, (char_u *)"maxheight")) > 0)
864 wp->w_maxheight = nr;
Bram Moolenaarac1f1bc2019-05-30 21:24:26 +0200865 get_pos_options(wp, d);
Bram Moolenaar60cdb302019-05-27 21:54:10 +0200866
867 if (wp->w_winrow + wp->w_height >= cmdline_row)
868 clear_cmdline = TRUE;
869 popup_adjust_position(wp);
870 redraw_all_later(NOT_VALID);
871}
872
Bram Moolenaarbc133542019-05-29 20:26:46 +0200873/*
Bram Moolenaarac1f1bc2019-05-30 21:24:26 +0200874 * popup_getpos({id})
Bram Moolenaarbc133542019-05-29 20:26:46 +0200875 */
876 void
Bram Moolenaarac1f1bc2019-05-30 21:24:26 +0200877f_popup_getpos(typval_T *argvars, typval_T *rettv)
Bram Moolenaarbc133542019-05-29 20:26:46 +0200878{
879 dict_T *dict;
880 int id = (int)tv_get_number(argvars);
881 win_T *wp = find_popup_win(id);
Bram Moolenaar2fd8e352019-06-01 20:16:48 +0200882 int top_extra;
883 int left_extra;
Bram Moolenaarbc133542019-05-29 20:26:46 +0200884
885 if (rettv_dict_alloc(rettv) == OK)
886 {
887 if (wp == NULL)
888 return; // invalid {id}
Bram Moolenaar2fd8e352019-06-01 20:16:48 +0200889 top_extra = wp->w_popup_border[0] + wp->w_popup_padding[0];
890 left_extra = wp->w_popup_border[3] + wp->w_popup_padding[3];
891
Bram Moolenaarbc133542019-05-29 20:26:46 +0200892 dict = rettv->vval.v_dict;
Bram Moolenaar2fd8e352019-06-01 20:16:48 +0200893
Bram Moolenaarbc133542019-05-29 20:26:46 +0200894 dict_add_number(dict, "line", wp->w_winrow + 1);
895 dict_add_number(dict, "col", wp->w_wincol + 1);
Bram Moolenaar2fd8e352019-06-01 20:16:48 +0200896 dict_add_number(dict, "width", wp->w_width + left_extra + wp->w_popup_border[1] + wp->w_popup_padding[1]);
897 dict_add_number(dict, "height", wp->w_height + top_extra + wp->w_popup_border[2] + wp->w_popup_padding[2]);
898
899 dict_add_number(dict, "core_line", wp->w_winrow + 1 + top_extra);
900 dict_add_number(dict, "core_col", wp->w_wincol + 1 + left_extra);
901 dict_add_number(dict, "core_width", wp->w_width);
902 dict_add_number(dict, "core_height", wp->w_height);
903
Bram Moolenaar8c2a6002019-05-30 14:29:45 +0200904 dict_add_number(dict, "visible",
905 (wp->w_popup_flags & POPF_HIDDEN) == 0);
906 }
907}
908
909/*
910 * f_popup_getoptions({id})
911 */
912 void
913f_popup_getoptions(typval_T *argvars, typval_T *rettv)
914{
915 dict_T *dict;
916 int id = (int)tv_get_number(argvars);
917 win_T *wp = find_popup_win(id);
Bram Moolenaarac1f1bc2019-05-30 21:24:26 +0200918 int i;
Bram Moolenaar8c2a6002019-05-30 14:29:45 +0200919
920 if (rettv_dict_alloc(rettv) == OK)
921 {
922 if (wp == NULL)
923 return;
924
925 dict = rettv->vval.v_dict;
926 dict_add_number(dict, "line", wp->w_wantline);
927 dict_add_number(dict, "col", wp->w_wantcol);
928 dict_add_number(dict, "minwidth", wp->w_minwidth);
929 dict_add_number(dict, "minheight", wp->w_minheight);
930 dict_add_number(dict, "maxheight", wp->w_maxheight);
931 dict_add_number(dict, "maxwidth", wp->w_maxwidth);
932 dict_add_number(dict, "zindex", wp->w_zindex);
Bram Moolenaar042fb4b2019-06-02 14:49:56 +0200933 dict_add_number(dict, "fixed", wp->w_popup_fixed);
Bram Moolenaarac1f1bc2019-05-30 21:24:26 +0200934
935 for (i = 0; i < (int)(sizeof(poppos_entries) / sizeof(poppos_entry_T));
936 ++i)
937 if (wp->w_popup_pos == poppos_entries[i].pp_val)
938 {
939 dict_add_string(dict, "pos",
940 (char_u *)poppos_entries[i].pp_name);
941 break;
942 }
943
Bram Moolenaar8c2a6002019-05-30 14:29:45 +0200944# if defined(FEAT_TIMERS)
945 dict_add_number(dict, "time", wp->w_popup_timer != NULL
946 ? (long)wp->w_popup_timer->tr_interval : 0L);
947# endif
Bram Moolenaarbc133542019-05-29 20:26:46 +0200948 }
949}
Bram Moolenaar815b76b2019-06-01 14:15:52 +0200950
951 int
952not_in_popup_window()
953{
954 if (bt_popup(curwin->w_buffer))
955 {
956 emsg(_("E994: Not allowed in a popup window"));
957 return TRUE;
958 }
959 return FALSE;
960}
961
Bram Moolenaarbf0eff02019-06-01 17:13:36 +0200962/*
963 * Reset all the POPF_HANDLED flags in global popup windows and popup windows
964 * in the current tab.
965 */
966 void
967popup_reset_handled()
968{
969 win_T *wp;
970
971 for (wp = first_popupwin; wp != NULL; wp = wp->w_next)
972 wp->w_popup_flags &= ~POPF_HANDLED;
973 for (wp = curtab->tp_first_popupwin; wp != NULL; wp = wp->w_next)
974 wp->w_popup_flags &= ~POPF_HANDLED;
975}
976
977/*
978 * Find the next visible popup where POPF_HANDLED is not set.
979 * Must have called popup_reset_handled() first.
980 * When "lowest" is TRUE find the popup with the lowest zindex, otherwise the
981 * popup with the highest zindex.
982 */
983 win_T *
984find_next_popup(int lowest)
985{
986 win_T *wp;
987 win_T *found_wp;
988 int found_zindex;
989
990 found_zindex = lowest ? INT_MAX : 0;
991 found_wp = NULL;
992 for (wp = first_popupwin; wp != NULL; wp = wp->w_next)
993 if ((wp->w_popup_flags & (POPF_HANDLED|POPF_HIDDEN)) == 0
994 && (lowest ? wp->w_zindex < found_zindex
995 : wp->w_zindex > found_zindex))
996 {
997 found_zindex = wp->w_zindex;
998 found_wp = wp;
999 }
1000 for (wp = curtab->tp_first_popupwin; wp != NULL; wp = wp->w_next)
1001 if ((wp->w_popup_flags & (POPF_HANDLED|POPF_HIDDEN)) == 0
1002 && (lowest ? wp->w_zindex < found_zindex
1003 : wp->w_zindex > found_zindex))
1004 {
1005 found_zindex = wp->w_zindex;
1006 found_wp = wp;
1007 }
1008
1009 if (found_wp != NULL)
1010 found_wp->w_popup_flags |= POPF_HANDLED;
1011 return found_wp;
1012}
1013
1014/*
1015 * Invoke the filter callback for window "wp" with typed character "c".
1016 * Uses the global "mod_mask" for modifiers.
1017 * Returns the return value of the filter.
1018 * Careful: The filter may make "wp" invalid!
1019 */
1020 static int
1021invoke_popup_filter(win_T *wp, int c)
1022{
1023 int res;
1024 typval_T rettv;
1025 int dummy;
1026 typval_T argv[3];
1027 char_u buf[NUMBUFLEN];
1028
1029 argv[0].v_type = VAR_NUMBER;
1030 argv[0].vval.v_number = (varnumber_T)wp->w_id;
1031
1032 // Convert the number to a string, so that the function can use:
1033 // if a:c == "\<F2>"
1034 buf[special_to_buf(c, mod_mask, TRUE, buf)] = NUL;
1035 argv[1].v_type = VAR_STRING;
1036 argv[1].vval.v_string = vim_strsave(buf);
1037
1038 argv[2].v_type = VAR_UNKNOWN;
1039
1040 call_callback(&wp->w_filter_cb, -1,
1041 &rettv, 2, argv, NULL, 0L, 0L, &dummy, TRUE, NULL);
1042 res = tv_get_number(&rettv);
1043 vim_free(argv[1].vval.v_string);
1044 clear_tv(&rettv);
1045 return res;
1046}
1047
1048/*
1049 * Called when "c" was typed: invoke popup filter callbacks.
1050 * Returns TRUE when the character was consumed,
1051 */
1052 int
1053popup_do_filter(int c)
1054{
1055 int res = FALSE;
1056 win_T *wp;
1057
1058 popup_reset_handled();
1059
1060 while (!res && (wp = find_next_popup(FALSE)) != NULL)
1061 if (wp->w_filter_cb.cb_name != NULL)
1062 res = invoke_popup_filter(wp, c);
1063
1064 return res;
1065}
1066
Bram Moolenaar4d784b22019-05-25 19:51:39 +02001067#endif // FEAT_TEXT_PROP