mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
feat(highlight): support for blend in nvim_set_hl (#17516)
This commit is contained in:
parent
73da7cef7b
commit
b5bf4877c0
@ -97,6 +97,7 @@ return {
|
|||||||
"special"; "sp";
|
"special"; "sp";
|
||||||
"link";
|
"link";
|
||||||
"fallback";
|
"fallback";
|
||||||
|
"blend";
|
||||||
"temp";
|
"temp";
|
||||||
};
|
};
|
||||||
highlight_cterm = {
|
highlight_cterm = {
|
||||||
|
@ -800,6 +800,7 @@ HlAttrs dict2hlattrs(Dict(highlight) *dict, bool use_rgb, int *link_id, Error *e
|
|||||||
{
|
{
|
||||||
HlAttrs hlattrs = HLATTRS_INIT;
|
HlAttrs hlattrs = HLATTRS_INIT;
|
||||||
int32_t fg = -1, bg = -1, ctermfg = -1, ctermbg = -1, sp = -1;
|
int32_t fg = -1, bg = -1, ctermfg = -1, ctermbg = -1, sp = -1;
|
||||||
|
int blend = -1;
|
||||||
int16_t mask = 0;
|
int16_t mask = 0;
|
||||||
int16_t cterm_mask = 0;
|
int16_t cterm_mask = 0;
|
||||||
bool cterm_mask_provided = false;
|
bool cterm_mask_provided = false;
|
||||||
@ -847,6 +848,20 @@ HlAttrs dict2hlattrs(Dict(highlight) *dict, bool use_rgb, int *link_id, Error *e
|
|||||||
return hlattrs;
|
return hlattrs;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (dict->blend.type == kObjectTypeInteger) {
|
||||||
|
Integer blend0 = dict->blend.data.integer;
|
||||||
|
if (blend0 < 0 || blend0 > 100) {
|
||||||
|
api_set_error(err, kErrorTypeValidation, "'blend' is not between 0 to 100");
|
||||||
|
} else {
|
||||||
|
blend = (int)blend0;
|
||||||
|
}
|
||||||
|
} else if (HAS_KEY(dict->blend)) {
|
||||||
|
api_set_error(err, kErrorTypeValidation, "'blend' must be an integer");
|
||||||
|
}
|
||||||
|
if (ERROR_SET(err)) {
|
||||||
|
return hlattrs;
|
||||||
|
}
|
||||||
|
|
||||||
if (HAS_KEY(dict->link)) {
|
if (HAS_KEY(dict->link)) {
|
||||||
if (link_id) {
|
if (link_id) {
|
||||||
*link_id = object_to_hl_id(dict->link, "link", err);
|
*link_id = object_to_hl_id(dict->link, "link", err);
|
||||||
@ -908,6 +923,7 @@ HlAttrs dict2hlattrs(Dict(highlight) *dict, bool use_rgb, int *link_id, Error *e
|
|||||||
hlattrs.rgb_bg_color = bg;
|
hlattrs.rgb_bg_color = bg;
|
||||||
hlattrs.rgb_fg_color = fg;
|
hlattrs.rgb_fg_color = fg;
|
||||||
hlattrs.rgb_sp_color = sp;
|
hlattrs.rgb_sp_color = sp;
|
||||||
|
hlattrs.hl_blend = blend;
|
||||||
hlattrs.cterm_bg_color = ctermbg == -1 ? 0 : ctermbg + 1;
|
hlattrs.cterm_bg_color = ctermbg == -1 ? 0 : ctermbg + 1;
|
||||||
hlattrs.cterm_fg_color = ctermfg == -1 ? 0 : ctermfg + 1;
|
hlattrs.cterm_fg_color = ctermfg == -1 ? 0 : ctermfg + 1;
|
||||||
hlattrs.cterm_ae_attr = cterm_mask;
|
hlattrs.cterm_ae_attr = cterm_mask;
|
||||||
|
@ -323,5 +323,9 @@ describe("API: set highlight", function()
|
|||||||
exec_capture('highlight Test_hl3'))
|
exec_capture('highlight Test_hl3'))
|
||||||
end
|
end
|
||||||
|
|
||||||
|
meths.set_hl(0, 'Test_hl3', {fg='#FF00FF', blend=50})
|
||||||
|
eq('Test_hl3 xxx guifg=#FF00FF blend=50',
|
||||||
|
exec_capture('highlight Test_hl3'))
|
||||||
|
|
||||||
end)
|
end)
|
||||||
end)
|
end)
|
||||||
|
Loading…
Reference in New Issue
Block a user