diff options
author | Björn Linse <bjorn.linse@gmail.com> | 2018-08-21 21:12:01 +0200 |
---|---|---|
committer | Björn Linse <bjorn.linse@gmail.com> | 2018-08-27 11:51:52 +0200 |
commit | 03978a0f296aa8638a578698ea0a6cceedb34527 (patch) | |
tree | f04a06422d5f9e51077aa7e95bfea247eb813ac1 /src/nvim/api/ui.c | |
parent | a8b4d76a0a2c59a3a368932ae111265c15b8dccb (diff) | |
download | rneovim-03978a0f296aa8638a578698ea0a6cceedb34527.tar.gz rneovim-03978a0f296aa8638a578698ea0a6cceedb34527.tar.bz2 rneovim-03978a0f296aa8638a578698ea0a6cceedb34527.zip |
ext_cmdline: use new highlight representation for cmdline_block
Make sure cmdline updates will receive highlight specifications the same
way as screen cells. This is controlled by the ext_newgrid option so
nothing is changed by default (as screen cells are also not changed by
default). This was already done for the cmdline itself in #8221, this
extends it to cmdline_block. Which currently doesn't store highlights,
but the placeholder should be one that makes sense for future use.
Diffstat (limited to 'src/nvim/api/ui.c')
-rw-r--r-- | src/nvim/api/ui.c | 39 |
1 files changed, 31 insertions, 8 deletions
diff --git a/src/nvim/api/ui.c b/src/nvim/api/ui.c index 37d34c5843..76e3927820 100644 --- a/src/nvim/api/ui.c +++ b/src/nvim/api/ui.c @@ -501,10 +501,8 @@ static void remote_ui_flush(UI *ui) } } -static void remote_ui_cmdline_show(UI *ui, Array args) +static Array translate_contents(UI *ui, Array contents) { - Array new_args = ARRAY_DICT_INIT; - Array contents = args.items[0].data.array; Array new_contents = ARRAY_DICT_INIT; for (size_t i = 0; i < contents.size; i++) { Array item = contents.items[i].data.array; @@ -519,23 +517,48 @@ static void remote_ui_cmdline_show(UI *ui, Array args) ADD(new_item, copy_object(item.items[1])); ADD(new_contents, ARRAY_OBJ(new_item)); } - ADD(new_args, ARRAY_OBJ(new_contents)); + return new_contents; +} + +static Array translate_firstarg(UI *ui, Array args) +{ + Array new_args = ARRAY_DICT_INIT; + Array contents = args.items[0].data.array; + + ADD(new_args, ARRAY_OBJ(translate_contents(ui, contents))); for (size_t i = 1; i < args.size; i++) { ADD(new_args, copy_object(args.items[i])); } - push_call(ui, "cmdline_show", new_args); + return new_args; } static void remote_ui_event(UI *ui, char *name, Array args, bool *args_consumed) { if (!ui->ui_ext[kUINewgrid]) { - // the representation of cmdline_show changed, translate back + // the representation of highlights in cmdline changed, translate back + // never consumes args if (strequal(name, "cmdline_show")) { - remote_ui_cmdline_show(ui, args); - // never consumes args + Array new_args = translate_firstarg(ui, args); + push_call(ui, name, new_args); + return; + } else if (strequal(name, "cmdline_block_show")) { + Array new_args = ARRAY_DICT_INIT; + Array block = args.items[0].data.array; + Array new_block = ARRAY_DICT_INIT; + for (size_t i = 0; i < block.size; i++) { + ADD(new_block, + ARRAY_OBJ(translate_contents(ui, block.items[i].data.array))); + } + ADD(new_args, ARRAY_OBJ(new_block)); + push_call(ui, name, new_args); + return; + } else if (strequal(name, "cmdline_block_append")) { + Array new_args = translate_firstarg(ui, args); + push_call(ui, name, new_args); return; } } + Array my_args = ARRAY_DICT_INIT; // Objects are currently single-reference // make a copy, but only if necessary |