mirror of
https://github.com/neovim/neovim.git
synced 2024-12-23 20:55:18 -07:00
fix(float): apply 'winblend' to title/footer highlight (#25999)
This commit is contained in:
parent
b331302442
commit
9ecb43b637
@ -725,6 +725,7 @@ static void win_redr_bordertext(win_T *wp, VirtText vt, int col)
|
||||
if (text == NULL) {
|
||||
break;
|
||||
}
|
||||
attr = hl_apply_winblend(wp, attr);
|
||||
col += grid_line_puts(col, text, -1, attr);
|
||||
}
|
||||
}
|
||||
|
@ -323,6 +323,23 @@ int hl_get_ui_attr(int ns_id, int idx, int final_id, bool optional)
|
||||
.id1 = idx, .id2 = final_id });
|
||||
}
|
||||
|
||||
/// Apply 'winblend' to highlight attributes.
|
||||
///
|
||||
/// @param wp The window to get 'winblend' value from.
|
||||
/// @param attr The original attribute code.
|
||||
///
|
||||
/// @return The attribute code with 'winblend' applied.
|
||||
int hl_apply_winblend(win_T *wp, int attr)
|
||||
{
|
||||
HlEntry entry = attr_entry(attr);
|
||||
// if blend= attribute is not set, 'winblend' value overrides it.
|
||||
if (entry.attr.hl_blend == -1 && wp->w_p_winbl > 0) {
|
||||
entry.attr.hl_blend = (int)wp->w_p_winbl;
|
||||
attr = get_attr_entry(entry);
|
||||
}
|
||||
return attr;
|
||||
}
|
||||
|
||||
void update_window_hl(win_T *wp, bool invalid)
|
||||
{
|
||||
int ns_id = wp->w_ns_hl;
|
||||
@ -358,13 +375,8 @@ void update_window_hl(win_T *wp, bool invalid)
|
||||
wp->w_hl_attr_normal = float_win ? HL_ATTR(HLF_NFLOAT) : 0;
|
||||
}
|
||||
|
||||
// if blend= attribute is not set, 'winblend' value overrides it.
|
||||
if (wp->w_floating && wp->w_p_winbl > 0) {
|
||||
HlEntry entry = attr_entry(wp->w_hl_attr_normal);
|
||||
if (entry.attr.hl_blend == -1) {
|
||||
entry.attr.hl_blend = (int)wp->w_p_winbl;
|
||||
wp->w_hl_attr_normal = get_attr_entry(entry);
|
||||
}
|
||||
if (wp->w_floating) {
|
||||
wp->w_hl_attr_normal = hl_apply_winblend(wp, wp->w_hl_attr_normal);
|
||||
}
|
||||
|
||||
wp->w_float_config.shadow = false;
|
||||
@ -375,13 +387,8 @@ void update_window_hl(win_T *wp, bool invalid)
|
||||
attr = hl_get_ui_attr(ns_id, HLF_BORDER,
|
||||
wp->w_float_config.border_hl_ids[i], false);
|
||||
}
|
||||
HlAttrs a = syn_attr2entry(attr);
|
||||
if (a.hl_blend == -1 && wp->w_p_winbl > 0) {
|
||||
HlEntry entry = attr_entry(attr);
|
||||
a.hl_blend = entry.attr.hl_blend = (int)wp->w_p_winbl;
|
||||
attr = get_attr_entry(entry);
|
||||
}
|
||||
if (a.hl_blend > 0) {
|
||||
attr = hl_apply_winblend(wp, attr);
|
||||
if (syn_attr2entry(attr).hl_blend > 0) {
|
||||
wp->w_float_config.shadow = true;
|
||||
}
|
||||
wp->w_float_config.border_attr[i] = attr;
|
||||
@ -400,13 +407,8 @@ void update_window_hl(win_T *wp, bool invalid)
|
||||
wp->w_hl_attr_normalnc = hl_def[HLF_INACTIVE];
|
||||
}
|
||||
|
||||
// if blend= attribute is not set, 'winblend' value overrides it.
|
||||
if (wp->w_floating && wp->w_p_winbl > 0) {
|
||||
HlEntry entry = attr_entry(wp->w_hl_attr_normalnc);
|
||||
if (entry.attr.hl_blend == -1) {
|
||||
entry.attr.hl_blend = (int)wp->w_p_winbl;
|
||||
wp->w_hl_attr_normalnc = get_attr_entry(entry);
|
||||
}
|
||||
if (wp->w_floating) {
|
||||
wp->w_hl_attr_normalnc = hl_apply_winblend(wp, wp->w_hl_attr_normalnc);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -9198,6 +9198,9 @@ describe('float window', function()
|
||||
[20] = {background = Screen.colors.White, foreground = Screen.colors.Gray0};
|
||||
[21] = {background = Screen.colors.White, bold = true, foreground = tonumber('0x00007f')};
|
||||
[22] = {background = Screen.colors.Gray90, foreground = Screen.colors.Gray0};
|
||||
[23] = {blend = 100, bold = true, foreground = Screen.colors.Magenta};
|
||||
[24] = {foreground = tonumber('0x7f007f'), bold = true, background = Screen.colors.White};
|
||||
[25] = {foreground = tonumber('0x7f007f'), bold = true, background = Screen.colors.Grey90};
|
||||
})
|
||||
insert([[
|
||||
Lorem ipsum dolor sit amet, consectetur
|
||||
@ -9483,8 +9486,8 @@ describe('float window', function()
|
||||
]])
|
||||
end
|
||||
|
||||
-- Check that 'winblend' applies to border
|
||||
meths.win_set_config(win, {border='single'})
|
||||
-- Check that 'winblend' applies to border/title/footer
|
||||
meths.win_set_config(win, {border='single', title='Title', footer='Footer'})
|
||||
meths.set_option_value('winblend', 100, {win=win.id})
|
||||
meths.set_option_value("cursorline", true, {win=0})
|
||||
command('hi clear VertSplit')
|
||||
@ -9513,21 +9516,21 @@ describe('float window', function()
|
||||
## grid 3
|
||||
|
|
||||
## grid 4
|
||||
{17:┌───────────────┐}|
|
||||
{17:┌}{23:Title}{17:──────────┐}|
|
||||
{17:│}{11:popup text}{18: }{17:│}|
|
||||
{17:│}{19:~ }{17:│}|
|
||||
{17:│}{19:~ }{17:│}|
|
||||
{17:└───────────────┘}|
|
||||
{17:└}{23:Footer}{17:─────────┘}|
|
||||
]], float_pos={[4] = {{id = 1001}, "NW", 1, 2, 5, true}}}
|
||||
else
|
||||
screen:expect([[
|
||||
Ut enim ad minim veniam, quis nostrud |
|
||||
exercitation ullamco laboris nisi ut aliquip ex |
|
||||
ea co{20:┌───────────────┐}Duis aute irure dolor in |
|
||||
ea co{20:┌}{24:Title}{20:──────────┐}Duis aute irure dolor in |
|
||||
repre{20:│}{5:popup}{6:it i}{5:text}{20:lu│}tate velit esse cillum |
|
||||
dolor{20:│}{21:~}{20:eu fugiat null│} pariatur. Excepteur sint |
|
||||
occae{20:│}{21:~}{20:t cupidatat no│} proident, sunt in culpa |
|
||||
{16:^qui o}{22:└───────────────┘}{16:ollit anim id est }|
|
||||
{16:^qui o}{22:└}{25:Footer}{22:─────────┘}{16:ollit anim id est }|
|
||||
laborum. |
|
||||
|
|
||||
]])
|
||||
|
Loading…
Reference in New Issue
Block a user