From 5cfa7a72f8c40cdcc0fa93693689915e913806f1 Mon Sep 17 00:00:00 2001 From: Luuk van Baal Date: Tue, 20 Feb 2024 17:25:57 +0100 Subject: refactor(message): propagate highlight id instead of attrs Problem: Highlight group id is not propagated to the end of the message call stack, where ext_messages are emitted. Solution: Refactor message functions to pass along highlight group id instead of attr id. --- src/nvim/normal.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/nvim/normal.c') diff --git a/src/nvim/normal.c b/src/nvim/normal.c index aa247e39e6..d0517d5e4f 100644 --- a/src/nvim/normal.c +++ b/src/nvim/normal.c @@ -693,7 +693,7 @@ static void normal_redraw_mode_message(NormalState *s) keep_msg = kmsg; kmsg = xstrdup(keep_msg); - msg(kmsg, keep_msg_attr); + msg(kmsg, keep_msg_hl_id); xfree(kmsg); } setcursor(); @@ -1388,7 +1388,7 @@ static void normal_redraw(NormalState *s) // check for duplicates. Never put this message in // history. msg_hist_off = true; - msg(p, keep_msg_attr); + msg(p, keep_msg_hl_id); msg_hist_off = false; xfree(p); } -- cgit From 4f9260d06a48216862ebb34fc33744486b058f58 Mon Sep 17 00:00:00 2001 From: Luuk van Baal Date: Fri, 8 Mar 2024 14:44:58 +0100 Subject: feat(ext_messages): add hl_id to ext_messages chunks Problem: Ext_messages chunks only contain the highlight attr id, which is not very useful for vim.ui_attach() consumers. Solotion: Add highlight group id to message chunks, which can easily be used to highlight text in the TUI through nvim_buf_set_extmark(): hl_group = synIDattr(id, "name"). --- src/nvim/normal.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/nvim/normal.c') diff --git a/src/nvim/normal.c b/src/nvim/normal.c index d0517d5e4f..d2716bf236 100644 --- a/src/nvim/normal.c +++ b/src/nvim/normal.c @@ -2081,11 +2081,12 @@ static void display_showcmd(void) if (ui_has(kUIMessages)) { MAXSIZE_TEMP_ARRAY(content, 1); - MAXSIZE_TEMP_ARRAY(chunk, 2); + MAXSIZE_TEMP_ARRAY(chunk, 3); if (!showcmd_is_clear) { // placeholder for future highlight support ADD_C(chunk, INTEGER_OBJ(0)); ADD_C(chunk, CSTR_AS_OBJ(showcmd_buf)); + ADD_C(chunk, INTEGER_OBJ(0)); ADD_C(content, ARRAY_OBJ(chunk)); } ui_call_msg_showcmd(content); -- cgit