diff options
Diffstat (limited to 'src/nvim/highlight.c')
| -rw-r--r-- | src/nvim/highlight.c | 53 |
1 files changed, 31 insertions, 22 deletions
diff --git a/src/nvim/highlight.c b/src/nvim/highlight.c index e2f3e2aafa..fad113adc5 100644 --- a/src/nvim/highlight.c +++ b/src/nvim/highlight.c @@ -50,7 +50,7 @@ static Map(int, int) blendthrough_attr_entries = MAP_INIT; /// highlight entries private to a namespace static Map(ColorKey, ColorItem) ns_hls; typedef int NSHlAttr[HLF_COUNT + 1]; -static PMap(handle_T) ns_hl_attr; +static PMap(int) ns_hl_attr; void highlight_init(void) { @@ -207,7 +207,7 @@ int ns_get_hl(NS *ns_hl, int hl_id, bool link, bool nodefault) if (!valid_item && p->hl_def != LUA_NOREF && !recursive) { MAXSIZE_TEMP_ARRAY(args, 3); ADD_C(args, INTEGER_OBJ((Integer)ns_id)); - ADD_C(args, STRING_OBJ(cstr_to_string(syn_id2name(hl_id)))); + ADD_C(args, CSTR_TO_OBJ(syn_id2name(hl_id))); ADD_C(args, BOOLEAN_OBJ(link)); // TODO(bfredl): preload the "global" attr dict? @@ -277,7 +277,7 @@ bool hl_check_ns(void) hl_attr_active = highlight_attr; if (ns > 0) { update_ns_hl(ns); - NSHlAttr *hl_def = (NSHlAttr *)pmap_get(handle_T)(&ns_hl_attr, ns); + NSHlAttr *hl_def = (NSHlAttr *)pmap_get(int)(&ns_hl_attr, ns); if (hl_def) { hl_attr_active = *hl_def; } @@ -335,7 +335,7 @@ void update_window_hl(win_T *wp, bool invalid) if (ns_id != wp->w_ns_hl_active || wp->w_ns_hl_attr == NULL) { wp->w_ns_hl_active = ns_id; - wp->w_ns_hl_attr = *(NSHlAttr *)pmap_get(handle_T)(&ns_hl_attr, ns_id); + wp->w_ns_hl_attr = *(NSHlAttr *)pmap_get(int)(&ns_hl_attr, ns_id); if (!wp->w_ns_hl_attr) { // No specific highlights, use the defaults. wp->w_ns_hl_attr = highlight_attr; @@ -398,6 +398,15 @@ void update_window_hl(win_T *wp, bool invalid) } else { 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 = kv_A(attr_entries, 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); + } + } } void update_ns_hl(int ns_id) @@ -410,7 +419,7 @@ void update_ns_hl(int ns_id) return; } - NSHlAttr **alloc = (NSHlAttr **)pmap_ref(handle_T)(&ns_hl_attr, ns_id, true); + NSHlAttr **alloc = (NSHlAttr **)pmap_put_ref(int)(&ns_hl_attr, ns_id, NULL, NULL); if (*alloc == NULL) { *alloc = xmalloc(sizeof(**alloc)); } @@ -482,28 +491,28 @@ void clear_hl_tables(bool reinit) { if (reinit) { kv_size(attr_entries) = 1; - map_clear(HlEntry, int)(&attr_entry_ids); - map_clear(int, int)(&combine_attr_entries); - map_clear(int, int)(&blend_attr_entries); - map_clear(int, int)(&blendthrough_attr_entries); + map_clear(HlEntry, &attr_entry_ids); + map_clear(int, &combine_attr_entries); + map_clear(int, &blend_attr_entries); + map_clear(int, &blendthrough_attr_entries); memset(highlight_attr_last, -1, sizeof(highlight_attr_last)); highlight_attr_set_all(); highlight_changed(); screen_invalidate_highlights(); } else { kv_destroy(attr_entries); - map_destroy(HlEntry, int)(&attr_entry_ids); - map_destroy(int, int)(&combine_attr_entries); - map_destroy(int, int)(&blend_attr_entries); - map_destroy(int, int)(&blendthrough_attr_entries); - map_destroy(ColorKey, ColorItem)(&ns_hls); + map_destroy(HlEntry, &attr_entry_ids); + map_destroy(int, &combine_attr_entries); + map_destroy(int, &blend_attr_entries); + map_destroy(int, &blendthrough_attr_entries); + map_destroy(ColorKey, &ns_hls); } } void hl_invalidate_blends(void) { - map_clear(int, int)(&blend_attr_entries); - map_clear(int, int)(&blendthrough_attr_entries); + map_clear(int, &blend_attr_entries); + map_clear(int, &blendthrough_attr_entries); highlight_changed(); update_window_hl(curwin, true); } @@ -1132,21 +1141,21 @@ static void hl_inspect_impl(Array *arr, int attr) HlEntry e = kv_A(attr_entries, attr); switch (e.kind) { case kHlSyntax: - PUT(item, "kind", STRING_OBJ(cstr_to_string("syntax"))); + PUT(item, "kind", CSTR_TO_OBJ("syntax")); PUT(item, "hi_name", - STRING_OBJ(cstr_to_string(syn_id2name(e.id1)))); + CSTR_TO_OBJ(syn_id2name(e.id1))); break; case kHlUI: - PUT(item, "kind", STRING_OBJ(cstr_to_string("ui"))); + PUT(item, "kind", CSTR_TO_OBJ("ui")); const char *ui_name = (e.id1 == -1) ? "Normal" : hlf_names[e.id1]; - PUT(item, "ui_name", STRING_OBJ(cstr_to_string(ui_name))); + PUT(item, "ui_name", CSTR_TO_OBJ(ui_name)); PUT(item, "hi_name", - STRING_OBJ(cstr_to_string(syn_id2name(e.id2)))); + CSTR_TO_OBJ(syn_id2name(e.id2))); break; case kHlTerminal: - PUT(item, "kind", STRING_OBJ(cstr_to_string("term"))); + PUT(item, "kind", CSTR_TO_OBJ("term")); break; case kHlCombine: |
