diff options
Diffstat (limited to 'src/nvim/api')
-rw-r--r-- | src/nvim/api/buffer.c | 8 | ||||
-rw-r--r-- | src/nvim/api/private/helpers.c | 61 | ||||
-rw-r--r-- | src/nvim/api/vim.c | 27 |
3 files changed, 41 insertions, 55 deletions
diff --git a/src/nvim/api/buffer.c b/src/nvim/api/buffer.c index 66c4454f7b..c55dc39605 100644 --- a/src/nvim/api/buffer.c +++ b/src/nvim/api/buffer.c @@ -222,11 +222,7 @@ Boolean nvim_buf_attach(uint64_t channel_id, return buf_updates_register(buf, channel_id, cb, send_buffer); error: - // TODO(bfredl): ASAN build should check that the ref table is empty? - api_free_luaref(cb.on_lines); - api_free_luaref(cb.on_bytes); - api_free_luaref(cb.on_changedtick); - api_free_luaref(cb.on_detach); + buffer_update_callbacks_free(cb); return false; } @@ -1453,6 +1449,8 @@ Array nvim_buf_get_extmarks(Buffer buffer, Integer ns_id, /// the extmark end position (if it exists) will be shifted /// in when new text is inserted (true for right, false /// for left). Defaults to false. +/// - priority: a priority value for the highlight group. For +/// example treesitter highlighting uses a value of 100. /// @param[out] err Error details, if any /// @return Id of the created/updated extmark Integer nvim_buf_set_extmark(Buffer buffer, Integer ns_id, diff --git a/src/nvim/api/private/helpers.c b/src/nvim/api/private/helpers.c index d2b787a6f5..24ba6110c4 100644 --- a/src/nvim/api/private/helpers.c +++ b/src/nvim/api/private/helpers.c @@ -1708,33 +1708,6 @@ const char *describe_ns(NS ns_id) return "(UNKNOWN PLUGIN)"; } -DecorProvider *get_provider(NS ns_id, bool force) -{ - ssize_t i; - for (i = 0; i < (ssize_t)kv_size(decor_providers); i++) { - DecorProvider *item = &kv_A(decor_providers, i); - if (item->ns_id == ns_id) { - return item; - } else if (item->ns_id > ns_id) { - break; - } - } - - if (!force) { - return NULL; - } - - for (ssize_t j = (ssize_t)kv_size(decor_providers)-1; j >= i; j++) { - // allocates if needed: - (void)kv_a(decor_providers, (size_t)j+1); - kv_A(decor_providers, (size_t)j+1) = kv_A(decor_providers, j); - } - DecorProvider *item = &kv_a(decor_providers, (size_t)i); - *item = DECORATION_PROVIDER_INIT(ns_id); - - return item; -} - static bool parse_float_anchor(String anchor, FloatAnchor *out) { if (anchor.size == 0) { @@ -1787,10 +1760,13 @@ static void parse_border_style(Object style, FloatConfig *fconfig, Error *err) struct { const char *name; schar_T chars[8]; + bool shadow_color; } defaults[] = { - { "double", { "╔", "═", "╗", "║", "╝", "═", "╚", "║" } }, - { "single", { "┌", "─", "┐", "│", "┘", "─", "└", "│" } }, - { NULL, { { NUL } } }, + { "double", { "╔", "═", "╗", "║", "╝", "═", "╚", "║" }, false }, + { "single", { "┌", "─", "┐", "│", "┘", "─", "└", "│" }, false }, + { "shadow", { "", "", " ", " ", " ", " ", " ", "" }, true }, + { "solid", { " ", " ", " ", " ", " ", " ", " ", " " }, false }, + { NULL, { { NUL } } , false }, }; schar_T *chars = fconfig->border_chars; @@ -1834,13 +1810,16 @@ static void parse_border_style(Object style, FloatConfig *fconfig, Error *err) api_set_error(err, kErrorTypeValidation, "invalid border char"); return; } - if (!string.size - || mb_string2cells_len((char_u *)string.data, string.size) != 1) { + if (string.size + && mb_string2cells_len((char_u *)string.data, string.size) > 1) { api_set_error(err, kErrorTypeValidation, "border chars must be one cell"); + return; } size_t len = MIN(string.size, sizeof(*chars)-1); - memcpy(chars[i], string.data, len); + if (len) { + memcpy(chars[i], string.data, len); + } chars[i][len] = NUL; hl_ids[i] = hl_id; } @@ -1849,6 +1828,13 @@ static void parse_border_style(Object style, FloatConfig *fconfig, Error *err) memcpy(hl_ids+size, hl_ids, sizeof(*hl_ids) * size); size <<= 1; } + if ((chars[7][0] && chars[1][0] && !chars[0][0]) + || (chars[1][0] && chars[3][0] && !chars[2][0]) + || (chars[3][0] && chars[5][0] && !chars[4][0]) + || (chars[5][0] && chars[7][0] && !chars[6][0])) { + api_set_error(err, kErrorTypeValidation, + "corner between used edges must be specified"); + } } else if (style.type == kObjectTypeString) { String str = style.data.string; if (str.size == 0 || strequal(str.data, "none")) { @@ -1859,6 +1845,15 @@ static void parse_border_style(Object style, FloatConfig *fconfig, Error *err) if (strequal(str.data, defaults[i].name)) { memcpy(chars, defaults[i].chars, sizeof(defaults[i].chars)); memset(hl_ids, 0, 8 * sizeof(*hl_ids)); + if (defaults[i].shadow_color) { + int hl_blend = SYN_GROUP_STATIC("FloatShadow"); + int hl_through = SYN_GROUP_STATIC("FloatShadowThrough"); + hl_ids[2] = hl_through; + hl_ids[3] = hl_blend; + hl_ids[4] = hl_blend; + hl_ids[5] = hl_blend; + hl_ids[6] = hl_through; + } return; } } diff --git a/src/nvim/api/vim.c b/src/nvim/api/vim.c index 787b6addc9..b5e53beabe 100644 --- a/src/nvim/api/vim.c +++ b/src/nvim/api/vim.c @@ -1333,7 +1333,8 @@ void nvim_chan_send(Integer chan, String data, Error *err) return; } - channel_send((uint64_t)chan, data.data, data.size, &error); + channel_send((uint64_t)chan, data.data, data.size, + false, &error); if (error) { api_set_error(err, kErrorTypeValidation, "%s", error); } @@ -1421,6 +1422,7 @@ void nvim_chan_send(Integer chan, String data, Error *err) /// - "none" No border. This is the default /// - "single" a single line box /// - "double" a double line box +/// - "shadow" a drop shadow effect by blending with the background. /// If it is an array it should be an array of eight items or any divisor of /// eight. The array will specifify the eight chars building up the border /// in a clockwise fashion starting with the top-left corner. As, an @@ -1431,6 +1433,9 @@ void nvim_chan_send(Integer chan, String data, Error *err) /// [ "/", "-", "\\", "|" ] /// or all chars the same as: /// [ "x" ] +/// An empty string can be used to turn off a specific border, for instance: +/// [ "", "", "", ">", "", "", "", "<" ] +/// will only make vertical borders but not horizontal ones. /// By default `FloatBorder` highlight is used which links to `VertSplit` /// when not defined. It could also be specified by character: /// [ {"+", "MyCorner"}, {"x", "MyBorder"} ] @@ -2708,6 +2713,7 @@ Dictionary nvim__stats(void) Dictionary rv = ARRAY_DICT_INIT; PUT(rv, "fsync", INTEGER_OBJ(g_stats.fsync)); PUT(rv, "redraw", INTEGER_OBJ(g_stats.redraw)); + PUT(rv, "lua_refcount", INTEGER_OBJ(nlua_refcount)); return rv; } @@ -2880,19 +2886,6 @@ void nvim__screenshot(String path) ui_call_screenshot(path); } -static void clear_provider(DecorProvider *p) -{ - if (p == NULL) { - return; - } - NLUA_CLEAR_REF(p->redraw_start); - NLUA_CLEAR_REF(p->redraw_buf); - NLUA_CLEAR_REF(p->redraw_win); - NLUA_CLEAR_REF(p->redraw_line); - NLUA_CLEAR_REF(p->redraw_end); - p->active = false; -} - /// Set or change decoration provider for a namespace /// /// This is a very general purpose interface for having lua callbacks @@ -2937,8 +2930,8 @@ void nvim_set_decoration_provider(Integer ns_id, DictionaryOf(LuaRef) opts, Error *err) FUNC_API_SINCE(7) FUNC_API_LUA_ONLY { - DecorProvider *p = get_provider((NS)ns_id, true); - clear_provider(p); + DecorProvider *p = get_decor_provider((NS)ns_id, true); + decor_provider_clear(p); // regardless of what happens, it seems good idea to redraw redraw_all_later(NOT_VALID); // TODO(bfredl): too soon? @@ -2981,5 +2974,5 @@ void nvim_set_decoration_provider(Integer ns_id, DictionaryOf(LuaRef) opts, p->active = true; return; error: - clear_provider(p); + decor_provider_clear(p); } |