Skip to content

Commit ae94315

Browse files
committed
patch 8.1.1561: popup_setoptions() is not implemented yet
Problem: Popup_setoptions() is not implemented yet. Solution: Implement popup_setoptions(). Also add more fields to popup_getoptions().
1 parent 6313c4f commit ae94315

File tree

9 files changed

+363
-88
lines changed

9 files changed

+363
-88
lines changed

runtime/doc/popup.txt

+37-9
Original file line numberDiff line numberDiff line change
@@ -109,8 +109,6 @@ TODO:
109109
- When the lines do not fit show a scrollbar (like in the popup menu).
110110
Use the mouse wheel for scrolling.
111111
- Implement:
112-
popup_setoptions({id}, {options})
113-
hidden option
114112
tabpage option with number
115113
flip option
116114
transparent text property
@@ -247,11 +245,15 @@ popup_getoptions({id}) *popup_getoptions()*
247245
A zero value means the option was not set. For "zindex" the
248246
default value is returned, not zero.
249247

250-
The "highlight" entry is omitted, use the 'wincolor' option
251-
for that: >
252-
let hl = getwinvar(winid, '&wincolor')
248+
The "moved" entry is a list with minimum and maximum column,
249+
[0, 0] when not set.
253250

254-
< If popup window {id} is not found an empty Dict is returned.
251+
"border" and "padding" are not included when all values are
252+
zero. When all values are one then an empty list is included.
253+
254+
"borderhighlight" is not included when all values are empty.
255+
256+
If popup window {id} is not found an empty Dict is returned.
255257

256258

257259
popup_getpos({id}) *popup_getpos()*
@@ -307,9 +309,17 @@ popup_menu({text}, {options}) *popup_menu()*
307309
popup_move({id}, {options}) *popup_move()*
308310
Move popup {id} to the position specified with {options}.
309311
{options} may contain the items from |popup_create()| that
310-
specify the popup position: "line", "col", "pos", "maxheight",
311-
"minheight", "maxwidth" and "minwidth".
312+
specify the popup position:
313+
line
314+
col
315+
pos
316+
maxheight
317+
minheight
318+
maxwidth
319+
minwidth
320+
fixed
312321
For {id} see `popup_hide()`.
322+
For other options see |popup_setoptions()|.
313323

314324

315325
popup_notification({text}, {options}) *popup_notification()*
@@ -341,8 +351,26 @@ popup_show({id}) *popup_show()*
341351

342352

343353
popup_setoptions({id}, {options}) *popup_setoptions()*
344-
{not implemented yet}
345354
Override options in popup {id} with entries in {options}.
355+
These options can be set:
356+
flip
357+
firstline
358+
title
359+
wrap
360+
drag
361+
highlight
362+
padding
363+
border
364+
borderhighlight
365+
borderchars
366+
zindex
367+
time
368+
moved
369+
filter
370+
callback
371+
The options from |popup_move()| can also be used.
372+
For "hidden" use |popup_hide()| and |popup_show()|.
373+
"tabpage" cannot be changed.
346374

347375
popup_settext({id}, {text}) *popup_settext()*
348376
Set the text of the buffer in poup win {id}. {text} is the

src/dict.c

+21
Original file line numberDiff line numberDiff line change
@@ -447,6 +447,27 @@ dict_add_list(dict_T *d, char *key, list_T *list)
447447
return OK;
448448
}
449449

450+
/*
451+
* Add a callback to dictionary "d".
452+
* Returns FAIL when out of memory and when key already exists.
453+
*/
454+
int
455+
dict_add_callback(dict_T *d, char *key, callback_T *cb)
456+
{
457+
dictitem_T *item;
458+
459+
item = dictitem_alloc((char_u *)key);
460+
if (item == NULL)
461+
return FAIL;
462+
put_callback(cb, &item->di_tv);
463+
if (dict_add(d, item) == FAIL)
464+
{
465+
dictitem_free(item);
466+
return FAIL;
467+
}
468+
return OK;
469+
}
470+
450471
/*
451472
* Initializes "iter" for iterating over dictionary items with
452473
* dict_iterate_next().

src/evalfunc.c

+1
Original file line numberDiff line numberDiff line change
@@ -824,6 +824,7 @@ static struct fst
824824
{"popup_menu", 2, 2, f_popup_menu},
825825
{"popup_move", 2, 2, f_popup_move},
826826
{"popup_notification", 2, 2, f_popup_notification},
827+
{"popup_setoptions", 2, 2, f_popup_setoptions},
827828
{"popup_settext", 2, 2, f_popup_settext},
828829
{"popup_show", 1, 1, f_popup_show},
829830
#endif

0 commit comments

Comments
 (0)