Skip to content

Commit c7c5f10

Browse files
committed
patch 8.1.1905: cannot set all properties of the info popup
Problem: Cannot set all properties of the info popup. Solution: Add popup_findinfo(). Rename popup_getpreview() to popup_findpreview().
1 parent 258cef5 commit c7c5f10

File tree

10 files changed

+87
-28
lines changed

10 files changed

+87
-28
lines changed

runtime/doc/popup.txt

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -289,6 +289,20 @@ popup_filter_yesno({id}, {key}) *popup_filter_yesno()*
289289
See the example here: |popup_dialog-example|
290290

291291

292+
popup_findinfo() *popup_findinfo()*
293+
Get the |window-ID| for the popup info window, as it used by
294+
the popup menu. See |complete-popup|. The info popup is
295+
hidden when not used, it can be deleted with |popup_clear()|
296+
and |popup_close()|.
297+
Return zero if there is none.
298+
299+
300+
popup_findpreview() *popup_findpreview()*
301+
Get the |window-ID| for the popup preview window.
302+
Return zero if there is none.
303+
304+
305+
292306
popup_getoptions({id}) *popup_getoptions()*
293307
Return the {options} for popup {id} in a Dict.
294308
A zero value means the option was not set. For "zindex" the
@@ -336,10 +350,6 @@ popup_getpos({id}) *popup_getpos()*
336350

337351
If popup window {id} is not found an empty Dict is returned.
338352

339-
popup_getpreview() *popup_getpreview()*
340-
Get the |window-ID| for the popup preview window.
341-
Return zero if there is none.
342-
343353

344354
popup_hide({id}) *popup_hide()*
345355
If {id} is a displayed popup, hide it now. If the popup has a

src/evalfunc.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -702,9 +702,10 @@ static funcentry_T global_functions[] =
702702
{"popup_dialog", 2, 2, 0, f_popup_dialog},
703703
{"popup_filter_menu", 2, 2, 0, f_popup_filter_menu},
704704
{"popup_filter_yesno", 2, 2, 0, f_popup_filter_yesno},
705+
{"popup_findinfo", 0, 0, 0, f_popup_findinfo},
706+
{"popup_findpreview", 0, 0, 0, f_popup_findpreview},
705707
{"popup_getoptions", 1, 1, 0, f_popup_getoptions},
706708
{"popup_getpos", 1, 1, 0, f_popup_getpos},
707-
{"popup_getpreview", 0, 0, 0, f_popup_getpreview},
708709
{"popup_hide", 1, 1, 0, f_popup_hide},
709710
{"popup_locate", 2, 2, 0, f_popup_locate},
710711
{"popup_menu", 2, 2, 0, f_popup_menu},

src/ex_cmds.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5154,7 +5154,8 @@ prepare_tagpreview(
51545154
else if (use_popup)
51555155
{
51565156
wp = popup_find_info_window();
5157-
// TODO: set position
5157+
if (wp != NULL)
5158+
popup_show(wp);
51585159
}
51595160
else
51605161
# endif

src/ex_docmd.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5808,7 +5808,7 @@ ex_pclose(exarg_T *eap)
58085808
}
58095809
# ifdef FEAT_TEXT_PROP
58105810
// Also when 'previewpopup' is empty, it might have been cleared.
5811-
popup_close_preview(FALSE);
5811+
popup_close_preview();
58125812
# endif
58135813
}
58145814
#endif

src/popupmnu.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -923,8 +923,8 @@ pum_set_selected(int n, int repeat UNUSED)
923923
}
924924
#if defined(FEAT_TEXT_PROP) && defined(FEAT_QUICKFIX)
925925
if (!has_info)
926-
// close any popup info window
927-
popup_close_preview(TRUE);
926+
// hide any popup info window
927+
popup_hide_info();
928928
#endif
929929

930930
if (!resized)
@@ -944,8 +944,8 @@ pum_undisplay(void)
944944
redraw_tabline = TRUE;
945945
status_redraw_all();
946946
#if defined(FEAT_TEXT_PROP) && defined(FEAT_QUICKFIX)
947-
// close any popup info window
948-
popup_close_preview(TRUE);
947+
// hide any popup info window
948+
popup_hide_info();
949949
#endif
950950
}
951951

src/popupwin.c

Lines changed: 50 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2058,6 +2058,18 @@ f_popup_close(typval_T *argvars, typval_T *rettv UNUSED)
20582058
popup_close_and_callback(wp, &argvars[1]);
20592059
}
20602060

2061+
static void
2062+
popup_hide(win_T *wp)
2063+
{
2064+
if ((wp->w_popup_flags & POPF_HIDDEN) == 0)
2065+
{
2066+
wp->w_popup_flags |= POPF_HIDDEN;
2067+
--wp->w_buffer->b_nwindows;
2068+
redraw_all_later(NOT_VALID);
2069+
popup_mask_refresh = TRUE;
2070+
}
2071+
}
2072+
20612073
/*
20622074
* popup_hide({id})
20632075
*/
@@ -2067,10 +2079,17 @@ f_popup_hide(typval_T *argvars, typval_T *rettv UNUSED)
20672079
int id = (int)tv_get_number(argvars);
20682080
win_T *wp = find_popup_win(id);
20692081

2070-
if (wp != NULL && (wp->w_popup_flags & POPF_HIDDEN) == 0)
2082+
if (wp != NULL)
2083+
popup_hide(wp);
2084+
}
2085+
2086+
void
2087+
popup_show(win_T *wp)
2088+
{
2089+
if ((wp->w_popup_flags & POPF_HIDDEN) != 0)
20712090
{
2072-
wp->w_popup_flags |= POPF_HIDDEN;
2073-
--wp->w_buffer->b_nwindows;
2091+
wp->w_popup_flags &= ~POPF_HIDDEN;
2092+
++wp->w_buffer->b_nwindows;
20742093
redraw_all_later(NOT_VALID);
20752094
popup_mask_refresh = TRUE;
20762095
}
@@ -2085,13 +2104,8 @@ f_popup_show(typval_T *argvars, typval_T *rettv UNUSED)
20852104
int id = (int)tv_get_number(argvars);
20862105
win_T *wp = find_popup_win(id);
20872106

2088-
if (wp != NULL && (wp->w_popup_flags & POPF_HIDDEN) != 0)
2089-
{
2090-
wp->w_popup_flags &= ~POPF_HIDDEN;
2091-
++wp->w_buffer->b_nwindows;
2092-
redraw_all_later(NOT_VALID);
2093-
popup_mask_refresh = TRUE;
2094-
}
2107+
if (wp != NULL)
2108+
popup_show(wp);
20952109
}
20962110

20972111
/*
@@ -3314,7 +3328,15 @@ popup_find_info_window(void)
33143328
#endif
33153329

33163330
void
3317-
f_popup_getpreview(typval_T *argvars UNUSED, typval_T *rettv)
3331+
f_popup_findinfo(typval_T *argvars UNUSED, typval_T *rettv)
3332+
{
3333+
win_T *wp = popup_find_info_window();
3334+
3335+
rettv->vval.v_number = wp == NULL ? 0 : wp->w_id;
3336+
}
3337+
3338+
void
3339+
f_popup_findpreview(typval_T *argvars UNUSED, typval_T *rettv)
33183340
{
33193341
win_T *wp = popup_find_preview_window();
33203342

@@ -3355,10 +3377,13 @@ popup_create_preview_window(int info)
33553377
}
33563378

33573379
#if defined(FEAT_QUICKFIX) || defined(PROTO)
3380+
/*
3381+
* Close any preview popup.
3382+
*/
33583383
void
3359-
popup_close_preview(int info)
3384+
popup_close_preview(void)
33603385
{
3361-
win_T *wp = info ? popup_find_info_window() : popup_find_preview_window();
3386+
win_T *wp = popup_find_preview_window();
33623387

33633388
if (wp != NULL)
33643389
{
@@ -3369,6 +3394,18 @@ popup_close_preview(int info)
33693394
popup_close_and_callback(wp, &res);
33703395
}
33713396
}
3397+
3398+
/*
3399+
* Hide the info popup.
3400+
*/
3401+
void
3402+
popup_hide_info(void)
3403+
{
3404+
win_T *wp = popup_find_info_window();
3405+
3406+
if (wp != NULL)
3407+
popup_hide(wp);
3408+
}
33723409
#endif
33733410

33743411
/*

src/proto/popupwin.pro

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ void f_popup_menu(typval_T *argvars, typval_T *rettv);
2727
void f_popup_notification(typval_T *argvars, typval_T *rettv);
2828
void f_popup_close(typval_T *argvars, typval_T *rettv);
2929
void f_popup_hide(typval_T *argvars, typval_T *rettv);
30+
void popup_show(win_T *wp);
3031
void f_popup_show(typval_T *argvars, typval_T *rettv);
3132
void f_popup_settext(typval_T *argvars, typval_T *rettv);
3233
void popup_close(int id);
@@ -49,9 +50,11 @@ int set_ref_in_popups(int copyID);
4950
win_T *popup_find_preview_window(void);
5051
int popup_is_popup(win_T *wp);
5152
win_T *popup_find_info_window(void);
52-
void f_popup_getpreview(typval_T *argvars, typval_T *rettv);
53+
void f_popup_findinfo(typval_T *argvars, typval_T *rettv);
54+
void f_popup_findpreview(typval_T *argvars, typval_T *rettv);
5355
int popup_create_preview_window(int info);
54-
void popup_close_preview(int info);
56+
void popup_close_preview(void);
57+
void popup_hide_info(void);
5558
void popup_set_title(win_T *wp);
5659
void popup_update_preview_title(void);
5760
/* vim: set ft=c : */

src/testdir/dumps/Test_popupwin_infopopup_align_3.dump

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
|x| @7| +0#0000001#e0e0e08|w|r|d| @4|W| |e|x|t|r|a| |t|e|x|t| | +0#0000000#ffffff0@43
99
|x| @7| +0#0000001#ffd7ff255|a|n|o|t|w|r|d| |W| |e|x|t|r|a| |t|e|x|t| | +0#0000000#ffffff0@43
1010
|x| @7| +0#0000001#ffd7ff255|n|o|a|w|r|d| @1|W| |e|x|t|r|a| |t|e|x|t| | +0#0000000#ffffff0@43
11-
|x| @7| +0#0000001#ffd7ff255|t|h|a|t|w|r|d| |W| |e|x|t|r|a| |t|e|x|t| | +0&#e0e0e08|w|o|r|d|s| |a|r|e| |c|o@1|l| | +0#0000000#ffffff0@27
11+
|x| @7| +0#0000001#ffd7ff255|t|h|a|t|w|r|d| |W| |e|x|t|r|a| |t|e|x|t| | +0#0000000#ffff4012|w|o|r|d|s| |a|r|e| |c|o@1|l| | +0&#ffffff0@27
1212
|t|e|s|t| |t|e|x|t| |a|w|o|r|d> @59
1313
|~+0#4040ff13&| @73
1414
|-+2#0000000&@1| |U|s|e|r| |d|e|f|i|n|e|d| |c|o|m|p|l|e|t|i|o|n| |(|^|U|^|N|^|P|)| |m+0#00e0003&|a|t|c|h| |1| |o|f| |4| +0#0000000&@26

src/testdir/test_popupwin.vim

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2162,7 +2162,7 @@ func Test_previewpopup()
21622162
call term_sendkeys(buf, "/another\<CR>\<C-W>}")
21632163
call VerifyScreenDump(buf, 'Test_popupwin_previewpopup_2', {})
21642164

2165-
call term_sendkeys(buf, ":call popup_move(popup_getpreview(), #{col: 15})\<CR>")
2165+
call term_sendkeys(buf, ":call popup_move(popup_findpreview(), #{col: 15})\<CR>")
21662166
call term_sendkeys(buf, ":\<CR>")
21672167
call VerifyScreenDump(buf, 'Test_popupwin_previewpopup_3', {})
21682168

@@ -2245,6 +2245,10 @@ func Get_popupmenu_lines()
22452245
\ }
22462246
endfunc
22472247
call setline(1, 'text text text text text text text ')
2248+
func ChangeColor()
2249+
let id = popup_findinfo()
2250+
call popup_setoptions(id, #{highlight: 'InfoPopup'})
2251+
endfunc
22482252
END
22492253
return lines
22502254
endfunc
@@ -2313,6 +2317,7 @@ func Test_popupmenu_info_align_menu()
23132317
call VerifyScreenDump(buf, 'Test_popupwin_infopopup_align_2', {})
23142318

23152319
call term_sendkeys(buf, "\<Esc>")
2320+
call term_sendkeys(buf, ":call ChangeColor()\<CR>")
23162321
call term_sendkeys(buf, ":call setline(2, ['x']->repeat(10))\<CR>")
23172322
call term_sendkeys(buf, "Gotest text test text\<C-X>\<C-U>")
23182323
call VerifyScreenDump(buf, 'Test_popupwin_infopopup_align_3', {})

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -761,6 +761,8 @@ static char *(features[]) =
761761

762762
static int included_patches[] =
763763
{ /* Add new patch number below this line */
764+
/**/
765+
1905,
764766
/**/
765767
1904,
766768
/**/

0 commit comments

Comments
 (0)