Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions runtime/doc/popup.txt
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,11 @@ A popup window can be used for such things as:
The text in the popup window can be colored with |text-properties|. It is
also possible to use syntax highlighting.

The default color used is "Pmenu". If you prefer something else use the
"highlight" argument or the 'wincolor' option, e.g.: >
The default colors are taken from |hl-Popup| (body), |hl-PopupBorder|
(border) and |hl-PopupTitle| (title), which all link to |hl-Pmenu| by
default for backward compatibility. Override them to give general popup
windows a different look than the popup completion menu, or use the
"highlight" argument or the 'wincolor' option for a per-popup override: >
hi MyPopupColor ctermbg=lightblue guibg=lightblue
call setwinvar(winid, '&wincolor', 'MyPopupColor')

Expand Down Expand Up @@ -760,6 +763,10 @@ The second argument of |popup_create()| is a dictionary with options:
border one line of padding is added to put the title
on. You might want to add one or more spaces at the
start and end as padding.
The title uses |hl-PopupTitle| by default; if
"borderhighlight" is set the top border highlight is
used instead, and if "highlight"/'wincolor' is set
that is used.
wrap TRUE to make the lines wrap (default TRUE).
drag TRUE to allow the popup to be dragged with the mouse
by grabbing at the border. Has no effect if the
Expand Down Expand Up @@ -808,6 +815,8 @@ The second argument of |popup_create()| is a dictionary with options:
the highlight for the top/right/bottom/left border.
Example: ['TopColor', 'RightColor', 'BottomColor,
'LeftColor']
When not given and "highlight"/'wincolor' is also not
set, |hl-PopupBorder| is used.
borderchars List with characters, defining the character to use
for the top/right/bottom/left border. Optionally
followed by the character to use for the
Expand Down
12 changes: 12 additions & 0 deletions runtime/doc/syntax.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6077,6 +6077,18 @@ PmenuShadow Popup menu: Used for shadow.
ComplMatchIns Matched text of the currently inserted completion.
*hl-PreInsert*
PreInsert Text inserted when "preinsert" is in 'completeopt'.
*hl-Popup*
Popup Popup window body, used when neither the popup's 'wincolor'
nor explicit "highlight" argument is set. Linked to |hl-Pmenu|
by default.
*hl-PopupBorder*
PopupBorder Popup window border characters, used when "borderhighlight" is
not set and the popup's 'wincolor' is also not set.
Linked to |hl-Pmenu| by default.
*hl-PopupTitle*
PopupTitle Popup window title, used when "borderhighlight" is not set and
the popup's 'wincolor' is also not set. Linked to
|hl-Pmenu| by default.
*hl-PopupSelected*
PopupSelected Popup window created with |popup_menu()|. Linked to
|hl-PmenuSel| by default.
Expand Down
3 changes: 3 additions & 0 deletions runtime/doc/tags
Original file line number Diff line number Diff line change
Expand Up @@ -8464,8 +8464,11 @@ hl-PmenuSbar syntax.txt /*hl-PmenuSbar*
hl-PmenuSel syntax.txt /*hl-PmenuSel*
hl-PmenuShadow syntax.txt /*hl-PmenuShadow*
hl-PmenuThumb syntax.txt /*hl-PmenuThumb*
hl-Popup syntax.txt /*hl-Popup*
hl-PopupBorder syntax.txt /*hl-PopupBorder*
hl-PopupNotification syntax.txt /*hl-PopupNotification*
hl-PopupSelected syntax.txt /*hl-PopupSelected*
hl-PopupTitle syntax.txt /*hl-PopupTitle*
hl-PreInsert syntax.txt /*hl-PreInsert*
hl-Question syntax.txt /*hl-Question*
hl-QuickFixLine syntax.txt /*hl-QuickFixLine*
Expand Down
3 changes: 3 additions & 0 deletions src/highlight.c
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,9 @@ static char *(highlight_init_both[]) = {
"default link PmenuExtraSel PmenuSel",
"default link PmenuBorder Pmenu",
"default link PopupSelected PmenuSel",
"default link Popup Pmenu",
"default link PopupBorder Pmenu",
"default link PopupTitle Pmenu",
"default link MessageWindow WarningMsg",
"default link PopupNotification WarningMsg",
"default link PreInsert Added",
Expand Down
21 changes: 17 additions & 4 deletions src/popupwin.c
Original file line number Diff line number Diff line change
Expand Up @@ -6173,9 +6173,13 @@ update_popups(void (*win_update)(win_T *wp))

for (i = 0; i < 4; ++i)
{
border_attr[i] = popup_attr;
if (wp->w_border_highlight[i] != NULL)
border_attr[i] = syn_name2attr(wp->w_border_highlight[i]);
else if (wp->w_hlfwin_id != 0
|| (wp->w_popup_flags & POPF_INFO))
border_attr[i] = popup_attr;
else
border_attr[i] = syn_name2attr((char_u *)"PopupBorder");

// Apply blend to border attributes for popup with opacitys
if ((wp->w_popup_flags & POPF_OPACITY) && wp->w_popup_blend > 0)
Expand All @@ -6192,6 +6196,16 @@ update_popups(void (*win_update)(win_T *wp))
title_wincol = wp->w_wincol + 1;
if (wp->w_popup_title != NULL)
{
int title_attr;

if (wp->w_popup_border[0] > 0 && wp->w_border_highlight[0] != NULL)
title_attr = border_attr[0];
else if (wp->w_hlfwin_id != 0
|| (wp->w_popup_flags & POPF_INFO))
title_attr = popup_attr;
else
title_attr = syn_name2attr((char_u *)"PopupTitle");

title_len = vim_strsize(wp->w_popup_title);

// truncate the title if too long
Expand All @@ -6205,16 +6219,15 @@ update_popups(void (*win_update)(win_T *wp))
trunc_string(wp->w_popup_title, title_text,
total_width - 2, title_byte_len + 1);
screen_puts(title_text, wp->w_winrow, title_wincol,
wp->w_popup_border[0] > 0
? border_attr[0] : popup_attr);
title_attr);
vim_free(title_text);
}

title_len = total_width - 2;
}
else
screen_puts(wp->w_popup_title, wp->w_winrow, title_wincol,
wp->w_popup_border[0] > 0 ? border_attr[0] : popup_attr);
title_attr);
}

wincol = wp->w_wincol - wp->w_popup_leftoff + wp->w_popup_leftclip;
Expand Down
2 changes: 1 addition & 1 deletion src/screen.c
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ get_win_attr(win_T *wp)
if (wp->w_popup_flags & POPF_INFO)
win_attr = HL_ATTR(HLF_PSI); // PmenuSel
else
win_attr = HL_ATTR(HLF_PNI); // Pmenu
win_attr = syn_name2attr((char_u *)"Popup");
}
#endif

Expand Down
Loading