patch 8.1.1422: popup_getoptions() not implemented yet
Problem: Popup_getoptions() not implemented yet. Solution: Implement it. (closes #4452)
This commit is contained in:
@ -86,15 +86,18 @@ Probably 2. is the best choice.
|
|||||||
IMPLEMENTATION:
|
IMPLEMENTATION:
|
||||||
- Code is in popupwin.c
|
- Code is in popupwin.c
|
||||||
- when creating the window set options to Vim default? (verify with 'number')
|
- when creating the window set options to Vim default? (verify with 'number')
|
||||||
- Do not show tilde below last line.
|
|
||||||
- Implement filter.
|
- Implement filter.
|
||||||
Check that popup_close() works in the filter.
|
Check that popup_close() works in the filter.
|
||||||
|
- Implement the "pos" option.
|
||||||
- Handle screen resize in screenalloc().
|
- Handle screen resize in screenalloc().
|
||||||
- Make redrawing more efficient and avoid flicker.
|
- Make redrawing more efficient and avoid flicker.
|
||||||
|
Store popup info in a mask, use the mask in screen_line()
|
||||||
Fix redrawing problem with completion.
|
Fix redrawing problem with completion.
|
||||||
Fix redrawing problem when scrolling non-current window
|
Fix redrawing problem when scrolling non-current window
|
||||||
Fix redrawing the statusline on top of a popup
|
Fix redrawing the statusline on top of a popup
|
||||||
- Properly figure out the size and position.
|
- Figure out the size and position better.
|
||||||
|
if wrapping splits a double-wide character
|
||||||
|
if wrapping has an indent
|
||||||
- Can the buffer be re-used, to avoid using up lots of buffer numbers?
|
- Can the buffer be re-used, to avoid using up lots of buffer numbers?
|
||||||
- Implement all the unimplemented options and features.
|
- Implement all the unimplemented options and features.
|
||||||
|
|
||||||
@ -228,16 +231,23 @@ popup_setoptions({id}, {options}) *popup_setoptions()*
|
|||||||
|
|
||||||
|
|
||||||
popup_getoptions({id}) *popup_getoptions()*
|
popup_getoptions({id}) *popup_getoptions()*
|
||||||
{not implemented yet}
|
Return the {options} for popup {id} in a Dict.
|
||||||
Return the {options} for popup {id}.
|
A zero value means the option was not set.
|
||||||
|
|
||||||
|
The "highlight" entry is omitted, use the 'wincolor' option
|
||||||
|
for that: >
|
||||||
|
let hl = getwinvar(winid, '&wincolor')
|
||||||
|
|
||||||
|
< If popup window {id} is not found an empty Dict is returned.
|
||||||
|
|
||||||
popup_getposition({id}) *popup_getposition()*
|
popup_getposition({id}) *popup_getposition()*
|
||||||
Return the position and size of popup {id}. Returns a Dict
|
Return the position and size of popup {id}. Returns a Dict
|
||||||
with these entries:
|
with these entries:
|
||||||
col screen column of the popup, one-based
|
col screen column of the popup, one-based
|
||||||
line screen line of the popup, one-based
|
line screen line of the popup, one-based
|
||||||
width width of the popup in screen cells
|
width width of the popup in screen cells
|
||||||
height height of the popup in screen cells
|
height height of the popup in screen cells
|
||||||
|
visible one if the popup is displayed, zero if hidden
|
||||||
Note that these are the actual screen positions. They differ
|
Note that these are the actual screen positions. They differ
|
||||||
from the values in `popup_getoptions()` for the sizing and
|
from the values in `popup_getoptions()` for the sizing and
|
||||||
positioning mechanism applied.
|
positioning mechanism applied.
|
||||||
@ -304,9 +314,9 @@ The second argument of |popup_create()| is a dictionary with options:
|
|||||||
{only number is implemented}
|
{only number is implemented}
|
||||||
pos "topleft", "topright", "botleft" or "botright":
|
pos "topleft", "topright", "botleft" or "botright":
|
||||||
defines what corner of the popup "line" and "col" are
|
defines what corner of the popup "line" and "col" are
|
||||||
used for. Default is "botleft". Alternatively
|
used for. When not set "topleft" is used.
|
||||||
"center" can be used to position the popup in the
|
Alternatively "center" can be used to position the
|
||||||
center of the Vim window.
|
popup in the center of the Vim window.
|
||||||
{not implemented yet}
|
{not implemented yet}
|
||||||
flip when TRUE (the default) and the position is relative
|
flip when TRUE (the default) and the position is relative
|
||||||
to the cursor, flip to below or above the cursor to
|
to the cursor, flip to below or above the cursor to
|
||||||
|
|||||||
@ -811,6 +811,7 @@ static struct fst
|
|||||||
#ifdef FEAT_TEXT_PROP
|
#ifdef FEAT_TEXT_PROP
|
||||||
{"popup_close", 1, 1, f_popup_close},
|
{"popup_close", 1, 1, f_popup_close},
|
||||||
{"popup_create", 2, 2, f_popup_create},
|
{"popup_create", 2, 2, f_popup_create},
|
||||||
|
{"popup_getoptions", 1, 1, f_popup_getoptions},
|
||||||
{"popup_getposition", 1, 1, f_popup_getposition},
|
{"popup_getposition", 1, 1, f_popup_getposition},
|
||||||
{"popup_hide", 1, 1, f_popup_hide},
|
{"popup_hide", 1, 1, f_popup_hide},
|
||||||
{"popup_move", 2, 2, f_popup_move},
|
{"popup_move", 2, 2, f_popup_move},
|
||||||
|
|||||||
@ -530,6 +530,38 @@ f_popup_getposition(typval_T *argvars, typval_T *rettv)
|
|||||||
dict_add_number(dict, "col", wp->w_wincol + 1);
|
dict_add_number(dict, "col", wp->w_wincol + 1);
|
||||||
dict_add_number(dict, "width", wp->w_width);
|
dict_add_number(dict, "width", wp->w_width);
|
||||||
dict_add_number(dict, "height", wp->w_height);
|
dict_add_number(dict, "height", wp->w_height);
|
||||||
|
dict_add_number(dict, "visible",
|
||||||
|
(wp->w_popup_flags & POPF_HIDDEN) == 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* f_popup_getoptions({id})
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
f_popup_getoptions(typval_T *argvars, typval_T *rettv)
|
||||||
|
{
|
||||||
|
dict_T *dict;
|
||||||
|
int id = (int)tv_get_number(argvars);
|
||||||
|
win_T *wp = find_popup_win(id);
|
||||||
|
|
||||||
|
if (rettv_dict_alloc(rettv) == OK)
|
||||||
|
{
|
||||||
|
if (wp == NULL)
|
||||||
|
return;
|
||||||
|
|
||||||
|
dict = rettv->vval.v_dict;
|
||||||
|
dict_add_number(dict, "line", wp->w_wantline);
|
||||||
|
dict_add_number(dict, "col", wp->w_wantcol);
|
||||||
|
dict_add_number(dict, "minwidth", wp->w_minwidth);
|
||||||
|
dict_add_number(dict, "minheight", wp->w_minheight);
|
||||||
|
dict_add_number(dict, "maxheight", wp->w_maxheight);
|
||||||
|
dict_add_number(dict, "maxwidth", wp->w_maxwidth);
|
||||||
|
dict_add_number(dict, "zindex", wp->w_zindex);
|
||||||
|
# if defined(FEAT_TIMERS)
|
||||||
|
dict_add_number(dict, "time", wp->w_popup_timer != NULL
|
||||||
|
? (long)wp->w_popup_timer->tr_interval : 0L);
|
||||||
|
# endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif // FEAT_TEXT_PROP
|
#endif // FEAT_TEXT_PROP
|
||||||
|
|||||||
@ -10,5 +10,6 @@ void popup_close_tabpage(tabpage_T *tp, int id);
|
|||||||
void close_all_popups(void);
|
void close_all_popups(void);
|
||||||
void ex_popupclear(exarg_T *eap);
|
void ex_popupclear(exarg_T *eap);
|
||||||
void f_popup_move(typval_T *argvars, typval_T *rettv);
|
void f_popup_move(typval_T *argvars, typval_T *rettv);
|
||||||
|
void f_popup_getoptions(typval_T *argvars, typval_T *rettv);
|
||||||
void f_popup_getposition(typval_T *argvars, typval_T *rettv);
|
void f_popup_getposition(typval_T *argvars, typval_T *rettv);
|
||||||
/* vim: set ft=c : */
|
/* vim: set ft=c : */
|
||||||
|
|||||||
@ -108,16 +108,19 @@ func Test_popup_hide()
|
|||||||
redraw
|
redraw
|
||||||
let line = join(map(range(1, 5), 'screenstring(1, v:val)'), '')
|
let line = join(map(range(1, 5), 'screenstring(1, v:val)'), '')
|
||||||
call assert_equal('world', line)
|
call assert_equal('world', line)
|
||||||
|
call assert_equal(1, popup_getposition(winid).visible)
|
||||||
|
|
||||||
call popup_hide(winid)
|
call popup_hide(winid)
|
||||||
redraw
|
redraw
|
||||||
let line = join(map(range(1, 5), 'screenstring(1, v:val)'), '')
|
let line = join(map(range(1, 5), 'screenstring(1, v:val)'), '')
|
||||||
call assert_equal('hello', line)
|
call assert_equal('hello', line)
|
||||||
|
call assert_equal(0, popup_getposition(winid).visible)
|
||||||
|
|
||||||
call popup_show(winid)
|
call popup_show(winid)
|
||||||
redraw
|
redraw
|
||||||
let line = join(map(range(1, 5), 'screenstring(1, v:val)'), '')
|
let line = join(map(range(1, 5), 'screenstring(1, v:val)'), '')
|
||||||
call assert_equal('world', line)
|
call assert_equal('world', line)
|
||||||
|
call assert_equal(1, popup_getposition(winid).visible)
|
||||||
|
|
||||||
|
|
||||||
call popup_close(winid)
|
call popup_close(winid)
|
||||||
@ -178,6 +181,7 @@ func Test_popup_getposition()
|
|||||||
call assert_equal(3, res.col)
|
call assert_equal(3, res.col)
|
||||||
call assert_equal(10, res.width)
|
call assert_equal(10, res.width)
|
||||||
call assert_equal(11, res.height)
|
call assert_equal(11, res.height)
|
||||||
|
call assert_equal(1, res.visible)
|
||||||
|
|
||||||
call popup_close(winid)
|
call popup_close(winid)
|
||||||
endfunc
|
endfunc
|
||||||
@ -215,5 +219,48 @@ func Test_popup_wraps()
|
|||||||
call assert_equal(test[2], position.height)
|
call assert_equal(test[2], position.height)
|
||||||
|
|
||||||
call popup_close(winid)
|
call popup_close(winid)
|
||||||
|
call assert_equal({}, popup_getposition(winid))
|
||||||
endfor
|
endfor
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
|
func Test_popup_getoptions()
|
||||||
|
let winid = popup_create('hello', {
|
||||||
|
\ 'line': 2,
|
||||||
|
\ 'col': 3,
|
||||||
|
\ 'minwidth': 10,
|
||||||
|
\ 'minheight': 11,
|
||||||
|
\ 'maxwidth': 20,
|
||||||
|
\ 'maxheight': 21,
|
||||||
|
\ 'zindex': 100,
|
||||||
|
\ 'time': 5000,
|
||||||
|
\})
|
||||||
|
redraw
|
||||||
|
let res = popup_getoptions(winid)
|
||||||
|
call assert_equal(2, res.line)
|
||||||
|
call assert_equal(3, res.col)
|
||||||
|
call assert_equal(10, res.minwidth)
|
||||||
|
call assert_equal(11, res.minheight)
|
||||||
|
call assert_equal(20, res.maxwidth)
|
||||||
|
call assert_equal(21, res.maxheight)
|
||||||
|
call assert_equal(100, res.zindex)
|
||||||
|
if has('timers')
|
||||||
|
call assert_equal(5000, res.time)
|
||||||
|
endif
|
||||||
|
call popup_close(winid)
|
||||||
|
|
||||||
|
let winid = popup_create('hello', {})
|
||||||
|
redraw
|
||||||
|
let res = popup_getoptions(winid)
|
||||||
|
call assert_equal(0, res.line)
|
||||||
|
call assert_equal(0, res.col)
|
||||||
|
call assert_equal(0, res.minwidth)
|
||||||
|
call assert_equal(0, res.minheight)
|
||||||
|
call assert_equal(0, res.maxwidth)
|
||||||
|
call assert_equal(0, res.maxheight)
|
||||||
|
call assert_equal(50, res.zindex)
|
||||||
|
if has('timers')
|
||||||
|
call assert_equal(0, res.time)
|
||||||
|
endif
|
||||||
|
call popup_close(winid)
|
||||||
|
call assert_equal({}, popup_getoptions(winid))
|
||||||
|
endfunc
|
||||||
|
|||||||
@ -767,6 +767,8 @@ static char *(features[]) =
|
|||||||
|
|
||||||
static int included_patches[] =
|
static int included_patches[] =
|
||||||
{ /* Add new patch number below this line */
|
{ /* Add new patch number below this line */
|
||||||
|
/**/
|
||||||
|
1422,
|
||||||
/**/
|
/**/
|
||||||
1421,
|
1421,
|
||||||
/**/
|
/**/
|
||||||
|
|||||||
Reference in New Issue
Block a user