From 394f69a25dc32c5b101ba2d34ac6376b0c75b2a2 Mon Sep 17 00:00:00 2001 From: Luuk van Baal Date: Fri, 20 Dec 2024 21:11:38 +0100 Subject: feat(ui): additional arguments for cmdline_show/hide events Problem: Unable to tell what highlight the prompt part of a cmdline_show event should have, and whether cmdline_hide was emitted after aborting. Solution: Add additional arguments hl_id to cmdline_show, and abort to cmdline_hide. --- runtime/doc/news.txt | 5 +++++ runtime/doc/ui.txt | 11 ++++++----- 2 files changed, 11 insertions(+), 5 deletions(-) (limited to 'runtime') diff --git a/runtime/doc/news.txt b/runtime/doc/news.txt index 011970f5eb..19c4e3b51d 100644 --- a/runtime/doc/news.txt +++ b/runtime/doc/news.txt @@ -86,6 +86,11 @@ EVENTS • |vim.ui_attach()| callbacks for |ui-messages| `msg_show` events are executed in |api-fast| context. +• Various additions for the following UI events: + • `cmdline_show`: `hl_id` to highlight the prompt text. + • `cmdline_hide`: `abort` indicating if the cmdline was aborted. + • `msg_show`: new message kinds: "bufwrite", "completion", "list_cmd", + "lua_print", "number_prompt", "search_cmd", "undo", "wildlist". HIGHLIGHTS diff --git a/runtime/doc/ui.txt b/runtime/doc/ui.txt index f531411354..0082e9d76b 100644 --- a/runtime/doc/ui.txt +++ b/runtime/doc/ui.txt @@ -715,7 +715,7 @@ Activated by the `ext_cmdline` |ui-option|. This UI extension delegates presentation of the |cmdline| (except 'wildmenu'). For command-line 'wildmenu' UI events, activate |ui-popupmenu|. -["cmdline_show", content, pos, firstc, prompt, indent, level] ~ +["cmdline_show", content, pos, firstc, prompt, indent, level, hl_id] ~ content: List of [attrs, string] [[{}, "t"], [attrs, "est"], ...] @@ -728,8 +728,8 @@ For command-line 'wildmenu' UI events, activate |ui-popupmenu|. `firstc` and `prompt` are text, that if non-empty should be displayed in front of the command line. `firstc` always indicates built-in command lines such as `:` (ex command) and `/` `?` (search), - while `prompt` is an |input()| prompt. `indent` tells how many spaces - the content should be indented. + while `prompt` is an |input()| prompt, highlighted with `hl_id`. + `indent` tells how many spaces the content should be indented. The Nvim command line can be invoked recursively, for instance by typing `=` at the command line prompt. The `level` field is used @@ -749,8 +749,9 @@ For command-line 'wildmenu' UI events, activate |ui-popupmenu|. Should be hidden at next cmdline_show. -["cmdline_hide"] ~ - Hide the cmdline. +["cmdline_hide", abort] ~ + Hide the cmdline. `abort` is true if the cmdline is hidden after an + aborting condition (|c_Esc| or |c_CTRL-C|). ["cmdline_block_show", lines] ~ Show a block of context to the current command line. For example if -- cgit From a10636fbe7bb4dba45c42c64548e5e32fe8f8d12 Mon Sep 17 00:00:00 2001 From: Luuk van Baal Date: Sun, 22 Dec 2024 13:21:57 +0100 Subject: feat(ui): specify whether msg_show event is added to history Pass along whether message in msg_show event is added to the internal :messages history. --- runtime/doc/news.txt | 12 +++++++----- runtime/doc/ui.txt | 5 ++++- 2 files changed, 11 insertions(+), 6 deletions(-) (limited to 'runtime') diff --git a/runtime/doc/news.txt b/runtime/doc/news.txt index 19c4e3b51d..8bfca39552 100644 --- a/runtime/doc/news.txt +++ b/runtime/doc/news.txt @@ -86,11 +86,13 @@ EVENTS • |vim.ui_attach()| callbacks for |ui-messages| `msg_show` events are executed in |api-fast| context. -• Various additions for the following UI events: - • `cmdline_show`: `hl_id` to highlight the prompt text. - • `cmdline_hide`: `abort` indicating if the cmdline was aborted. - • `msg_show`: new message kinds: "bufwrite", "completion", "list_cmd", - "lua_print", "number_prompt", "search_cmd", "undo", "wildlist". +• New/enhanced arguments in these existing UI events: + • `cmdline_show`: `hl_id` argument to highlight the prompt text. + • `cmdline_hide`: `abort` argument indicating if the cmdline was aborted. + • `msg_show`: + • `history` argument indicating if the message was added to the history. + • new message kinds: "bufwrite", "completion", "list_cmd", + "lua_print", "number_prompt", "search_cmd", "undo", "wildlist". HIGHLIGHTS diff --git a/runtime/doc/ui.txt b/runtime/doc/ui.txt index 0082e9d76b..1b11565eeb 100644 --- a/runtime/doc/ui.txt +++ b/runtime/doc/ui.txt @@ -784,7 +784,7 @@ will be set to zero, but can be changed and used for the replacing cmdline or message window. Cmdline state is emitted as |ui-cmdline| events, which the UI must handle. -["msg_show", kind, content, replace_last] ~ +["msg_show", kind, content, replace_last, history] ~ Display a message to the user. kind @@ -827,6 +827,9 @@ must handle. true: Replace the message in the most-recent `msg_show` call, but any other visible message should still remain. + history + True if the message was added to the |:messages| history. + ["msg_clear"] ~ Clear all messages currently displayed by "msg_show". (Messages sent by other "msg_" events below will not be affected). -- cgit