diff options
author | Yatao Li <yatli@microsoft.com> | 2021-09-16 07:53:56 +0800 |
---|---|---|
committer | Yatao Li <yatli@microsoft.com> | 2022-05-03 22:26:02 +0800 |
commit | 29a6cda3ffe981b09d4c59d49d6c97a4ea13ca8b (patch) | |
tree | aef77156a4164f79b004e92bd685d23a40ba6bfb /src/nvim/api | |
parent | 8ea84eee570fd1ec560fe149e611d10034d9a223 (diff) | |
download | rneovim-29a6cda3ffe981b09d4c59d49d6c97a4ea13ca8b.tar.gz rneovim-29a6cda3ffe981b09d4c59d49d6c97a4ea13ca8b.tar.bz2 rneovim-29a6cda3ffe981b09d4c59d49d6c97a4ea13ca8b.zip |
feat(api/ui): win_extmarks
Diffstat (limited to 'src/nvim/api')
-rw-r--r-- | src/nvim/api/extmark.c | 14 | ||||
-rw-r--r-- | src/nvim/api/keysets.lua | 1 | ||||
-rw-r--r-- | src/nvim/api/ui.c | 1 | ||||
-rw-r--r-- | src/nvim/api/ui.h | 1 | ||||
-rw-r--r-- | src/nvim/api/ui_events.in.h | 4 |
5 files changed, 19 insertions, 2 deletions
diff --git a/src/nvim/api/extmark.c b/src/nvim/api/extmark.c index e408d88854..fa6923e6d5 100644 --- a/src/nvim/api/extmark.c +++ b/src/nvim/api/extmark.c @@ -146,6 +146,10 @@ static Array extmark_to_array(ExtmarkInfo extmark, bool id, bool add_dict) STRING_OBJ(cstr_to_string(virt_text_pos_str[decor->virt_text_pos]))); } + if (decor->ui_watched) { + PUT(dict, "ui_watched", BOOLEAN_OBJ(true)); + } + if (kv_size(decor->virt_lines)) { Array all_chunks = ARRAY_DICT_INIT; bool virt_lines_leftcol = false; @@ -170,7 +174,7 @@ static Array extmark_to_array(ExtmarkInfo extmark, bool id, bool add_dict) PUT(dict, "virt_lines_leftcol", BOOLEAN_OBJ(virt_lines_leftcol)); } - if (decor->hl_id || kv_size(decor->virt_text)) { + if (decor->hl_id || kv_size(decor->virt_text) || decor->ui_watched) { PUT(dict, "priority", INTEGER_OBJ(decor->priority)); } @@ -472,6 +476,10 @@ Array nvim_buf_get_extmarks(Buffer buffer, Integer ns_id, Object start, Object e /// When a character is supplied it is used as |:syn-cchar|. /// "hl_group" is used as highlight for the cchar if provided, /// otherwise it defaults to |hl-Conceal|. +/// - ui_watched: boolean that indicates the mark should be drawn +/// by a UI. When set, the UI will receive win_extmark events. +/// Note: the mark is positioned by virt_text attributes. Can be +/// used together with virt_text. /// /// @param[out] err Error details, if any /// @return Id of the created/updated extmark @@ -709,6 +717,8 @@ Integer nvim_buf_set_extmark(Buffer buffer, Integer ns_id, Integer line, Integer bool ephemeral = false; OPTION_TO_BOOL(ephemeral, ephemeral, false); + OPTION_TO_BOOL(decor.ui_watched, ui_watched, false); + if (line < 0) { api_set_error(err, kErrorTypeValidation, "line value outside range"); goto error; @@ -762,7 +772,7 @@ Integer nvim_buf_set_extmark(Buffer buffer, Integer ns_id, Integer line, Integer // TODO(bfredl): synergize these two branches even more if (ephemeral && decor_state.buf == buf) { - decor_add_ephemeral((int)line, (int)col, line2, col2, &decor); + decor_add_ephemeral((int)line, (int)col, line2, col2, &decor, (uint64_t)ns_id, id); } else { if (ephemeral) { api_set_error(err, kErrorTypeException, "not yet implemented"); diff --git a/src/nvim/api/keysets.lua b/src/nvim/api/keysets.lua index 8ad4dae928..5baffaf505 100644 --- a/src/nvim/api/keysets.lua +++ b/src/nvim/api/keysets.lua @@ -28,6 +28,7 @@ return { "line_hl_group"; "cursorline_hl_group"; "conceal"; + "ui_watched"; }; keymap = { "noremap"; diff --git a/src/nvim/api/ui.c b/src/nvim/api/ui.c index d1b86ed328..4f9592bd52 100644 --- a/src/nvim/api/ui.c +++ b/src/nvim/api/ui.c @@ -810,3 +810,4 @@ static void remote_ui_inspect(UI *ui, Dictionary *info) UIData *data = ui->data; PUT(*info, "chan", INTEGER_OBJ((Integer)data->channel_id)); } + diff --git a/src/nvim/api/ui.h b/src/nvim/api/ui.h index b3af14f8a8..bc70406acb 100644 --- a/src/nvim/api/ui.h +++ b/src/nvim/api/ui.h @@ -4,6 +4,7 @@ #include <stdint.h> #include "nvim/api/private/defs.h" +#include "nvim/map.h" #ifdef INCLUDE_GENERATED_DECLARATIONS # include "api/ui.h.generated.h" diff --git a/src/nvim/api/ui_events.in.h b/src/nvim/api/ui_events.in.h index db348359eb..63aaaae38a 100644 --- a/src/nvim/api/ui_events.in.h +++ b/src/nvim/api/ui_events.in.h @@ -123,6 +123,10 @@ void win_viewport(Integer grid, Window win, Integer topline, Integer line_count) FUNC_API_SINCE(7) FUNC_API_REMOTE_ONLY; +void win_extmark(Integer grid, Window win, Integer ns_id, Integer mark_id, + Integer row, Integer col) + FUNC_API_SINCE(10) FUNC_API_REMOTE_ONLY; + void popupmenu_show(Array items, Integer selected, Integer row, Integer col, Integer grid) FUNC_API_SINCE(3) FUNC_API_REMOTE_ONLY; |