@@ -144,13 +144,19 @@ int hl_get_syn_attr(int ns_id, int idx, HlAttrs at_en)
144
144
}
145
145
}
146
146
147
-
void ns_hl_def(NS ns_id, int hl_id, HlAttrs attrs, int link_id)
147
+
void ns_hl_def(NS ns_id, int hl_id, HlAttrs attrs, int link_id, HlAttrNames *names)
148
148
{
149
-
DecorProvider *p = get_decor_provider(ns_id, true);
150
149
if ((attrs.rgb_ae_attr & HL_DEFAULT)
151
150
&& map_has(ColorKey, ColorItem)(&ns_hl, ColorKey(ns_id, hl_id))) {
152
151
return;
153
152
}
153
+
if (ns_id == 0) {
154
+
assert(names);
155
+
// set in global (':highlight') namespace
156
+
set_hl_group(hl_id, attrs, names, link_id);
157
+
return;
158
+
}
159
+
DecorProvider *p = get_decor_provider(ns_id, true);
154
160
int attr_id = link_id > 0 ? -1 : hl_get_syn_attr(ns_id, hl_id, attrs);
155
161
ColorItem it = { .attr_id = attr_id,
156
162
.link_id = link_id,
@@ -194,7 +200,7 @@ int ns_get_hl(NS ns_id, int hl_id, bool link, bool nodefault)
194
200
if (ret.type == kObjectTypeDictionary) {
195
201
Dictionary dict = ret.data.dictionary;
196
202
fallback = false;
197
-
attrs = dict2hlattrs(dict, true, &it.link_id, &err);
203
+
attrs = dict2hlattrs(dict, true, &it.link_id, NULL, &err);
198
204
for (size_t i = 0; i < dict.size; i++) {
199
205
char *key = dict.items[i].key.data;
200
206
Object val = dict.items[i].value;
@@ -796,7 +802,7 @@ Dictionary hlattrs2dict(HlAttrs ae, bool use_rgb)
796
802
return hl;
797
803
}
798
804
799
-
HlAttrs dict2hlattrs(Dictionary dict, bool use_rgb, int *link_id, Error *err)
805
+
HlAttrs dict2hlattrs(Dictionary dict, bool use_rgb, int *link_id, HlAttrNames *names, Error *err)
800
806
{
801
807
HlAttrs hlattrs = HLATTRS_INIT;
802
808
@@ -820,7 +826,7 @@ HlAttrs dict2hlattrs(Dictionary dict, bool use_rgb, int *link_id, Error *err)
820
826
{ "italic", HL_ITALIC },
821
827
{ "reverse", HL_INVERSE },
822
828
{ "default", HL_DEFAULT },
823
-
{ "global", HL_GLOBAL },
829
+
// { "global", HL_GLOBAL },
824
830
{ NULL, 0 },
825
831
};
826
832
@@ -857,13 +863,14 @@ HlAttrs dict2hlattrs(Dictionary dict, bool use_rgb, int *link_id, Error *err)
857
863
const char *name;
858
864
const char *shortname;
859
865
int *dest;
866
+
char **dest_name;
860
867
} colors[] = {
861
-
{ "foreground", "fg", &fg },
862
-
{ "background", "bg", &bg },
863
-
{ "ctermfg", NULL, &ctermfg },
864
-
{ "ctermbg", NULL, &ctermbg },
865
-
{ "special", "sp", &sp },
866
-
{ NULL, NULL, NULL },
868
+
{ "foreground", "fg", &fg, names ? &names->fg_name : NULL },
869
+
{ "background", "bg", &bg, names ? &names->bg_name : NULL },
870
+
{ "ctermfg", NULL, &ctermfg, NULL },
871
+
{ "ctermbg", NULL, &ctermbg, NULL },
872
+
{ "special", "sp", &sp, names ? &names->sp_name : NULL },
873
+
{ NULL, NULL, NULL, NULL },
867
874
};
868
875
869
876
int k;
@@ -876,6 +883,9 @@ HlAttrs dict2hlattrs(Dictionary dict, bool use_rgb, int *link_id, Error *err)
876
883
// TODO(bfredl): be more fancy with "bg", "fg" etc
877
884
if (str.size) {
878
885
*colors[k].dest = name_to_color(str.data);
886
+
if (colors[k].dest_name) {
887
+
*colors[k].dest_name = str.data;
888
+
}
879
889
}
880
890
} else {
881
891
api_set_error(err, kErrorTypeValidation,
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