2017-09-10 01:01:18 -07:00
|
|
|
|
*ui.txt* Nvim
|
|
|
|
|
|
|
|
|
|
|
2017-10-28 14:49:41 -07:00
|
|
|
|
NVIM REFERENCE MANUAL
|
2017-09-10 01:01:18 -07:00
|
|
|
|
|
|
|
|
|
|
2019-08-25 16:00:58 -07:00
|
|
|
|
Nvim UI protocol *UI* *ui*
|
2017-09-10 01:01:18 -07:00
|
|
|
|
|
2017-10-28 14:49:41 -07:00
|
|
|
|
Type |gO| to see the table of contents.
|
2017-09-10 01:01:18 -07:00
|
|
|
|
|
|
|
|
|
==============================================================================
|
2019-08-25 16:00:58 -07:00
|
|
|
|
UI Events *ui-events*
|
2017-09-10 01:01:18 -07:00
|
|
|
|
|
2019-05-11 07:58:47 -07:00
|
|
|
|
UIs can be implemented as external client processes communicating with Nvim
|
|
|
|
|
over the RPC API. The default UI model is a terminal-like grid with a single,
|
|
|
|
|
monospace font. The UI can opt-in to have windows drawn on separate grids, and
|
|
|
|
|
have some elements ("widgets") presented by the UI itself rather than by Nvim
|
|
|
|
|
("externalized").
|
|
|
|
|
|
|
|
|
|
*ui-option*
|
|
|
|
|
Call |nvim_ui_attach()| to tell Nvim that your program wants to draw the Nvim
|
|
|
|
|
screen grid with a size of width × height cells. This is typically done by an
|
|
|
|
|
embedder at startup (see |ui-startup|), but UIs can also connect to a running
|
|
|
|
|
Nvim instance and invoke nvim_ui_attach(). The `options` parameter is a map
|
|
|
|
|
with these (optional) keys:
|
2022-09-24 17:20:47 -07:00
|
|
|
|
|
2019-05-11 07:58:47 -07:00
|
|
|
|
*ui-rgb*
|
2022-09-24 17:20:47 -07:00
|
|
|
|
- `rgb` Decides the color format.
|
2024-01-16 23:01:39 -07:00
|
|
|
|
- true: (default) 24-bit RGB colors
|
|
|
|
|
- false: Terminal colors (8-bit, max 256)
|
2022-10-14 08:01:13 -07:00
|
|
|
|
|
2019-05-11 07:58:47 -07:00
|
|
|
|
*ui-override*
|
2022-09-24 17:20:47 -07:00
|
|
|
|
- `override` Decides how UI capabilities are resolved.
|
2024-01-16 23:01:39 -07:00
|
|
|
|
- true: Enable requested UI capabilities, even if not
|
2022-09-24 17:20:47 -07:00
|
|
|
|
supported by all connected UIs (including |TUI|).
|
|
|
|
|
- false: (default) Disable UI capabilities not
|
|
|
|
|
supported by all connected UIs (including TUI).
|
2022-10-14 08:01:13 -07:00
|
|
|
|
|
2019-05-11 07:58:47 -07:00
|
|
|
|
*ui-ext-options*
|
2022-09-24 17:20:47 -07:00
|
|
|
|
- `ext_cmdline` Externalize the cmdline. |ui-cmdline|
|
|
|
|
|
- `ext_hlstate` Detailed highlight state. |ui-hlstate|
|
|
|
|
|
Sets `ext_linegrid` implicitly.
|
|
|
|
|
- `ext_linegrid` Line-based grid events. |ui-linegrid|
|
|
|
|
|
Deactivates |ui-grid-old| implicitly.
|
|
|
|
|
- `ext_messages` Externalize messages. |ui-messages|
|
|
|
|
|
Sets `ext_linegrid` and `ext_cmdline` implicitly.
|
|
|
|
|
- `ext_multigrid` Per-window grid events. |ui-multigrid|
|
|
|
|
|
Sets `ext_linegrid` implicitly.
|
|
|
|
|
- `ext_popupmenu` Externalize |popupmenu-completion| and
|
|
|
|
|
'wildmenu'. |ui-popupmenu|
|
|
|
|
|
- `ext_tabline` Externalize the tabline. |ui-tabline|
|
|
|
|
|
- `ext_termcolors` Use external default colors.
|
|
|
|
|
- `term_name` Sets the name of the terminal 'term'.
|
|
|
|
|
- `term_colors` Sets the number of supported colors 't_Co'.
|
2023-02-23 10:29:36 -07:00
|
|
|
|
- `stdin_fd` Read buffer 1 from this fd as if it were stdin |--|.
|
|
|
|
|
Only from |--embed| UI on startup. |ui-startup-stdin|
|
2023-02-21 09:07:26 -07:00
|
|
|
|
- `stdin_tty` Tells if `stdin` is a `tty` or not.
|
|
|
|
|
- `stdout_tty` Tells if `stdout` is a `tty` or not.
|
2017-09-10 01:01:18 -07:00
|
|
|
|
|
2019-05-11 07:58:47 -07:00
|
|
|
|
Specifying an unknown option is an error; UIs can check the |api-metadata|
|
|
|
|
|
`ui_options` key for supported options.
|
|
|
|
|
|
|
|
|
|
By default Nvim requires all connected UIs to support the same capabilities,
|
|
|
|
|
thus the active capabilities are the intersection of those requested. UIs may
|
|
|
|
|
specify |ui-override| to invert this behavior (useful for debugging). The
|
|
|
|
|
"option_set" event announces which capabilities are active.
|
|
|
|
|
|
|
|
|
|
Nvim sends RPC notifications to all attached UIs, with method name "redraw"
|
|
|
|
|
and a single argument: an array (batch) of screen "update events". Each update
|
|
|
|
|
event is itself an array whose first element is the event name and remaining
|
|
|
|
|
elements are event-parameter tuples. Thus multiple events of the same kind can
|
|
|
|
|
be sent contiguously without repeating the event name.
|
|
|
|
|
|
|
|
|
|
Example of a typical "redraw" batch in a single RPC notification: >
|
|
|
|
|
|
|
|
|
|
['notification', 'redraw',
|
|
|
|
|
[
|
|
|
|
|
['grid_resize', [2, 77, 36]],
|
|
|
|
|
['grid_line',
|
2023-06-01 02:15:14 -07:00
|
|
|
|
[2, 0, 0, [[' ' , 0, 77]], false],
|
|
|
|
|
[2, 1, 0, [['~', 7], [' ', 7, 76]], false],
|
|
|
|
|
[2, 9, 0, [['~', 7], [' ', 7, 76]], false],
|
2019-05-11 07:58:47 -07:00
|
|
|
|
...
|
2023-06-01 02:15:14 -07:00
|
|
|
|
[2, 35, 0, [['~', 7], [' ', 7, 76]], false],
|
|
|
|
|
[1, 36, 0, [['[', 9], ['N'], ['o'], [' '], ['N'], ['a'], ['m'], ['e'], [']']], false],
|
|
|
|
|
[1, 36, 9, [[' ', 9, 50]], false],
|
|
|
|
|
[1, 36, 59, [['0', 9], [','], ['0'], ['-' ], ['1'], [' ', 9, 10], ['A'], ['l', 9, 2]], false]
|
2019-05-11 07:58:47 -07:00
|
|
|
|
],
|
|
|
|
|
['msg_showmode', [[]]],
|
|
|
|
|
['win_pos', [2, 1000, 0, 0, 77, 36]],
|
|
|
|
|
['grid_cursor_goto', [2, 0, 0]],
|
|
|
|
|
['flush', []]
|
|
|
|
|
]
|
|
|
|
|
]
|
|
|
|
|
|
|
|
|
|
Events must be handled in-order. Nvim sends a "flush" event when it has
|
|
|
|
|
completed a redraw of the entire screen (so all windows have a consistent view
|
|
|
|
|
of buffer state, options, etc.). Multiple "redraw" batches may be sent before
|
|
|
|
|
the entire screen has been redrawn, with "flush" following only the last
|
|
|
|
|
batch. The user should only see the final state (when "flush" is sent), not
|
|
|
|
|
any intermediate state while processing part of the batch array, nor after
|
|
|
|
|
a batch not ending with "flush".
|
|
|
|
|
|
|
|
|
|
By default, Nvim sends |ui-global| and |ui-grid-old| events (for backwards
|
|
|
|
|
compatibility); these suffice to implement a terminal-like interface. However
|
|
|
|
|
the new |ui-linegrid| represents text more efficiently (especially highlighted
|
|
|
|
|
text), and allows UI capabilities requiring multiple grids. New UIs should
|
|
|
|
|
implement |ui-linegrid| instead of |ui-grid-old|.
|
|
|
|
|
|
|
|
|
|
Nvim optionally sends various screen elements "semantically" as structured
|
|
|
|
|
events instead of raw grid-lines, as specified by |ui-ext-options|. The UI
|
|
|
|
|
must present such elements itself, Nvim will not draw them on the grid.
|
2017-09-10 01:01:18 -07:00
|
|
|
|
|
|
|
|
|
Future versions of Nvim may add new update kinds and may append new parameters
|
2017-12-27 11:30:23 -07:00
|
|
|
|
to existing update kinds. Clients must be prepared to ignore such extensions,
|
|
|
|
|
for forward-compatibility. |api-contract|
|
2017-09-10 01:01:18 -07:00
|
|
|
|
|
2018-09-28 04:17:16 -07:00
|
|
|
|
==============================================================================
|
|
|
|
|
UI startup *ui-startup*
|
|
|
|
|
|
2019-04-08 18:14:27 -07:00
|
|
|
|
UI embedders (clients that start Nvim with |--embed| and later call
|
2022-11-22 10:41:00 -07:00
|
|
|
|
|nvim_ui_attach()|) must start Nvim without |--headless|: >bash
|
2019-04-08 18:14:27 -07:00
|
|
|
|
nvim --embed
|
|
|
|
|
Nvim will pause before loading startup files and reading buffers, so the UI
|
|
|
|
|
has a chance to invoke requests and do early initialization. Startup will
|
|
|
|
|
continue as soon as the UI invokes |nvim_ui_attach()|.
|
2018-09-28 04:17:16 -07:00
|
|
|
|
|
2019-04-08 18:14:27 -07:00
|
|
|
|
A simple UI only needs to do a single |nvim_ui_attach()| request and then
|
|
|
|
|
prepare to handle any UI event. A more featureful UI, which might need
|
2019-05-11 07:58:47 -07:00
|
|
|
|
additional configuration of the Nvim process, should use the following startup
|
2018-09-28 04:17:16 -07:00
|
|
|
|
procedure:
|
|
|
|
|
|
2019-04-08 18:14:27 -07:00
|
|
|
|
1. Invoke |nvim_get_api_info()|, if needed to setup the client library and/or
|
|
|
|
|
to get the list of supported UI extensions.
|
2022-10-14 08:01:13 -07:00
|
|
|
|
|
2019-04-08 18:14:27 -07:00
|
|
|
|
2. Do any configuration that should be happen before user config is loaded.
|
|
|
|
|
Buffers and windows are not available at this point, but this could be used
|
|
|
|
|
to set |g:| variables visible to init.vim
|
2022-10-14 08:01:13 -07:00
|
|
|
|
|
2019-04-08 18:14:27 -07:00
|
|
|
|
3. If the UI wants to do additional setup after user config is loaded,
|
2024-01-16 23:01:39 -07:00
|
|
|
|
register a VimEnter autocmd: >lua
|
2019-04-08 18:14:27 -07:00
|
|
|
|
nvim_command("autocmd VimEnter * call rpcrequest(1, 'vimenter')")
|
2022-10-14 08:01:13 -07:00
|
|
|
|
|
|
|
|
|
4. Now invoke |nvim_ui_attach()|. The UI must handle user input by now:
|
2019-04-08 18:14:27 -07:00
|
|
|
|
sourcing init.vim and loading buffers might lead to blocking prompts.
|
2022-10-14 08:01:13 -07:00
|
|
|
|
|
2019-04-08 18:14:27 -07:00
|
|
|
|
5. If step 3 was used, Nvim will send a blocking "vimenter" request to the UI.
|
|
|
|
|
Inside this request handler, the UI can safely do any initialization before
|
|
|
|
|
entering normal mode, for example reading variables set by init.vim.
|
2018-09-28 04:17:16 -07:00
|
|
|
|
|
2022-04-22 11:56:31 -07:00
|
|
|
|
*ui-startup-stdin*
|
|
|
|
|
An UI can support the native read from stdin feature as invoked with
|
|
|
|
|
`command | nvim -` for the builtin TUI. |--|
|
|
|
|
|
The embedding process can detect that its stdin is open to a file which
|
2023-02-21 09:07:26 -07:00
|
|
|
|
not is a terminal, just like Nvim does. It then needs to forward this fd
|
2022-04-22 11:56:31 -07:00
|
|
|
|
to Nvim. As fd=0 is already is used to send rpc data from the embedder to
|
|
|
|
|
Nvim, it needs to use some other file descriptor, like fd=3 or higher.
|
|
|
|
|
|
2023-02-21 09:07:26 -07:00
|
|
|
|
Then, `stdin_fd` option should be passed to `nvim_ui_attach` and Nvim will
|
2022-04-22 11:56:31 -07:00
|
|
|
|
implicitly read it as a buffer. This option can only be used when Nvim is
|
|
|
|
|
launched with `--embed` option, as described above.
|
|
|
|
|
|
|
|
|
|
|
2017-09-10 01:01:18 -07:00
|
|
|
|
==============================================================================
|
|
|
|
|
Global Events *ui-global*
|
|
|
|
|
|
2019-05-11 07:58:47 -07:00
|
|
|
|
The following UI events are always emitted, and describe global state of
|
2018-09-28 05:19:37 -07:00
|
|
|
|
the editor.
|
|
|
|
|
|
2022-09-24 17:20:47 -07:00
|
|
|
|
["set_title", title] ~
|
|
|
|
|
["set_icon", icon] ~
|
2017-09-10 01:01:18 -07:00
|
|
|
|
Set the window title, and icon (minimized) window title, respectively.
|
|
|
|
|
In windowing systems not distinguishing between the two, "set_icon"
|
|
|
|
|
can be ignored.
|
|
|
|
|
|
2022-09-24 17:20:47 -07:00
|
|
|
|
["mode_info_set", cursor_style_enabled, mode_info] ~
|
2017-09-10 01:01:18 -07:00
|
|
|
|
`cursor_style_enabled` is a boolean indicating if the UI should set
|
|
|
|
|
the cursor style. `mode_info` is a list of mode property maps. The
|
|
|
|
|
current mode is given by the `mode_idx` field of the `mode_change`
|
|
|
|
|
event.
|
|
|
|
|
|
2017-10-28 14:49:41 -07:00
|
|
|
|
Each mode property map may contain these keys:
|
|
|
|
|
|
2017-09-10 01:01:18 -07:00
|
|
|
|
KEY DESCRIPTION ~
|
|
|
|
|
`cursor_shape`: "block", "horizontal", "vertical"
|
|
|
|
|
`cell_percentage`: Cell % occupied by the cursor.
|
|
|
|
|
`blinkwait`, `blinkon`, `blinkoff`: See |cursor-blinking|.
|
2020-05-01 07:34:28 -07:00
|
|
|
|
`attr_id`: Cursor attribute id (defined by `hl_attr_define`).
|
|
|
|
|
When attr_id is 0, the background and foreground
|
|
|
|
|
colors should be swapped.
|
2024-01-16 23:01:39 -07:00
|
|
|
|
`attr_id_lm`: Cursor attribute id for when |:lmap| is on.
|
2017-09-10 01:01:18 -07:00
|
|
|
|
`short_name`: Mode code name, see 'guicursor'.
|
|
|
|
|
`name`: Mode descriptive name.
|
|
|
|
|
`mouse_shape`: (To be implemented.)
|
|
|
|
|
|
2017-10-28 14:49:41 -07:00
|
|
|
|
Some keys are missing in some modes.
|
2021-01-04 12:10:34 -07:00
|
|
|
|
|
2018-07-26 12:27:41 -07:00
|
|
|
|
The following keys are deprecated:
|
|
|
|
|
|
|
|
|
|
`hl_id`: Use `attr_id` instead.
|
2023-06-19 02:24:44 -07:00
|
|
|
|
`id_lm`: Use `attr_id_lm` instead.
|
2017-09-10 01:01:18 -07:00
|
|
|
|
|
2022-09-24 17:20:47 -07:00
|
|
|
|
["option_set", name, value] ~
|
2018-06-27 15:48:17 -07:00
|
|
|
|
UI-related option changed, where `name` is one of:
|
2017-12-12 10:23:19 -07:00
|
|
|
|
|
2022-09-24 17:20:47 -07:00
|
|
|
|
- 'arabicshape'
|
|
|
|
|
- 'ambiwidth'
|
|
|
|
|
- 'emoji'
|
|
|
|
|
- 'guifont'
|
|
|
|
|
- 'guifontwide'
|
|
|
|
|
- 'linespace'
|
|
|
|
|
- 'mousefocus'
|
2023-10-09 01:48:24 -07:00
|
|
|
|
- 'mousehide'
|
2022-09-24 17:20:47 -07:00
|
|
|
|
- 'mousemoveevent'
|
|
|
|
|
- 'pumblend'
|
|
|
|
|
- 'showtabline'
|
|
|
|
|
- 'termguicolors'
|
|
|
|
|
- "ext_*" (all |ui-ext-options|)
|
2018-06-27 15:48:17 -07:00
|
|
|
|
|
|
|
|
|
Triggered when the UI first connects to Nvim, and whenever an option
|
|
|
|
|
is changed by the user or a plugin.
|
|
|
|
|
|
|
|
|
|
Options are not represented here if their effects are communicated in
|
|
|
|
|
other UI events. For example, instead of forwarding the 'mouse' option
|
|
|
|
|
value, the "mouse_on" and "mouse_off" UI events directly indicate if
|
|
|
|
|
mouse support is active. Some options like 'ambiwidth' have already
|
|
|
|
|
taken effect on the grid, where appropriate empty cells are added,
|
|
|
|
|
however a UI might still use such options when rendering raw text
|
2018-11-04 18:47:22 -07:00
|
|
|
|
sent from Nvim, like for |ui-cmdline|.
|
2017-12-12 10:23:19 -07:00
|
|
|
|
|
2024-01-19 13:51:10 -07:00
|
|
|
|
["chdir", path] ~
|
|
|
|
|
The |current-directory| of the embedded Nvim process changed to
|
|
|
|
|
`path`.
|
|
|
|
|
|
2022-09-24 17:20:47 -07:00
|
|
|
|
["mode_change", mode, mode_idx] ~
|
2019-11-25 09:56:42 -07:00
|
|
|
|
Editor mode changed. The `mode` parameter is a string representing
|
|
|
|
|
the current mode. `mode_idx` is an index into the array emitted in
|
2017-09-10 01:01:18 -07:00
|
|
|
|
the `mode_info_set` event. UIs should change the cursor style
|
|
|
|
|
according to the properties specified in the corresponding item. The
|
|
|
|
|
set of modes reported will change in new versions of Nvim, for
|
|
|
|
|
instance more submodes and temporary states might be represented as
|
|
|
|
|
separate modes.
|
|
|
|
|
|
2022-09-24 17:20:47 -07:00
|
|
|
|
["mouse_on"] ~
|
|
|
|
|
["mouse_off"] ~
|
2020-12-23 09:13:13 -07:00
|
|
|
|
'mouse' was enabled/disabled in the current editor mode. Useful for
|
|
|
|
|
a terminal UI, or embedding into an application where Nvim mouse would
|
|
|
|
|
conflict with other usages of the mouse. Other UI:s may ignore this event.
|
2017-09-10 01:01:18 -07:00
|
|
|
|
|
2022-09-24 17:20:47 -07:00
|
|
|
|
["busy_start"] ~
|
|
|
|
|
["busy_stop"] ~
|
2021-06-25 10:01:57 -07:00
|
|
|
|
Indicates to the UI that it must stop rendering the cursor. This event
|
|
|
|
|
is misnamed and does not actually have anything to do with busyness.
|
2017-09-10 01:01:18 -07:00
|
|
|
|
|
2022-09-24 17:20:47 -07:00
|
|
|
|
["suspend"] ~
|
2018-09-28 04:17:16 -07:00
|
|
|
|
|:suspend| command or |CTRL-Z| mapping is used. A terminal client (or
|
|
|
|
|
another client where it makes sense) could suspend itself. Other
|
|
|
|
|
clients can safely ignore it.
|
2017-09-10 01:01:18 -07:00
|
|
|
|
|
2022-09-24 17:20:47 -07:00
|
|
|
|
["update_menu"] ~
|
2017-09-10 01:01:18 -07:00
|
|
|
|
The menu mappings changed.
|
|
|
|
|
|
2022-09-24 17:20:47 -07:00
|
|
|
|
["bell"] ~
|
|
|
|
|
["visual_bell"] ~
|
2017-09-10 01:01:18 -07:00
|
|
|
|
Notify the user with an audible or visual bell, respectively.
|
|
|
|
|
|
2022-09-24 17:20:47 -07:00
|
|
|
|
["flush"] ~
|
2018-09-29 04:28:53 -07:00
|
|
|
|
Nvim is done redrawing the screen. For an implementation that renders
|
|
|
|
|
to an internal buffer, this is the time to display the redrawn parts
|
|
|
|
|
to the user.
|
|
|
|
|
|
2017-09-10 01:01:18 -07:00
|
|
|
|
==============================================================================
|
2018-09-28 05:19:37 -07:00
|
|
|
|
Grid Events (line-based) *ui-linegrid*
|
2018-04-30 14:01:47 -07:00
|
|
|
|
|
2019-05-11 07:58:47 -07:00
|
|
|
|
Activated by the `ext_linegrid` |ui-option|. Recommended for all new UIs.
|
|
|
|
|
Deactivates |ui-grid-old| implicitly.
|
|
|
|
|
|
|
|
|
|
The biggest change compared to |ui-grid-old| is to use a single `grid_line`
|
|
|
|
|
event to update the contents of a screen line (whereas the old protocol used
|
|
|
|
|
a combination of cursor, highlight and text events)
|
2018-04-30 14:01:47 -07:00
|
|
|
|
|
|
|
|
|
Most of these events take a `grid` index as first parameter. Grid 1 is the
|
2019-05-11 07:58:47 -07:00
|
|
|
|
global grid used by default for the entire editor screen state. The
|
|
|
|
|
`ext_linegrid` capability by itself will never cause any additional grids to
|
|
|
|
|
be created; to enable per-window grids, activate |ui-multigrid|.
|
2018-04-30 14:01:47 -07:00
|
|
|
|
|
|
|
|
|
Highlight attribute groups are predefined. UIs should maintain a table to map
|
2019-04-08 18:14:27 -07:00
|
|
|
|
numerical highlight ids to the actual attributes.
|
2018-04-30 14:01:47 -07:00
|
|
|
|
|
2022-09-24 17:20:47 -07:00
|
|
|
|
["grid_resize", grid, width, height] ~
|
2018-04-30 14:01:47 -07:00
|
|
|
|
Resize a `grid`. If `grid` wasn't seen by the client before, a new grid is
|
|
|
|
|
being created with this size.
|
|
|
|
|
|
2022-09-24 17:20:47 -07:00
|
|
|
|
["default_colors_set", rgb_fg, rgb_bg, rgb_sp, cterm_fg, cterm_bg] ~
|
2018-04-30 14:01:47 -07:00
|
|
|
|
The first three arguments set the default foreground, background and
|
|
|
|
|
special colors respectively. `cterm_fg` and `cterm_bg` specifies the
|
|
|
|
|
default color codes to use in a 256-color terminal.
|
|
|
|
|
|
2019-04-08 18:14:27 -07:00
|
|
|
|
The RGB values will always be valid colors, by default. If no
|
2019-02-05 08:17:23 -07:00
|
|
|
|
colors have been set, they will default to black and white, depending
|
|
|
|
|
on 'background'. By setting the `ext_termcolors` option, instead
|
2019-04-08 18:14:27 -07:00
|
|
|
|
-1 will be used for unset colors. This is mostly useful for a TUI
|
|
|
|
|
implementation, where using the terminal builtin ("ANSI") defaults
|
|
|
|
|
are expected.
|
2019-02-05 08:17:23 -07:00
|
|
|
|
|
UI/nvim_ui_attach(): add `override` option
Before now, Nvim always degrades UI capabilities to the lowest-common
denominator. For example, if any connected UI has `ext_messages=false`
then `ext_messages=true` requested by any other connected UI is ignored.
Now `nvim_ui_attach()` supports `override=true`, which flips the
behavior: if any UI requests an `ext_*` UI capability then the
capability is enabled (and the legacy behavior is disabled).
Legacy UIs will be broken while a `override=true` UI is connected, but
it's useful for debugging: you can type into the TUI and observe the UI
events from another connected (UI) client. And the legacy UI will
"recover" after the `override=true` UI disconnects.
Example using pynvim:
>>> n.ui_attach(2048, 2048, rgb=True, override=True, ext_multigrid=True, ext_messages=True, ext_popupmenu=True)
>>> while True: n.next_message();
2019-05-09 10:35:38 -07:00
|
|
|
|
Note: Unlike the corresponding |ui-grid-old| events, the screen is not
|
|
|
|
|
always cleared after sending this event. The UI must repaint the
|
|
|
|
|
screen with changed background color itself.
|
2018-04-30 14:01:47 -07:00
|
|
|
|
|
|
|
|
|
*ui-event-hl_attr_define*
|
2022-09-24 17:20:47 -07:00
|
|
|
|
["hl_attr_define", id, rgb_attr, cterm_attr, info] ~
|
2018-04-30 14:01:47 -07:00
|
|
|
|
Add a highlight with `id` to the highlight table, with the
|
|
|
|
|
attributes specified by the `rgb_attr` and `cterm_attr` dicts, with the
|
|
|
|
|
following (all optional) keys.
|
|
|
|
|
|
2022-03-01 14:48:11 -07:00
|
|
|
|
`foreground`: foreground color.
|
|
|
|
|
`background`: background color.
|
|
|
|
|
`special`: color to use for various underlines, when
|
|
|
|
|
present.
|
|
|
|
|
`reverse`: reverse video. Foreground and background colors
|
|
|
|
|
are switched.
|
|
|
|
|
`italic`: italic text.
|
|
|
|
|
`bold`: bold text.
|
|
|
|
|
`strikethrough`: struckthrough text.
|
|
|
|
|
`underline`: underlined text. The line has `special` color.
|
|
|
|
|
`undercurl`: undercurled text. The curl has `special` color.
|
2022-06-30 01:57:44 -07:00
|
|
|
|
`underdouble`: double underlined text. The lines have `special` color.
|
|
|
|
|
`underdotted`: underdotted text. The dots have `special` color.
|
|
|
|
|
`underdashed`: underdashed text. The dashes have `special` color.
|
2023-01-19 16:18:21 -07:00
|
|
|
|
`altfont`: alternative font.
|
feat(ui): add support for OSC 8 hyperlinks (#27109)
Extmarks can contain URLs which can then be drawn in any supporting UI.
In the TUI, for example, URLs are "drawn" by emitting the OSC 8 control
sequence to the TTY. On terminals which support the OSC 8 sequence this
will create clickable hyperlinks.
URLs are treated as inline highlights in the decoration subsystem, so
are included in the `DecorSignHighlight` structure. However, unlike
other inline highlights they use allocated memory which must be freed,
so they set the `ext` flag in `DecorInline` so that their lifetimes are
managed along with other allocated memory like virtual text.
The decoration subsystem then adds the URLs as a new highlight
attribute. The highlight subsystem maintains a set of unique URLs to
avoid duplicating allocations for the same string. To attach a URL to an
existing highlight attribute we call `hl_add_url` which finds the URL in
the set (allocating and adding it if it does not exist) and sets the
`url` highlight attribute to the index of the URL in the set (using an
index helps keep the size of the `HlAttrs` struct small).
This has the potential to lead to an increase in highlight attributes
if a URL is used over a range that contains many different highlight
attributes, because now each existing attribute must be combined with
the URL. In practice, however, URLs typically span a range containing a
single highlight (e.g. link text in Markdown), so this is likely just a
pathological edge case.
When a new highlight attribute is defined with a URL it is copied to all
attached UIs with the `hl_attr_define` UI event. The TUI manages its own
set of URLs (just like the highlight subsystem) to minimize allocations.
The TUI keeps track of which URL is "active" for the cell it is
printing. If no URL is active and a cell containing a URL is printed,
the opening OSC 8 sequence is emitted and that URL becomes the actively
tracked URL. If the cursor is moved while in the middle of a URL span,
we emit the terminating OSC sequence to prevent the hyperlink from
spanning multiple lines.
This does not support nested hyperlinks, but that is a rare (and,
frankly, bizarre) use case. If a valid use case for nested hyperlinks
ever presents itself we can address that issue then.
2024-01-24 15:36:25 -07:00
|
|
|
|
`blend`: blend level (0-100). Could be used by UIs to
|
2022-03-01 14:48:11 -07:00
|
|
|
|
support blending floating windows to the
|
|
|
|
|
background or to signal a transparent cursor.
|
feat(ui): add support for OSC 8 hyperlinks (#27109)
Extmarks can contain URLs which can then be drawn in any supporting UI.
In the TUI, for example, URLs are "drawn" by emitting the OSC 8 control
sequence to the TTY. On terminals which support the OSC 8 sequence this
will create clickable hyperlinks.
URLs are treated as inline highlights in the decoration subsystem, so
are included in the `DecorSignHighlight` structure. However, unlike
other inline highlights they use allocated memory which must be freed,
so they set the `ext` flag in `DecorInline` so that their lifetimes are
managed along with other allocated memory like virtual text.
The decoration subsystem then adds the URLs as a new highlight
attribute. The highlight subsystem maintains a set of unique URLs to
avoid duplicating allocations for the same string. To attach a URL to an
existing highlight attribute we call `hl_add_url` which finds the URL in
the set (allocating and adding it if it does not exist) and sets the
`url` highlight attribute to the index of the URL in the set (using an
index helps keep the size of the `HlAttrs` struct small).
This has the potential to lead to an increase in highlight attributes
if a URL is used over a range that contains many different highlight
attributes, because now each existing attribute must be combined with
the URL. In practice, however, URLs typically span a range containing a
single highlight (e.g. link text in Markdown), so this is likely just a
pathological edge case.
When a new highlight attribute is defined with a URL it is copied to all
attached UIs with the `hl_attr_define` UI event. The TUI manages its own
set of URLs (just like the highlight subsystem) to minimize allocations.
The TUI keeps track of which URL is "active" for the cell it is
printing. If no URL is active and a cell containing a URL is printed,
the opening OSC 8 sequence is emitted and that URL becomes the actively
tracked URL. If the cursor is moved while in the middle of a URL span,
we emit the terminating OSC sequence to prevent the hyperlink from
spanning multiple lines.
This does not support nested hyperlinks, but that is a rare (and,
frankly, bizarre) use case. If a valid use case for nested hyperlinks
ever presents itself we can address that issue then.
2024-01-24 15:36:25 -07:00
|
|
|
|
`url`: a URL associated with this highlight. UIs can
|
|
|
|
|
display this URL however they wish.
|
2018-04-30 14:01:47 -07:00
|
|
|
|
|
|
|
|
|
For absent color keys the default color should be used. Don't store
|
|
|
|
|
the default value in the table, rather a sentinel value, so that
|
|
|
|
|
a changed default color will take effect.
|
|
|
|
|
All boolean keys default to false, and will only be sent when they
|
|
|
|
|
are true.
|
|
|
|
|
|
2019-04-08 18:14:27 -07:00
|
|
|
|
Highlights are always transmitted both for both the RGB format and as
|
2018-04-30 14:01:47 -07:00
|
|
|
|
terminal 256-color codes, as the `rgb_attr` and `cterm_attr` parameters
|
2023-05-13 12:33:22 -07:00
|
|
|
|
respectively. The |ui-rgb| option has no effect anymore.
|
2018-04-30 14:01:47 -07:00
|
|
|
|
Most external UIs will only need to store and use the `rgb_attr`
|
|
|
|
|
attributes.
|
|
|
|
|
|
|
|
|
|
`id` 0 will always be used for the default highlight with colors defined
|
|
|
|
|
by `default_colors_set` and no styles applied.
|
|
|
|
|
|
2019-04-08 18:14:27 -07:00
|
|
|
|
Note: Nvim may reuse `id` values if its internal highlight table is full.
|
|
|
|
|
In that case Nvim will always issue redraws of screen cells that are
|
|
|
|
|
affected by redefined ids, so UIs do not need to keep track of this
|
2018-04-30 14:01:47 -07:00
|
|
|
|
themselves.
|
|
|
|
|
|
2019-04-08 18:14:27 -07:00
|
|
|
|
`info` is an empty array by default, and will be used by the
|
|
|
|
|
|ui-hlstate| extension explained below.
|
2018-04-30 14:01:47 -07:00
|
|
|
|
|
2022-09-24 17:20:47 -07:00
|
|
|
|
["hl_group_set", name, hl_id] ~
|
2023-05-13 12:33:22 -07:00
|
|
|
|
The built-in highlight group `name` was set to use the attributes `hl_id`
|
2019-07-14 04:26:40 -07:00
|
|
|
|
defined by a previous `hl_attr_define` call. This event is not needed
|
|
|
|
|
to render the grids which use attribute ids directly, but is useful
|
2023-02-21 09:07:26 -07:00
|
|
|
|
for a UI who want to render its own elements with consistent
|
|
|
|
|
highlighting. For instance a UI using |ui-popupmenu| events, might
|
2019-07-14 04:26:40 -07:00
|
|
|
|
use the |hl-Pmenu| family of builtin highlights.
|
|
|
|
|
|
2018-04-30 14:01:47 -07:00
|
|
|
|
*ui-event-grid_line*
|
2023-06-01 02:15:14 -07:00
|
|
|
|
["grid_line", grid, row, col_start, cells, wrap] ~
|
2019-04-08 18:14:27 -07:00
|
|
|
|
Redraw a continuous part of a `row` on a `grid`, starting at the column
|
2018-04-30 14:01:47 -07:00
|
|
|
|
`col_start`. `cells` is an array of arrays each with 1 to 3 items:
|
|
|
|
|
`[text(, hl_id, repeat)]` . `text` is the UTF-8 text that should be put in
|
|
|
|
|
a cell, with the highlight `hl_id` defined by a previous `hl_attr_define`
|
|
|
|
|
call. If `hl_id` is not present the most recently seen `hl_id` in
|
|
|
|
|
the same call should be used (it is always sent for the first
|
|
|
|
|
cell in the event). If `repeat` is present, the cell should be
|
|
|
|
|
repeated `repeat` times (including the first time), otherwise just
|
|
|
|
|
once.
|
|
|
|
|
|
|
|
|
|
The right cell of a double-width char will be represented as the empty
|
|
|
|
|
string. Double-width chars never use `repeat`.
|
|
|
|
|
|
|
|
|
|
If the array of cell changes doesn't reach to the end of the line, the
|
|
|
|
|
rest should remain unchanged. A whitespace char, repeated
|
|
|
|
|
enough to cover the remaining line, will be sent when the rest of the
|
|
|
|
|
line should be cleared.
|
|
|
|
|
|
2023-06-01 02:15:14 -07:00
|
|
|
|
`wrap` is a boolean indicating that this line wraps to the next row.
|
|
|
|
|
When redrawing a line which wraps to the next row, Nvim will emit a
|
|
|
|
|
`grid_line` event covering the last column of the line with `wrap` set
|
|
|
|
|
to true, followed immediately by a `grid_line` event starting at the
|
|
|
|
|
first column of the next row.
|
|
|
|
|
|
2022-09-24 17:20:47 -07:00
|
|
|
|
["grid_clear", grid] ~
|
2018-04-30 14:01:47 -07:00
|
|
|
|
Clear a `grid`.
|
|
|
|
|
|
2022-09-24 17:20:47 -07:00
|
|
|
|
["grid_destroy", grid] ~
|
2018-04-30 14:01:47 -07:00
|
|
|
|
`grid` will not be used anymore and the UI can free any data associated
|
|
|
|
|
with it.
|
|
|
|
|
|
2022-09-24 17:20:47 -07:00
|
|
|
|
["grid_cursor_goto", grid, row, column] ~
|
2018-04-30 14:01:47 -07:00
|
|
|
|
Makes `grid` the current grid and `row, column` the cursor position on this
|
|
|
|
|
grid. This event will be sent at most once in a `redraw` batch and
|
|
|
|
|
indicates the visible cursor position.
|
|
|
|
|
|
2022-09-24 17:20:47 -07:00
|
|
|
|
["grid_scroll", grid, top, bot, left, right, rows, cols] ~
|
2019-03-27 03:11:52 -07:00
|
|
|
|
Scroll a region of `grid`. This is semantically unrelated to editor
|
|
|
|
|
|scrolling|, rather this is an optimized way to say "copy these screen
|
|
|
|
|
cells".
|
|
|
|
|
|
|
|
|
|
The following diagrams show what happens per scroll direction.
|
|
|
|
|
"===" represents the SR (scroll region) boundaries.
|
|
|
|
|
"---" represents the moved rectangles.
|
2018-04-30 14:01:47 -07:00
|
|
|
|
Note that dst and src share a common region.
|
|
|
|
|
|
|
|
|
|
If `rows` is bigger than 0, move a rectangle in the SR up, this can
|
|
|
|
|
happen while scrolling down.
|
|
|
|
|
>
|
|
|
|
|
+-------------------------+
|
|
|
|
|
| (clipped above SR) | ^
|
|
|
|
|
|=========================| dst_top |
|
|
|
|
|
| dst (still in SR) | |
|
|
|
|
|
+-------------------------+ src_top |
|
|
|
|
|
| src (moved up) and dst | |
|
|
|
|
|
|-------------------------| dst_bot |
|
2018-11-03 06:40:22 -07:00
|
|
|
|
| src (invalid) | |
|
2018-04-30 14:01:47 -07:00
|
|
|
|
+=========================+ src_bot
|
|
|
|
|
<
|
|
|
|
|
If `rows` is less than zero, move a rectangle in the SR down, this can
|
|
|
|
|
happen while scrolling up.
|
|
|
|
|
>
|
|
|
|
|
+=========================+ src_top
|
2018-11-03 06:40:22 -07:00
|
|
|
|
| src (invalid) | |
|
2018-04-30 14:01:47 -07:00
|
|
|
|
|------------------------ | dst_top |
|
|
|
|
|
| src (moved down) and dst| |
|
|
|
|
|
+-------------------------+ src_bot |
|
|
|
|
|
| dst (still in SR) | |
|
|
|
|
|
|=========================| dst_bot |
|
|
|
|
|
| (clipped below SR) | v
|
|
|
|
|
+-------------------------+
|
|
|
|
|
<
|
|
|
|
|
`cols` is always zero in this version of Nvim, and reserved for future
|
2023-07-25 05:07:13 -07:00
|
|
|
|
use.
|
2018-04-30 14:01:47 -07:00
|
|
|
|
|
|
|
|
|
Note when updating code from |ui-grid-old| events: ranges are
|
|
|
|
|
end-exclusive, which is consistent with API conventions, but different
|
|
|
|
|
from `set_scroll_region` which was end-inclusive.
|
|
|
|
|
|
2018-11-03 06:40:22 -07:00
|
|
|
|
The scrolled-in area will be filled using |ui-event-grid_line| directly
|
|
|
|
|
after the scroll event. The UI thus doesn't need to clear this area as
|
|
|
|
|
part of handling the scroll event.
|
|
|
|
|
|
2018-04-30 14:01:47 -07:00
|
|
|
|
==============================================================================
|
2019-05-11 07:58:47 -07:00
|
|
|
|
Grid Events (cell-based) *ui-grid-old*
|
2018-04-30 14:01:47 -07:00
|
|
|
|
|
2019-05-11 07:58:47 -07:00
|
|
|
|
This is the legacy representation of the screen grid, emitted if |ui-linegrid|
|
|
|
|
|
is not active. New UIs should implement |ui-linegrid| instead.
|
2017-09-10 01:01:18 -07:00
|
|
|
|
|
2022-09-24 17:20:47 -07:00
|
|
|
|
["resize", width, height] ~
|
2017-09-10 01:01:18 -07:00
|
|
|
|
The grid is resized to `width` and `height` cells.
|
|
|
|
|
|
2022-09-24 17:20:47 -07:00
|
|
|
|
["clear"] ~
|
2017-09-10 01:01:18 -07:00
|
|
|
|
Clear the grid.
|
|
|
|
|
|
2022-09-24 17:20:47 -07:00
|
|
|
|
["eol_clear"] ~
|
2017-09-10 01:01:18 -07:00
|
|
|
|
Clear from the cursor position to the end of the current line.
|
|
|
|
|
|
2022-09-24 17:20:47 -07:00
|
|
|
|
["cursor_goto", row, col] ~
|
2017-09-10 01:01:18 -07:00
|
|
|
|
Move the cursor to position (row, col). Currently, the same cursor is
|
|
|
|
|
used to define the position for text insertion and the visible cursor.
|
|
|
|
|
However, only the last cursor position, after processing the entire
|
|
|
|
|
array in the "redraw" event, is intended to be a visible cursor
|
|
|
|
|
position.
|
|
|
|
|
|
2022-09-24 17:20:47 -07:00
|
|
|
|
["update_fg", color] ~
|
|
|
|
|
["update_bg", color] ~
|
|
|
|
|
["update_sp", color] ~
|
2017-09-10 01:01:18 -07:00
|
|
|
|
Set the default foreground, background and special colors
|
|
|
|
|
respectively.
|
|
|
|
|
|
2018-04-30 14:01:47 -07:00
|
|
|
|
*ui-event-highlight_set*
|
2022-09-24 17:20:47 -07:00
|
|
|
|
["highlight_set", attrs] ~
|
2017-09-10 01:01:18 -07:00
|
|
|
|
Set the attributes that the next text put on the grid will have.
|
|
|
|
|
`attrs` is a dict with the keys below. Any absent key is reset
|
|
|
|
|
to its default value. Color defaults are set by the `update_fg` etc
|
|
|
|
|
updates. All boolean keys default to false.
|
|
|
|
|
|
|
|
|
|
`foreground`: foreground color.
|
2019-04-08 18:14:27 -07:00
|
|
|
|
`background`: background color.
|
2022-03-01 14:48:11 -07:00
|
|
|
|
`special`: color to use for various underlines, when present.
|
2017-09-10 01:01:18 -07:00
|
|
|
|
`reverse`: reverse video. Foreground and background colors are
|
|
|
|
|
switched.
|
|
|
|
|
`italic`: italic text.
|
|
|
|
|
`bold`: bold text.
|
2019-09-13 14:46:19 -07:00
|
|
|
|
`strikethrough`: struckthrough text.
|
2017-09-10 01:01:18 -07:00
|
|
|
|
`underline`: underlined text. The line has `special` color.
|
|
|
|
|
`undercurl`: undercurled text. The curl has `special` color.
|
2022-06-30 01:57:44 -07:00
|
|
|
|
`underdouble`: double underlined text. The lines have `special` color.
|
|
|
|
|
`underdotted`: underdotted text. The dots have `special` color.
|
|
|
|
|
`underdashed`: underdashed text. The dashes have `special` color.
|
2017-09-10 01:01:18 -07:00
|
|
|
|
|
2022-09-24 17:20:47 -07:00
|
|
|
|
["put", text] ~
|
2017-09-10 01:01:18 -07:00
|
|
|
|
The (utf-8 encoded) string `text` is put at the cursor position
|
|
|
|
|
(and the cursor is advanced), with the highlights as set by the
|
|
|
|
|
last `highlight_set` update.
|
|
|
|
|
|
2022-09-24 17:20:47 -07:00
|
|
|
|
["set_scroll_region", top, bot, left, right] ~
|
2017-09-10 01:01:18 -07:00
|
|
|
|
Define the scroll region used by `scroll` below.
|
2021-01-04 12:10:34 -07:00
|
|
|
|
|
2018-04-30 14:01:47 -07:00
|
|
|
|
Note: ranges are end-inclusive, which is inconsistent with API
|
|
|
|
|
conventions.
|
2017-09-10 01:01:18 -07:00
|
|
|
|
|
2022-09-24 17:20:47 -07:00
|
|
|
|
["scroll", count] ~
|
2017-09-10 01:01:18 -07:00
|
|
|
|
Scroll the text in the scroll region. The diagrams below illustrate
|
|
|
|
|
what will happen, depending on the scroll direction. "=" is used to
|
|
|
|
|
represent the SR(scroll region) boundaries and "-" the moved rectangles.
|
|
|
|
|
Note that dst and src share a common region.
|
|
|
|
|
|
|
|
|
|
If count is bigger than 0, move a rectangle in the SR up, this can
|
|
|
|
|
happen while scrolling down.
|
|
|
|
|
>
|
|
|
|
|
+-------------------------+
|
|
|
|
|
| (clipped above SR) | ^
|
|
|
|
|
|=========================| dst_top |
|
|
|
|
|
| dst (still in SR) | |
|
|
|
|
|
+-------------------------+ src_top |
|
|
|
|
|
| src (moved up) and dst | |
|
|
|
|
|
|-------------------------| dst_bot |
|
|
|
|
|
| src (cleared) | |
|
|
|
|
|
+=========================+ src_bot
|
|
|
|
|
<
|
|
|
|
|
If count is less than zero, move a rectangle in the SR down, this can
|
|
|
|
|
happen while scrolling up.
|
|
|
|
|
>
|
|
|
|
|
+=========================+ src_top
|
|
|
|
|
| src (cleared) | |
|
|
|
|
|
|------------------------ | dst_top |
|
|
|
|
|
| src (moved down) and dst| |
|
|
|
|
|
+-------------------------+ src_bot |
|
|
|
|
|
| dst (still in SR) | |
|
|
|
|
|
|=========================| dst_bot |
|
|
|
|
|
| (clipped below SR) | v
|
|
|
|
|
+-------------------------+
|
|
|
|
|
<
|
2018-04-30 14:01:47 -07:00
|
|
|
|
==============================================================================
|
2023-02-21 09:07:26 -07:00
|
|
|
|
Detailed highlight state Extension *ui-hlstate*
|
2018-04-30 14:01:47 -07:00
|
|
|
|
|
2019-05-11 07:58:47 -07:00
|
|
|
|
Activated by the `ext_hlstate` |ui-option|.
|
|
|
|
|
Activates |ui-linegrid| implicitly.
|
2018-04-30 14:01:47 -07:00
|
|
|
|
|
2019-04-08 14:08:01 -07:00
|
|
|
|
By default Nvim will only describe grid cells using the final calculated
|
|
|
|
|
highlight attributes, as described by the dict keys in |ui-event-highlight_set|.
|
2018-04-30 14:01:47 -07:00
|
|
|
|
The `ext_hlstate` extension allows to the UI to also receive a semantic
|
2019-04-08 14:08:01 -07:00
|
|
|
|
description of the highlights active in a cell. In this mode highlights will be
|
2018-04-30 14:01:47 -07:00
|
|
|
|
predefined in a table, see |ui-event-hl_attr_define| and |ui-event-grid_line|.
|
|
|
|
|
The `info` parameter in `hl_attr_define` will contain a semantic description
|
|
|
|
|
of the highlights. As highlight groups can be combined, this will be an array
|
|
|
|
|
of items, with the item with highest priority last. Each item is a dictionary
|
|
|
|
|
with the following possible keys:
|
|
|
|
|
|
|
|
|
|
`kind`: always present. One of the following values:
|
2019-04-08 14:08:01 -07:00
|
|
|
|
"ui": Builtin UI highlight. |highlight-groups|
|
|
|
|
|
"syntax": Highlight applied to a buffer by a syntax declaration or
|
2024-01-16 23:01:39 -07:00
|
|
|
|
other runtime/plugin functionality such as
|
2018-08-25 07:38:24 -07:00
|
|
|
|
|nvim_buf_add_highlight()|
|
2018-04-30 14:01:47 -07:00
|
|
|
|
"terminal": highlight from a process running in a |terminal-emulator|.
|
2019-04-08 14:08:01 -07:00
|
|
|
|
Contains no further semantic information.
|
|
|
|
|
`ui_name`: Highlight name from |highlight-groups|. Only for "ui" kind.
|
2018-04-30 14:01:47 -07:00
|
|
|
|
`hi_name`: Name of the final |:highlight| group where the used
|
|
|
|
|
attributes are defined.
|
|
|
|
|
`id`: Unique numeric id representing this item.
|
|
|
|
|
|
|
|
|
|
Note: "ui" items will have both `ui_name` and `hi_name` present. These can
|
2018-08-25 07:38:24 -07:00
|
|
|
|
differ, because the builtin group was linked to another group |:hi-link| , or
|
2018-04-30 14:01:47 -07:00
|
|
|
|
because 'winhighlight' was used. UI items will be transmitted, even if the
|
|
|
|
|
highlight group is cleared, so `ui_name` can always be used to reliably identify
|
|
|
|
|
screen elements, even if no attributes have been applied.
|
|
|
|
|
|
2018-06-28 03:05:19 -07:00
|
|
|
|
==============================================================================
|
2023-02-21 09:07:26 -07:00
|
|
|
|
Multigrid Events *ui-multigrid*
|
2018-06-28 03:05:19 -07:00
|
|
|
|
|
2019-05-11 07:58:47 -07:00
|
|
|
|
Activated by the `ext_multigrid` |ui-option|.
|
|
|
|
|
Activates |ui-linegrid| implicitly.
|
2018-06-28 03:05:19 -07:00
|
|
|
|
|
2019-05-11 07:58:47 -07:00
|
|
|
|
See |ui-linegrid| for grid events.
|
|
|
|
|
See |nvim_ui_try_resize_grid()| to request changing the grid size.
|
|
|
|
|
See |nvim_input_mouse()| for sending mouse events to Nvim.
|
|
|
|
|
|
|
|
|
|
The multigrid extension gives UIs more control over how windows are displayed:
|
|
|
|
|
- UIs receive updates on a separate grid for each window.
|
|
|
|
|
- UIs can set the grid size independently of how much space the window
|
|
|
|
|
occupies on the global layout. So the UI could use a different font size
|
|
|
|
|
per-window. Or reserve space around the border of the window for its own
|
|
|
|
|
elements, such as scrollbars from the UI toolkit.
|
2019-07-02 06:53:43 -07:00
|
|
|
|
- A dedicated grid is used for messages, which may scroll over the window
|
2022-09-25 16:58:27 -07:00
|
|
|
|
area. (Alternatively |ui-messages| can be used).
|
2019-05-11 07:58:47 -07:00
|
|
|
|
|
|
|
|
|
By default, the grid size is handled by Nvim and set to the outer grid size
|
|
|
|
|
(i.e. the size of the window frame in Nvim) whenever the split is created.
|
|
|
|
|
Once a UI sets a grid size, Nvim does not handle the size for that grid and
|
2018-12-18 09:46:54 -07:00
|
|
|
|
the UI must change the grid size whenever the outer size is changed. To
|
2019-05-11 07:58:47 -07:00
|
|
|
|
delegate grid-size handling back to Nvim, request the size (0, 0).
|
2018-06-28 03:05:19 -07:00
|
|
|
|
|
2018-12-18 09:46:54 -07:00
|
|
|
|
A window can be hidden and redisplayed without its grid being deallocated.
|
|
|
|
|
This can happen multiple times for the same window, for instance when switching
|
|
|
|
|
tabs.
|
2018-06-28 03:05:19 -07:00
|
|
|
|
|
2022-09-24 17:20:47 -07:00
|
|
|
|
["win_pos", grid, win, start_row, start_col, width, height] ~
|
2019-05-11 07:58:47 -07:00
|
|
|
|
Set the position and size of the grid in Nvim (i.e. the outer grid
|
2018-06-28 03:05:19 -07:00
|
|
|
|
size). If the window was previously hidden, it should now be shown
|
|
|
|
|
again.
|
|
|
|
|
|
2022-09-24 17:20:47 -07:00
|
|
|
|
["win_float_pos", grid, win, anchor, anchor_grid, anchor_row, anchor_col, focusable] ~
|
2017-04-26 06:28:10 -07:00
|
|
|
|
Display or reconfigure floating window `win`. The window should be
|
|
|
|
|
displayed above another grid `anchor_grid` at the specified position
|
|
|
|
|
`anchor_row` and `anchor_col`. For the meaning of `anchor` and more
|
|
|
|
|
details of positioning, see |nvim_open_win()|.
|
|
|
|
|
|
2022-09-24 17:20:47 -07:00
|
|
|
|
["win_external_pos", grid, win] ~
|
2017-04-26 06:28:10 -07:00
|
|
|
|
Display or reconfigure external window `win`. The window should be
|
2019-04-08 18:14:27 -07:00
|
|
|
|
displayed as a separate top-level window in the desktop environment,
|
2017-04-26 06:28:10 -07:00
|
|
|
|
or something similar.
|
|
|
|
|
|
2022-09-24 17:20:47 -07:00
|
|
|
|
["win_hide", grid] ~
|
2017-04-26 06:28:10 -07:00
|
|
|
|
Stop displaying the window. The window can be shown again later.
|
2018-06-28 03:05:19 -07:00
|
|
|
|
|
2022-09-24 17:20:47 -07:00
|
|
|
|
["win_close", grid] ~
|
2017-04-26 06:28:10 -07:00
|
|
|
|
Close the window.
|
|
|
|
|
|
2022-09-24 17:20:47 -07:00
|
|
|
|
["msg_set_pos", grid, row, scrolled, sep_char] ~
|
2022-09-27 07:19:15 -07:00
|
|
|
|
Display messages on `grid`. The grid will be displayed at `row` on
|
|
|
|
|
the default grid (grid=1), covering the full column width. `scrolled`
|
2019-07-02 06:53:43 -07:00
|
|
|
|
indicates whether the message area has been scrolled to cover other
|
2022-09-27 07:19:15 -07:00
|
|
|
|
grids. It can be useful to draw a separator then |msgsep|. The Builtin
|
|
|
|
|
TUI draws a full line filled with `sep_char` ('fillchars' msgsep
|
|
|
|
|
field) and |hl-MsgSeparator| highlight.
|
2019-07-02 06:53:43 -07:00
|
|
|
|
|
2022-09-25 16:58:27 -07:00
|
|
|
|
When |ui-messages| is active, no message grid is used, and this event
|
2019-07-02 06:53:43 -07:00
|
|
|
|
will not be sent.
|
|
|
|
|
|
2023-03-12 15:58:46 -07:00
|
|
|
|
["win_viewport", grid, win, topline, botline, curline, curcol, line_count, scroll_delta] ~
|
2020-01-23 10:05:04 -07:00
|
|
|
|
Indicates the range of buffer text displayed in the window, as well
|
|
|
|
|
as the cursor position in the buffer. All positions are zero-based.
|
|
|
|
|
`botline` is set to one more than the line count of the buffer, if
|
2023-03-12 15:58:46 -07:00
|
|
|
|
there are filler lines past the end. `scroll_delta` contains how much
|
|
|
|
|
the top line of a window moved since `win_viewport` was last emitted.
|
|
|
|
|
It is intended to be used to implement smooth scrolling. For this
|
|
|
|
|
purpose it only counts "virtual" or "displayed" lines, so folds
|
2023-07-04 01:48:53 -07:00
|
|
|
|
only count as one line. When scrolling more than a full screen it is
|
|
|
|
|
an approximate value.
|
2020-01-23 10:05:04 -07:00
|
|
|
|
|
fix(ui): delay win_viewport until screen update #24182
Problem:
Sometimes, when nvim sends the `win_viewport` event, for example when scrolling
with visible folds on the screen, it reports the `scroll_delta` value one batch
into "future". So when the client application is trying to show the new viewport
it's not yet updated, resulting in temporary corruption / screen flickering.
For more details see #23609, and starting from [this comment](
https://github.com/neovide/neovide/pull/1790#issuecomment-1518697747) in
https://github.com/neovide/neovide/pull/1790,, where the issue was first
detected. Note that some of the conclusions in those are not fully accurate, but
the general observations are.
Solution:
When there are pending updates to a Window, delay the `win_viewport` UI event
until the updates are sent. This ensures that there's no flush between sending
the viewport and updating of the lines corresponding to the new viewport.
Document the existing viewport behaviour (for cases where there are no
extra flushes), give a hint about how applications can deal with the slightly
surprising behaviour of the viewport event being sent after the updates.
Fixes https://github.com/neovim/neovim/issues/23609
2023-07-05 06:31:34 -07:00
|
|
|
|
All updates, such as `grid_line`, in a batch affects the new viewport,
|
|
|
|
|
despite the fact that `win_viewport` is received after the updates.
|
|
|
|
|
Applications implementing, for example, smooth scrolling should take
|
|
|
|
|
this into account and keep the grid separated from what's displayed on
|
|
|
|
|
the screen and copy it to the viewport destination once `win_viewport`
|
|
|
|
|
is received.
|
|
|
|
|
|
2022-09-24 17:20:47 -07:00
|
|
|
|
["win_extmark", grid, win, ns_id, mark_id, row, col] ~
|
2021-09-15 16:53:56 -07:00
|
|
|
|
Updates the position of an extmark which is currently visible in a
|
2023-07-25 05:07:13 -07:00
|
|
|
|
window. Only emitted if the mark has the `ui_watched` attribute.
|
2021-09-15 16:53:56 -07:00
|
|
|
|
|
2017-09-10 01:01:18 -07:00
|
|
|
|
==============================================================================
|
|
|
|
|
Popupmenu Events *ui-popupmenu*
|
|
|
|
|
|
2019-05-11 07:58:47 -07:00
|
|
|
|
Activated by the `ext_popupmenu` |ui-option|.
|
|
|
|
|
|
|
|
|
|
This UI extension delegates presentation of the |popupmenu-completion| and
|
|
|
|
|
command-line 'wildmenu'.
|
2017-09-10 01:01:18 -07:00
|
|
|
|
|
2022-09-24 17:20:47 -07:00
|
|
|
|
["popupmenu_show", items, selected, row, col, grid] ~
|
2017-10-31 02:45:06 -07:00
|
|
|
|
Show |popupmenu-completion|. `items` is an array of completion items
|
|
|
|
|
to show; each item is an array of the form [word, kind, menu, info] as
|
|
|
|
|
defined at |complete-items|, except that `word` is replaced by `abbr`
|
|
|
|
|
if present. `selected` is the initially-selected item, a zero-based
|
|
|
|
|
index into the array of items (-1 if no item is selected). `row` and
|
|
|
|
|
`col` give the anchor position, where the first character of the
|
2018-06-28 03:05:19 -07:00
|
|
|
|
completed word will be. When |ui-multigrid| is used, `grid` is the
|
2019-03-04 02:59:44 -07:00
|
|
|
|
grid for the anchor position. When `ext_cmdline` is active, `grid` is
|
|
|
|
|
set to -1 to indicate the popupmenu should be anchored to the external
|
|
|
|
|
cmdline. Then `col` will be a byte position in the cmdline text.
|
2017-09-10 01:01:18 -07:00
|
|
|
|
|
2022-09-24 17:20:47 -07:00
|
|
|
|
["popupmenu_select", selected] ~
|
2017-10-31 02:45:06 -07:00
|
|
|
|
Select an item in the current popupmenu. `selected` is a zero-based
|
|
|
|
|
index into the array of items from the last popupmenu_show event, or
|
|
|
|
|
-1 if no item is selected.
|
2017-09-10 01:01:18 -07:00
|
|
|
|
|
2022-09-24 17:20:47 -07:00
|
|
|
|
["popupmenu_hide"] ~
|
2017-10-31 02:45:06 -07:00
|
|
|
|
Hide the popupmenu.
|
2017-09-10 01:01:18 -07:00
|
|
|
|
|
|
|
|
|
==============================================================================
|
|
|
|
|
Tabline Events *ui-tabline*
|
|
|
|
|
|
2019-05-11 07:58:47 -07:00
|
|
|
|
Activated by the `ext_tabline` |ui-option|.
|
2017-09-10 01:01:18 -07:00
|
|
|
|
|
2022-09-24 17:20:47 -07:00
|
|
|
|
["tabline_update", curtab, tabs, curbuf, buffers] ~
|
2017-09-10 01:01:18 -07:00
|
|
|
|
Tabline was updated. UIs should present this data in a custom tabline
|
2021-06-27 12:30:09 -07:00
|
|
|
|
widget. Note: options `curbuf` + `buffers` were added in API7.
|
|
|
|
|
curtab: Current Tabpage
|
|
|
|
|
tabs: List of Dicts [{ "tab": Tabpage, "name": String }, ...]
|
|
|
|
|
curbuf: Current buffer handle.
|
|
|
|
|
buffers: List of Dicts [{ "buffer": buffer handle, "name": String}, ...]
|
2017-09-10 01:01:18 -07:00
|
|
|
|
|
|
|
|
|
==============================================================================
|
|
|
|
|
Cmdline Events *ui-cmdline*
|
|
|
|
|
|
2019-05-11 07:58:47 -07:00
|
|
|
|
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|.
|
2017-09-10 01:01:18 -07:00
|
|
|
|
|
2022-09-24 17:20:47 -07:00
|
|
|
|
["cmdline_show", content, pos, firstc, prompt, indent, level] ~
|
2017-09-10 01:01:18 -07:00
|
|
|
|
content: List of [attrs, string]
|
|
|
|
|
[[{}, "t"], [attrs, "est"], ...]
|
2017-10-28 14:49:41 -07:00
|
|
|
|
|
2017-10-29 00:04:42 -07:00
|
|
|
|
Triggered when the cmdline is displayed or changed.
|
2017-09-10 01:01:18 -07:00
|
|
|
|
The `content` is the full content that should be displayed in the
|
|
|
|
|
cmdline, and the `pos` is the position of the cursor that in the
|
2017-10-28 14:49:41 -07:00
|
|
|
|
cmdline. The content is divided into chunks with different highlight
|
|
|
|
|
attributes represented as a dict (see |ui-event-highlight_set|).
|
2017-09-10 01:01:18 -07:00
|
|
|
|
|
|
|
|
|
`firstc` and `prompt` are text, that if non-empty should be
|
|
|
|
|
displayed in front of the command line. `firstc` always indicates
|
2017-10-28 14:49:41 -07:00
|
|
|
|
built-in command lines such as `:` (ex command) and `/` `?` (search),
|
2017-09-10 01:01:18 -07:00
|
|
|
|
while `prompt` is an |input()| prompt. `indent` tells how many spaces
|
2017-10-28 14:49:41 -07:00
|
|
|
|
the content should be indented.
|
2017-09-10 01:01:18 -07:00
|
|
|
|
|
2017-10-28 14:49:41 -07:00
|
|
|
|
The Nvim command line can be invoked recursively, for instance by
|
2017-09-10 01:01:18 -07:00
|
|
|
|
typing `<c-r>=` at the command line prompt. The `level` field is used
|
|
|
|
|
to distinguish different command lines active at the same time. The
|
2017-10-28 14:49:41 -07:00
|
|
|
|
first invoked command line has level 1, the next recursively-invoked
|
2018-08-25 07:38:24 -07:00
|
|
|
|
prompt has level 2. A command line invoked from the |cmdline-window|
|
2023-05-13 12:33:22 -07:00
|
|
|
|
has a higher level than the edited command line.
|
2017-09-10 01:01:18 -07:00
|
|
|
|
|
2022-09-24 17:20:47 -07:00
|
|
|
|
["cmdline_pos", pos, level] ~
|
2017-09-10 01:01:18 -07:00
|
|
|
|
Change the cursor position in the cmdline.
|
|
|
|
|
|
2022-09-24 17:20:47 -07:00
|
|
|
|
["cmdline_special_char", c, shift, level] ~
|
2017-09-10 01:01:18 -07:00
|
|
|
|
Display a special char in the cmdline at the cursor position. This is
|
2017-10-28 14:49:41 -07:00
|
|
|
|
typically used to indicate a pending state, e.g. after |c_CTRL-V|. If
|
|
|
|
|
`shift` is true the text after the cursor should be shifted, otherwise
|
|
|
|
|
it should overwrite the char at the cursor.
|
|
|
|
|
|
2017-11-03 01:34:31 -07:00
|
|
|
|
Should be hidden at next cmdline_show.
|
2017-09-10 01:01:18 -07:00
|
|
|
|
|
2022-09-24 17:20:47 -07:00
|
|
|
|
["cmdline_hide"] ~
|
2017-09-10 01:01:18 -07:00
|
|
|
|
Hide the cmdline.
|
|
|
|
|
|
2022-09-24 17:20:47 -07:00
|
|
|
|
["cmdline_block_show", lines] ~
|
2017-10-28 14:49:41 -07:00
|
|
|
|
Show a block of context to the current command line. For example if
|
2022-11-22 10:41:00 -07:00
|
|
|
|
the user defines a |:function| interactively: >vim
|
2017-10-28 14:49:41 -07:00
|
|
|
|
:function Foo()
|
|
|
|
|
: echo "foo"
|
|
|
|
|
:
|
|
|
|
|
<
|
|
|
|
|
`lines` is a list of lines of highlighted chunks, in the same form as
|
|
|
|
|
the "cmdline_show" `contents` parameter.
|
2017-09-10 01:01:18 -07:00
|
|
|
|
|
2022-09-24 17:20:47 -07:00
|
|
|
|
["cmdline_block_append", line] ~
|
2017-09-10 01:01:18 -07:00
|
|
|
|
Append a line at the end of the currently shown block.
|
|
|
|
|
|
2022-09-24 17:20:47 -07:00
|
|
|
|
["cmdline_block_hide"] ~
|
2017-09-10 01:01:18 -07:00
|
|
|
|
Hide the block.
|
|
|
|
|
|
2017-10-31 08:46:02 -07:00
|
|
|
|
==============================================================================
|
2019-05-11 07:58:47 -07:00
|
|
|
|
Message/Dialog Events *ui-messages*
|
2017-10-31 08:46:02 -07:00
|
|
|
|
|
2019-05-11 07:58:47 -07:00
|
|
|
|
Activated by the `ext_messages` |ui-option|.
|
|
|
|
|
Activates |ui-linegrid| and |ui-cmdline| implicitly.
|
2017-10-31 08:46:02 -07:00
|
|
|
|
|
2019-05-11 07:58:47 -07:00
|
|
|
|
This UI extension delegates presentation of messages and dialogs. Messages
|
|
|
|
|
that would otherwise render in the message/cmdline screen space, are emitted
|
|
|
|
|
as UI events.
|
2017-10-31 08:46:02 -07:00
|
|
|
|
|
2019-05-11 07:58:47 -07:00
|
|
|
|
Nvim will not allocate screen space for the cmdline or messages, and
|
|
|
|
|
'cmdheight' will be forced zero. Cmdline state is emitted as |ui-cmdline|
|
|
|
|
|
events, which the UI must handle.
|
2017-10-31 08:46:02 -07:00
|
|
|
|
|
2022-09-24 17:20:47 -07:00
|
|
|
|
["msg_show", kind, content, replace_last] ~
|
2017-10-31 08:46:02 -07:00
|
|
|
|
Display a message to the user.
|
|
|
|
|
|
2019-05-09 14:54:04 -07:00
|
|
|
|
kind
|
|
|
|
|
Name indicating the message kind:
|
2020-08-31 00:51:35 -07:00
|
|
|
|
"" (empty) Unknown (consider a feature-request: |bugs|)
|
2019-05-09 14:54:04 -07:00
|
|
|
|
"confirm" |confirm()| or |:confirm| dialog
|
|
|
|
|
"confirm_sub" |:substitute| confirm dialog |:s_c|
|
|
|
|
|
"emsg" Error (|errors|, internal error, |:throw|, …)
|
|
|
|
|
"echo" |:echo| message
|
|
|
|
|
"echomsg" |:echomsg| message
|
|
|
|
|
"echoerr" |:echoerr| message
|
2019-01-24 11:15:39 -07:00
|
|
|
|
"lua_error" Error in |:lua| code
|
|
|
|
|
"rpc_error" Error response from |rpcrequest()|
|
2019-05-09 14:54:04 -07:00
|
|
|
|
"return_prompt" |press-enter| prompt after a multiple messages
|
|
|
|
|
"quickfix" Quickfix navigation message
|
2019-06-08 04:42:21 -07:00
|
|
|
|
"search_count" Search count message ("S" flag of 'shortmess')
|
2019-05-09 14:54:04 -07:00
|
|
|
|
"wmsg" Warning ("search hit BOTTOM", |W10|, …)
|
|
|
|
|
New kinds may be added in the future; clients should treat unknown
|
|
|
|
|
kinds as the empty kind.
|
|
|
|
|
|
|
|
|
|
content
|
|
|
|
|
Array of `[attr_id, text_chunk]` tuples, building up the message
|
|
|
|
|
text of chunks of different highlights. No extra spacing should be
|
|
|
|
|
added between chunks, the `text_chunk` by itself contains any
|
|
|
|
|
necessary whitespace. Messages can contain line breaks "\n".
|
|
|
|
|
|
|
|
|
|
replace_last
|
|
|
|
|
Decides how multiple messages should be displayed:
|
|
|
|
|
false: Display the message together with all previous messages
|
|
|
|
|
that are still visible.
|
|
|
|
|
true: Replace the message in the most-recent `msg_show` call,
|
|
|
|
|
but any other visible message should still remain.
|
2017-10-31 08:46:02 -07:00
|
|
|
|
|
2022-09-24 17:20:47 -07:00
|
|
|
|
["msg_clear"] ~
|
2017-10-31 08:46:02 -07:00
|
|
|
|
Clear all messages currently displayed by "msg_show". (Messages sent
|
|
|
|
|
by other "msg_" events below will not be affected).
|
|
|
|
|
|
2022-09-24 17:20:47 -07:00
|
|
|
|
["msg_showmode", content] ~
|
2017-10-31 08:46:02 -07:00
|
|
|
|
Shows 'showmode' and |recording| messages. `content` has the same
|
|
|
|
|
format as in "msg_show". This event is sent with empty `content` to
|
|
|
|
|
hide the last message.
|
|
|
|
|
|
2022-09-24 17:20:47 -07:00
|
|
|
|
["msg_showcmd", content] ~
|
2017-10-31 08:46:02 -07:00
|
|
|
|
Shows 'showcmd' messages. `content` has the same format as in "msg_show".
|
|
|
|
|
This event is sent with empty `content` to hide the last message.
|
|
|
|
|
|
2022-09-24 17:20:47 -07:00
|
|
|
|
["msg_ruler", content] ~
|
2017-10-31 08:46:02 -07:00
|
|
|
|
Used to display 'ruler' when there is no space for the ruler in a
|
|
|
|
|
statusline. `content` has the same format as in "msg_show". This event is
|
|
|
|
|
sent with empty `content` to hide the last message.
|
|
|
|
|
|
2022-09-24 17:20:47 -07:00
|
|
|
|
["msg_history_show", entries] ~
|
2017-10-31 08:46:02 -07:00
|
|
|
|
Sent when |:messages| command is invoked. History is sent as a list of
|
|
|
|
|
entries, where each entry is a `[kind, content]` tuple.
|
|
|
|
|
|
2022-12-14 11:58:18 -07:00
|
|
|
|
["msg_history_clear"] ~
|
|
|
|
|
Clear the |:messages| history.
|
|
|
|
|
|
2017-09-10 01:01:18 -07:00
|
|
|
|
==============================================================================
|
|
|
|
|
vim:tw=78:ts=8:noet:ft=help:norl:
|