+44
-14
lines changedFilter options
+44
-14
lines changed Original file line number Diff line number Diff line change
@@ -904,15 +904,13 @@ HlAttrs dict2hlattrs(Dict(highlight) *dict, bool use_rgb, int *link_id, Error *e
904
904
hlattrs.rgb_bg_color = bg;
905
905
hlattrs.rgb_fg_color = fg;
906
906
hlattrs.rgb_sp_color = sp;
907
-
hlattrs.cterm_bg_color =
908
-
ctermbg == -1 ? cterm_normal_bg_color : ctermbg + 1;
909
-
hlattrs.cterm_fg_color =
910
-
ctermfg == -1 ? cterm_normal_fg_color : ctermfg + 1;
907
+
hlattrs.cterm_bg_color = ctermbg == -1 ? 0 : ctermbg + 1;
908
+
hlattrs.cterm_fg_color = ctermfg == -1 ? 0 : ctermfg + 1;
911
909
hlattrs.cterm_ae_attr = cterm_mask;
912
910
} else {
913
911
hlattrs.cterm_ae_attr = cterm_mask;
914
-
hlattrs.cterm_bg_color = bg == -1 ? cterm_normal_bg_color : bg + 1;
915
-
hlattrs.cterm_fg_color = fg == -1 ? cterm_normal_fg_color : fg + 1;
912
+
hlattrs.cterm_bg_color = bg == -1 ? 0 : bg + 1;
913
+
hlattrs.cterm_fg_color = fg == -1 ? 0 : fg + 1;
916
914
}
917
915
918
916
return hlattrs;
Original file line number Diff line number Diff line change
@@ -6758,16 +6758,26 @@ void set_hl_group(int id, HlAttrs attrs, Dict(highlight) *dict, int link_id)
6758
6758
{ NULL, -1, NIL },
6759
6759
};
6760
6760
6761
+
char hex_name[8];
6762
+
char *name;
6763
+
6761
6764
for (int j = 0; cattrs[j].dest; j++) {
6762
-
if (cattrs[j].val != -1) {
6765
+
if (cattrs[j].val < 0) {
6766
+
XFREE_CLEAR(*cattrs[j].dest);
6767
+
continue;
6768
+
}
6769
+
6770
+
if (cattrs[j].name.type == kObjectTypeString && cattrs[j].name.data.string.size) {
6771
+
name = cattrs[j].name.data.string.data;
6772
+
} else {
6773
+
snprintf(hex_name, sizeof(hex_name), "#%06x", cattrs[j].val);
6774
+
name = hex_name;
6775
+
}
6776
+
6777
+
if (!*cattrs[j].dest
6778
+
|| STRCMP(*cattrs[j].dest, name) != 0) {
6763
6779
xfree(*cattrs[j].dest);
6764
-
if (cattrs[j].name.type == kObjectTypeString && cattrs[j].name.data.string.size) {
6765
-
*cattrs[j].dest = xstrdup(cattrs[j].name.data.string.data);
6766
-
} else {
6767
-
char hex_name[8];
6768
-
snprintf(hex_name, sizeof(hex_name), "#%06x", cattrs[j].val);
6769
-
*cattrs[j].dest = xstrdup(hex_name);
6770
-
}
6780
+
*cattrs[j].dest = xstrdup(name);
6771
6781
}
6772
6782
}
6773
6783
Original file line number Diff line number Diff line change
@@ -276,4 +276,26 @@ describe("API: set highlight", function()
276
276
eq('Test_hl3 xxx guifg=bLue guibg=reD',
277
277
exec_capture('highlight Test_hl3'))
278
278
end)
279
+
280
+
it ("can modify a highlight in the global namespace", function()
281
+
meths.set_hl(0, 'Test_hl3', { bg = 'red', fg = 'blue'})
282
+
eq('Test_hl3 xxx guifg=blue guibg=red',
283
+
exec_capture('highlight Test_hl3'))
284
+
285
+
meths.set_hl(0, 'Test_hl3', { bg = 'red' })
286
+
eq('Test_hl3 xxx guibg=red',
287
+
exec_capture('highlight Test_hl3'))
288
+
289
+
meths.set_hl(0, 'Test_hl3', { ctermbg = 9, ctermfg = 12})
290
+
eq('Test_hl3 xxx ctermfg=12 ctermbg=9',
291
+
exec_capture('highlight Test_hl3'))
292
+
293
+
meths.set_hl(0, 'Test_hl3', { ctermbg = 9 })
294
+
eq('Test_hl3 xxx ctermbg=9',
295
+
exec_capture('highlight Test_hl3'))
296
+
297
+
meths.set_hl(0, 'Test_hl3', {})
298
+
eq('Test_hl3 xxx cleared',
299
+
exec_capture('highlight Test_hl3'))
300
+
end)
279
301
end)
You can’t perform that action at this time.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4