blob: ee59af2eaef87e66775a0a0d3029e2c80393e7ea [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
18/*
19 * Go through the options in "dict" and apply them to buffer "buf" displayed in
20 * popup window "wp".
21 */
22 static void
23apply_options(win_T *wp, buf_T *buf UNUSED, dict_T *dict)
24{
Bram Moolenaar51fe3b12019-05-26 20:10:06 +020025 int nr;
Bram Moolenaar20c023a2019-05-26 21:03:24 +020026 char_u *str;
Bram Moolenaar51fe3b12019-05-26 20:10:06 +020027
Bram Moolenaar60cdb302019-05-27 21:54:10 +020028 wp->w_minwidth = dict_get_number(dict, (char_u *)"minwidth");
29 wp->w_minheight = dict_get_number(dict, (char_u *)"minheight");
Bram Moolenaar4d784b22019-05-25 19:51:39 +020030 wp->w_maxwidth = dict_get_number(dict, (char_u *)"maxwidth");
31 wp->w_maxheight = dict_get_number(dict, (char_u *)"maxheight");
Bram Moolenaar60cdb302019-05-27 21:54:10 +020032
33 wp->w_wantline = dict_get_number(dict, (char_u *)"line");
34 wp->w_wantcol = dict_get_number(dict, (char_u *)"col");
35
Bram Moolenaar4d784b22019-05-25 19:51:39 +020036 wp->w_zindex = dict_get_number(dict, (char_u *)"zindex");
Bram Moolenaar51fe3b12019-05-26 20:10:06 +020037
Bram Moolenaar35d5af62019-05-26 20:44:10 +020038#if defined(FEAT_TIMERS)
Bram Moolenaar51fe3b12019-05-26 20:10:06 +020039 // Add timer to close the popup after some time.
40 nr = dict_get_number(dict, (char_u *)"time");
41 if (nr > 0)
42 {
43 char_u cbbuf[50];
44 char_u *ptr = cbbuf;
45 typval_T tv;
46
47 vim_snprintf((char *)cbbuf, sizeof(cbbuf),
48 "{_ -> popup_close(%d)}", wp->w_id);
49 if (get_lambda_tv(&ptr, &tv, TRUE) == OK)
50 {
51 wp->w_popup_timer = create_timer(nr, 0);
52 wp->w_popup_timer->tr_callback =
53 vim_strsave(partial_name(tv.vval.v_partial));
54 func_ref(wp->w_popup_timer->tr_callback);
55 wp->w_popup_timer->tr_partial = tv.vval.v_partial;
56 }
57 }
Bram Moolenaar35d5af62019-05-26 20:44:10 +020058#endif
Bram Moolenaar51fe3b12019-05-26 20:10:06 +020059
Bram Moolenaar20c023a2019-05-26 21:03:24 +020060 str = dict_get_string(dict, (char_u *)"highlight", TRUE);
61 if (str != NULL)
62 set_string_option_direct_in_win(wp, (char_u *)"wincolor", -1,
63 str, OPT_FREE|OPT_LOCAL, 0);
Bram Moolenaar4d784b22019-05-25 19:51:39 +020064}
65
66/*
Bram Moolenaar7a8d0272019-05-26 23:32:06 +020067 * Add lines to the popup from a list of strings.
68 */
69 static void
70add_popup_strings(buf_T *buf, list_T *l)
71{
72 listitem_T *li;
73 linenr_T lnum = 0;
74 char_u *p;
75
76 for (li = l->lv_first; li != NULL; li = li->li_next)
77 if (li->li_tv.v_type == VAR_STRING)
78 {
79 p = li->li_tv.vval.v_string;
80 ml_append_buf(buf, lnum++,
81 p == NULL ? (char_u *)"" : p, (colnr_T)0, TRUE);
82 }
83}
84
85/*
86 * Add lines to the popup from a list of dictionaries.
87 */
88 static void
89add_popup_dicts(buf_T *buf, list_T *l)
90{
91 listitem_T *li;
92 listitem_T *pli;
93 linenr_T lnum = 0;
94 char_u *p;
95 dict_T *dict;
96
97 // first add the text lines
98 for (li = l->lv_first; li != NULL; li = li->li_next)
99 {
100 if (li->li_tv.v_type != VAR_DICT)
101 {
102 emsg(_(e_dictreq));
103 return;
104 }
105 dict = li->li_tv.vval.v_dict;
106 p = dict == NULL ? NULL
107 : dict_get_string(dict, (char_u *)"text", FALSE);
108 ml_append_buf(buf, lnum++,
109 p == NULL ? (char_u *)"" : p, (colnr_T)0, TRUE);
110 }
111
112 // add the text properties
113 lnum = 1;
114 for (li = l->lv_first; li != NULL; li = li->li_next, ++lnum)
115 {
116 dictitem_T *di;
117 list_T *plist;
118
119 dict = li->li_tv.vval.v_dict;
120 di = dict_find(dict, (char_u *)"props", -1);
121 if (di != NULL)
122 {
123 if (di->di_tv.v_type != VAR_LIST)
124 {
125 emsg(_(e_listreq));
126 return;
127 }
128 plist = di->di_tv.vval.v_list;
129 if (plist != NULL)
130 {
131 for (pli = plist->lv_first; pli != NULL; pli = pli->li_next)
132 {
133 if (pli->li_tv.v_type != VAR_DICT)
134 {
135 emsg(_(e_dictreq));
136 return;
137 }
138 dict = pli->li_tv.vval.v_dict;
139 if (dict != NULL)
140 {
141 int col = dict_get_number(dict, (char_u *)"col");
142
143 prop_add_common( lnum, col, dict, buf, NULL);
144 }
145 }
146 }
147 }
148 }
149}
150
151/*
Bram Moolenaar60cdb302019-05-27 21:54:10 +0200152 * Adjust the position and size of the popup to fit on the screen.
153 */
Bram Moolenaar17146962019-05-30 00:12:11 +0200154 void
Bram Moolenaar60cdb302019-05-27 21:54:10 +0200155popup_adjust_position(win_T *wp)
156{
Bram Moolenaar88c4e1f2019-05-29 23:14:28 +0200157 linenr_T lnum;
158 int wrapped = 0;
159 int maxwidth;
160
Bram Moolenaar60cdb302019-05-27 21:54:10 +0200161 // TODO: Compute the size and position properly.
162 if (wp->w_wantline > 0)
163 wp->w_winrow = wp->w_wantline - 1;
164 else
165 // TODO: better default
166 wp->w_winrow = Rows > 5 ? Rows / 2 - 2 : 0;
167 if (wp->w_winrow >= Rows)
168 wp->w_winrow = Rows - 1;
169
170 if (wp->w_wantcol > 0)
171 wp->w_wincol = wp->w_wantcol - 1;
172 else
173 // TODO: better default
174 wp->w_wincol = Columns > 20 ? Columns / 2 - 10 : 0;
175 if (wp->w_wincol >= Columns - 3)
176 wp->w_wincol = Columns - 3;
177
Bram Moolenaar88c4e1f2019-05-29 23:14:28 +0200178 maxwidth = Columns - wp->w_wincol;
179 if (wp->w_maxwidth > 0 && maxwidth > wp->w_maxwidth)
180 maxwidth = wp->w_maxwidth;
181
182 // Compute width based on longest text line and the 'wrap' option.
183 // TODO: more accurate wrapping
184 wp->w_width = 0;
185 for (lnum = 1; lnum <= wp->w_buffer->b_ml.ml_line_count; ++lnum)
186 {
187 int len = vim_strsize(ml_get_buf(wp->w_buffer, lnum, FALSE));
188
189 while (wp->w_p_wrap && len > maxwidth)
190 {
191 ++wrapped;
192 len -= maxwidth;
193 wp->w_width = maxwidth;
194 }
195 if (wp->w_width < len)
196 wp->w_width = len;
197 }
198
Bram Moolenaar60cdb302019-05-27 21:54:10 +0200199 if (wp->w_minwidth > 0 && wp->w_width < wp->w_minwidth)
200 wp->w_width = wp->w_minwidth;
Bram Moolenaar88c4e1f2019-05-29 23:14:28 +0200201 if (wp->w_width > maxwidth)
202 wp->w_width = maxwidth;
Bram Moolenaar60cdb302019-05-27 21:54:10 +0200203
204 if (wp->w_height <= 1)
Bram Moolenaar88c4e1f2019-05-29 23:14:28 +0200205 wp->w_height = wp->w_buffer->b_ml.ml_line_count + wrapped;
Bram Moolenaar60cdb302019-05-27 21:54:10 +0200206 if (wp->w_minheight > 0 && wp->w_height < wp->w_minheight)
207 wp->w_height = wp->w_minheight;
208 if (wp->w_maxheight > 0 && wp->w_height > wp->w_maxheight)
209 wp->w_height = wp->w_maxheight;
210 if (wp->w_height > Rows - wp->w_winrow)
211 wp->w_height = Rows - wp->w_winrow;
Bram Moolenaar17146962019-05-30 00:12:11 +0200212
213 wp->w_popup_last_changedtick = CHANGEDTICK(wp->w_buffer);
Bram Moolenaar60cdb302019-05-27 21:54:10 +0200214}
215
216/*
Bram Moolenaar4d784b22019-05-25 19:51:39 +0200217 * popup_create({text}, {options})
218 */
219 void
220f_popup_create(typval_T *argvars, typval_T *rettv)
221{
222 win_T *wp;
223 buf_T *buf;
224 dict_T *d;
225 int nr;
226
227 // Check arguments look OK.
228 if (!(argvars[0].v_type == VAR_STRING
229 && argvars[0].vval.v_string != NULL
230 && STRLEN(argvars[0].vval.v_string) > 0)
231 && !(argvars[0].v_type == VAR_LIST
232 && argvars[0].vval.v_list != NULL
233 && argvars[0].vval.v_list->lv_len > 0))
234 {
235 emsg(_(e_listreq));
236 return;
237 }
238 if (argvars[1].v_type != VAR_DICT || argvars[1].vval.v_dict == NULL)
239 {
240 emsg(_(e_dictreq));
241 return;
242 }
243 d = argvars[1].vval.v_dict;
244
245 // Create the window and buffer.
246 wp = win_alloc_popup_win();
247 if (wp == NULL)
248 return;
249 rettv->vval.v_number = wp->w_id;
250 wp->w_p_wrap = TRUE; // 'wrap' is default on
251
252 buf = buflist_new(NULL, NULL, (linenr_T)0, BLN_NEW|BLN_LISTED|BLN_DUMMY);
253 if (buf == NULL)
254 return;
255 ml_open(buf);
Bram Moolenaarcacc6a52019-05-30 15:22:43 +0200256
257 win_init_popup_win(wp, buf);
258
259 set_local_options_default(wp);
Bram Moolenaar20c023a2019-05-26 21:03:24 +0200260 set_string_option_direct_in_buf(buf, (char_u *)"buftype", -1,
Bram Moolenaar4d784b22019-05-25 19:51:39 +0200261 (char_u *)"popup", OPT_FREE|OPT_LOCAL, 0);
Bram Moolenaar20c023a2019-05-26 21:03:24 +0200262 set_string_option_direct_in_buf(buf, (char_u *)"bufhidden", -1,
Bram Moolenaar4d784b22019-05-25 19:51:39 +0200263 (char_u *)"hide", OPT_FREE|OPT_LOCAL, 0);
Bram Moolenaar4d784b22019-05-25 19:51:39 +0200264 buf->b_p_ul = -1; // no undo
265 buf->b_p_swf = FALSE; // no swap file
266 buf->b_p_bl = FALSE; // unlisted buffer
Bram Moolenaar868b7b62019-05-29 21:44:40 +0200267 buf->b_locked = TRUE;
Bram Moolenaar54fabd42019-05-30 19:03:22 +0200268 // Avoid that 'buftype' is reset when this buffer is entered.
269 buf->b_p_initialized = TRUE;
Bram Moolenaar4d784b22019-05-25 19:51:39 +0200270
Bram Moolenaar4d784b22019-05-25 19:51:39 +0200271 nr = (int)dict_get_number(d, (char_u *)"tab");
272 if (nr == 0)
273 {
274 // popup on current tab
Bram Moolenaar9c27b1c2019-05-26 18:48:13 +0200275 wp->w_next = curtab->tp_first_popupwin;
276 curtab->tp_first_popupwin = wp;
Bram Moolenaar4d784b22019-05-25 19:51:39 +0200277 }
278 else if (nr < 0)
279 {
280 // global popup
281 wp->w_next = first_popupwin;
282 first_popupwin = wp;
283 }
284 else
285 // TODO: find tab page "nr"
286 emsg("Not implemented yet");
287
288 // Add text to the buffer.
289 if (argvars[0].v_type == VAR_STRING)
Bram Moolenaar7a8d0272019-05-26 23:32:06 +0200290 {
Bram Moolenaar4d784b22019-05-25 19:51:39 +0200291 // just a string
292 ml_append_buf(buf, 0, argvars[0].vval.v_string, (colnr_T)0, TRUE);
Bram Moolenaar4d784b22019-05-25 19:51:39 +0200293 }
294 else
Bram Moolenaar7a8d0272019-05-26 23:32:06 +0200295 {
296 list_T *l = argvars[0].vval.v_list;
297
298 if (l->lv_first->li_tv.v_type == VAR_STRING)
299 // list of strings
300 add_popup_strings(buf, l);
301 else
302 // list of dictionaries
303 add_popup_dicts(buf, l);
304 }
Bram Moolenaar4d784b22019-05-25 19:51:39 +0200305
306 // Delete the line of the empty buffer.
307 curbuf = buf;
308 ml_delete(buf->b_ml.ml_line_count, FALSE);
309 curbuf = curwin->w_buffer;
310
311 // Deal with options.
312 apply_options(wp, buf, argvars[1].vval.v_dict);
313
314 // set default values
315 if (wp->w_zindex == 0)
316 wp->w_zindex = 50;
317
Bram Moolenaar60cdb302019-05-27 21:54:10 +0200318 popup_adjust_position(wp);
Bram Moolenaar4d784b22019-05-25 19:51:39 +0200319
320 wp->w_vsep_width = 0;
321
322 redraw_all_later(NOT_VALID);
323}
324
325/*
Bram Moolenaar2cd0dce2019-05-26 22:17:52 +0200326 * Find the popup window with window-ID "id".
327 * If the popup window does not exist NULL is returned.
328 * If the window is not a popup window, and error message is given.
329 */
330 static win_T *
331find_popup_win(int id)
332{
333 win_T *wp = win_id2wp(id);
334
335 if (wp != NULL && !bt_popup(wp->w_buffer))
336 {
337 semsg(_("E993: window %d is not a popup window"), id);
338 return NULL;
339 }
340 return wp;
341}
342
343/*
344 * Return TRUE if there any popups that are not hidden.
345 */
346 int
347popup_any_visible(void)
348{
349 win_T *wp;
350
351 for (wp = first_popupwin; wp != NULL; wp = wp->w_next)
Bram Moolenaarbf0ecb22019-05-27 10:04:40 +0200352 if ((wp->w_popup_flags & POPF_HIDDEN) == 0)
Bram Moolenaar2cd0dce2019-05-26 22:17:52 +0200353 return TRUE;
354 for (wp = curtab->tp_first_popupwin; wp != NULL; wp = wp->w_next)
Bram Moolenaarbf0ecb22019-05-27 10:04:40 +0200355 if ((wp->w_popup_flags & POPF_HIDDEN) == 0)
Bram Moolenaar2cd0dce2019-05-26 22:17:52 +0200356 return TRUE;
357 return FALSE;
358}
359
360/*
Bram Moolenaar4d784b22019-05-25 19:51:39 +0200361 * popup_close({id})
362 */
363 void
364f_popup_close(typval_T *argvars, typval_T *rettv UNUSED)
365{
Bram Moolenaar2cd0dce2019-05-26 22:17:52 +0200366 int id = (int)tv_get_number(argvars);
Bram Moolenaar4d784b22019-05-25 19:51:39 +0200367
Bram Moolenaar2cd0dce2019-05-26 22:17:52 +0200368 popup_close(id);
369}
370
371/*
372 * popup_hide({id})
373 */
374 void
375f_popup_hide(typval_T *argvars, typval_T *rettv UNUSED)
376{
377 int id = (int)tv_get_number(argvars);
378 win_T *wp = find_popup_win(id);
379
Bram Moolenaarbf0ecb22019-05-27 10:04:40 +0200380 if (wp != NULL && (wp->w_popup_flags & POPF_HIDDEN) == 0)
Bram Moolenaar2cd0dce2019-05-26 22:17:52 +0200381 {
Bram Moolenaarbf0ecb22019-05-27 10:04:40 +0200382 wp->w_popup_flags |= POPF_HIDDEN;
Bram Moolenaar2cd0dce2019-05-26 22:17:52 +0200383 redraw_all_later(NOT_VALID);
384 }
385}
386
387/*
388 * popup_show({id})
389 */
390 void
391f_popup_show(typval_T *argvars, typval_T *rettv UNUSED)
392{
393 int id = (int)tv_get_number(argvars);
394 win_T *wp = find_popup_win(id);
395
Bram Moolenaarbf0ecb22019-05-27 10:04:40 +0200396 if (wp != NULL && (wp->w_popup_flags & POPF_HIDDEN) != 0)
Bram Moolenaar2cd0dce2019-05-26 22:17:52 +0200397 {
Bram Moolenaarbf0ecb22019-05-27 10:04:40 +0200398 wp->w_popup_flags &= ~POPF_HIDDEN;
Bram Moolenaar2cd0dce2019-05-26 22:17:52 +0200399 redraw_all_later(NOT_VALID);
400 }
Bram Moolenaar4d784b22019-05-25 19:51:39 +0200401}
402
Bram Moolenaar51fe3b12019-05-26 20:10:06 +0200403 static void
Bram Moolenaar2cd0dce2019-05-26 22:17:52 +0200404popup_free(win_T *wp)
Bram Moolenaar51fe3b12019-05-26 20:10:06 +0200405{
Bram Moolenaar868b7b62019-05-29 21:44:40 +0200406 wp->w_buffer->b_locked = FALSE;
Bram Moolenaar51fe3b12019-05-26 20:10:06 +0200407 if (wp->w_winrow + wp->w_height >= cmdline_row)
408 clear_cmdline = TRUE;
409 win_free_popup(wp);
410 redraw_all_later(NOT_VALID);
411}
412
Bram Moolenaarec583842019-05-26 14:11:23 +0200413/*
414 * Close a popup window by Window-id.
415 */
Bram Moolenaar4d784b22019-05-25 19:51:39 +0200416 void
Bram Moolenaarec583842019-05-26 14:11:23 +0200417popup_close(int id)
Bram Moolenaar4d784b22019-05-25 19:51:39 +0200418{
419 win_T *wp;
Bram Moolenaarec583842019-05-26 14:11:23 +0200420 tabpage_T *tp;
Bram Moolenaar4d784b22019-05-25 19:51:39 +0200421 win_T *prev = NULL;
422
Bram Moolenaarec583842019-05-26 14:11:23 +0200423 // go through global popups
Bram Moolenaar4d784b22019-05-25 19:51:39 +0200424 for (wp = first_popupwin; wp != NULL; prev = wp, wp = wp->w_next)
Bram Moolenaarec583842019-05-26 14:11:23 +0200425 if (wp->w_id == id)
Bram Moolenaar4d784b22019-05-25 19:51:39 +0200426 {
427 if (prev == NULL)
428 first_popupwin = wp->w_next;
429 else
430 prev->w_next = wp->w_next;
Bram Moolenaar2cd0dce2019-05-26 22:17:52 +0200431 popup_free(wp);
Bram Moolenaarec583842019-05-26 14:11:23 +0200432 return;
Bram Moolenaar4d784b22019-05-25 19:51:39 +0200433 }
434
Bram Moolenaarec583842019-05-26 14:11:23 +0200435 // go through tab-local popups
436 FOR_ALL_TABPAGES(tp)
437 popup_close_tabpage(tp, id);
438}
439
440/*
441 * Close a popup window with Window-id "id" in tabpage "tp".
442 */
443 void
444popup_close_tabpage(tabpage_T *tp, int id)
445{
446 win_T *wp;
Bram Moolenaar9c27b1c2019-05-26 18:48:13 +0200447 win_T **root = &tp->tp_first_popupwin;
Bram Moolenaarec583842019-05-26 14:11:23 +0200448 win_T *prev = NULL;
449
Bram Moolenaarec583842019-05-26 14:11:23 +0200450 for (wp = *root; wp != NULL; prev = wp, wp = wp->w_next)
451 if (wp->w_id == id)
452 {
453 if (prev == NULL)
454 *root = wp->w_next;
455 else
456 prev->w_next = wp->w_next;
Bram Moolenaar2cd0dce2019-05-26 22:17:52 +0200457 popup_free(wp);
Bram Moolenaarec583842019-05-26 14:11:23 +0200458 return;
459 }
Bram Moolenaar4d784b22019-05-25 19:51:39 +0200460}
461
462 void
463close_all_popups(void)
464{
465 while (first_popupwin != NULL)
466 popup_close(first_popupwin->w_id);
Bram Moolenaar9c27b1c2019-05-26 18:48:13 +0200467 while (curtab->tp_first_popupwin != NULL)
468 popup_close(curtab->tp_first_popupwin->w_id);
Bram Moolenaar4d784b22019-05-25 19:51:39 +0200469}
470
471 void
472ex_popupclear(exarg_T *eap UNUSED)
473{
474 close_all_popups();
475}
476
Bram Moolenaar60cdb302019-05-27 21:54:10 +0200477/*
478 * popup_move({id}, {options})
479 */
480 void
481f_popup_move(typval_T *argvars, typval_T *rettv UNUSED)
482{
483 dict_T *d;
484 int nr;
485 int id = (int)tv_get_number(argvars);
486 win_T *wp = find_popup_win(id);
487
488 if (wp == NULL)
489 return; // invalid {id}
490
491 if (argvars[1].v_type != VAR_DICT || argvars[1].vval.v_dict == NULL)
492 {
493 emsg(_(e_dictreq));
494 return;
495 }
496 d = argvars[1].vval.v_dict;
497
498 if ((nr = dict_get_number(d, (char_u *)"minwidth")) > 0)
499 wp->w_minwidth = nr;
500 if ((nr = dict_get_number(d, (char_u *)"minheight")) > 0)
501 wp->w_minheight = nr;
502 if ((nr = dict_get_number(d, (char_u *)"maxwidth")) > 0)
503 wp->w_maxwidth = nr;
504 if ((nr = dict_get_number(d, (char_u *)"maxheight")) > 0)
505 wp->w_maxheight = nr;
506 if ((nr = dict_get_number(d, (char_u *)"line")) > 0)
507 wp->w_wantline = nr;
508 if ((nr = dict_get_number(d, (char_u *)"col")) > 0)
509 wp->w_wantcol = nr;
510 // TODO: "pos"
511
512 if (wp->w_winrow + wp->w_height >= cmdline_row)
513 clear_cmdline = TRUE;
514 popup_adjust_position(wp);
515 redraw_all_later(NOT_VALID);
516}
517
Bram Moolenaarbc133542019-05-29 20:26:46 +0200518/*
519 * popup_getposition({id})
520 */
521 void
522f_popup_getposition(typval_T *argvars, typval_T *rettv)
523{
524 dict_T *dict;
525 int id = (int)tv_get_number(argvars);
526 win_T *wp = find_popup_win(id);
527
528 if (rettv_dict_alloc(rettv) == OK)
529 {
530 if (wp == NULL)
531 return; // invalid {id}
532 dict = rettv->vval.v_dict;
533 dict_add_number(dict, "line", wp->w_winrow + 1);
534 dict_add_number(dict, "col", wp->w_wincol + 1);
535 dict_add_number(dict, "width", wp->w_width);
536 dict_add_number(dict, "height", wp->w_height);
Bram Moolenaar8c2a6002019-05-30 14:29:45 +0200537 dict_add_number(dict, "visible",
538 (wp->w_popup_flags & POPF_HIDDEN) == 0);
539 }
540}
541
542/*
543 * f_popup_getoptions({id})
544 */
545 void
546f_popup_getoptions(typval_T *argvars, typval_T *rettv)
547{
548 dict_T *dict;
549 int id = (int)tv_get_number(argvars);
550 win_T *wp = find_popup_win(id);
551
552 if (rettv_dict_alloc(rettv) == OK)
553 {
554 if (wp == NULL)
555 return;
556
557 dict = rettv->vval.v_dict;
558 dict_add_number(dict, "line", wp->w_wantline);
559 dict_add_number(dict, "col", wp->w_wantcol);
560 dict_add_number(dict, "minwidth", wp->w_minwidth);
561 dict_add_number(dict, "minheight", wp->w_minheight);
562 dict_add_number(dict, "maxheight", wp->w_maxheight);
563 dict_add_number(dict, "maxwidth", wp->w_maxwidth);
564 dict_add_number(dict, "zindex", wp->w_zindex);
565# if defined(FEAT_TIMERS)
566 dict_add_number(dict, "time", wp->w_popup_timer != NULL
567 ? (long)wp->w_popup_timer->tr_interval : 0L);
568# endif
Bram Moolenaarbc133542019-05-29 20:26:46 +0200569 }
570}
Bram Moolenaar4d784b22019-05-25 19:51:39 +0200571#endif // FEAT_TEXT_PROP