mirror of
https://github.com/neovim/neovim.git
synced 2025-09-13 06:48:17 +00:00
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.
This commit is contained in:
@@ -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;
|
Array new_contents = ARRAY_DICT_INIT;
|
||||||
for (size_t i = 0; i < contents.size; i++) {
|
for (size_t i = 0; i < contents.size; i++) {
|
||||||
Array item = contents.items[i].data.array;
|
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_item, copy_object(item.items[1]));
|
||||||
ADD(new_contents, ARRAY_OBJ(new_item));
|
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++) {
|
for (size_t i = 1; i < args.size; i++) {
|
||||||
ADD(new_args, copy_object(args.items[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)
|
static void remote_ui_event(UI *ui, char *name, Array args, bool *args_consumed)
|
||||||
{
|
{
|
||||||
if (!ui->ui_ext[kUINewgrid]) {
|
if (!ui->ui_ext[kUINewgrid]) {
|
||||||
// the representation of cmdline_show changed, translate back
|
// the representation of highlights in cmdline changed, translate back
|
||||||
if (strequal(name, "cmdline_show")) {
|
|
||||||
remote_ui_cmdline_show(ui, args);
|
|
||||||
// never consumes args
|
// never consumes args
|
||||||
|
if (strequal(name, "cmdline_show")) {
|
||||||
|
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;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Array my_args = ARRAY_DICT_INIT;
|
Array my_args = ARRAY_DICT_INIT;
|
||||||
// Objects are currently single-reference
|
// Objects are currently single-reference
|
||||||
// make a copy, but only if necessary
|
// make a copy, but only if necessary
|
||||||
|
@@ -2990,7 +2990,7 @@ void ui_ext_cmdline_block_append(int indent, const char *line)
|
|||||||
memcpy(buf + indent, line, strlen(line)); // -V575
|
memcpy(buf + indent, line, strlen(line)); // -V575
|
||||||
|
|
||||||
Array item = ARRAY_DICT_INIT;
|
Array item = ARRAY_DICT_INIT;
|
||||||
ADD(item, DICTIONARY_OBJ((Dictionary)ARRAY_DICT_INIT));
|
ADD(item, INTEGER_OBJ(0));
|
||||||
ADD(item, STRING_OBJ(cstr_as_string(buf)));
|
ADD(item, STRING_OBJ(cstr_as_string(buf)));
|
||||||
Array content = ARRAY_DICT_INIT;
|
Array content = ARRAY_DICT_INIT;
|
||||||
ADD(content, ARRAY_OBJ(item));
|
ADD(content, ARRAY_OBJ(item));
|
||||||
|
Reference in New Issue
Block a user