diff options
author | zeertzjq <zeertzjq@outlook.com> | 2023-11-12 09:23:34 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-11-12 09:23:34 +0800 |
commit | 9ecb43b6372feb49d6d497c41aa75d2cce1a1446 (patch) | |
tree | a8b36d67981acc32648d126308a0fd1704b49fe6 /src/nvim/highlight.c | |
parent | b33130244278d28fa8372c35c68fe6d26dd1fefa (diff) | |
download | rneovim-9ecb43b6372feb49d6d497c41aa75d2cce1a1446.tar.gz rneovim-9ecb43b6372feb49d6d497c41aa75d2cce1a1446.tar.bz2 rneovim-9ecb43b6372feb49d6d497c41aa75d2cce1a1446.zip |
fix(float): apply 'winblend' to title/footer highlight (#25999)
Diffstat (limited to 'src/nvim/highlight.c')
-rw-r--r-- | src/nvim/highlight.c | 44 |
1 files changed, 23 insertions, 21 deletions
diff --git a/src/nvim/highlight.c b/src/nvim/highlight.c index a0114bbbe8..6d6bcacd83 100644 --- a/src/nvim/highlight.c +++ b/src/nvim/highlight.c @@ -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); } } |