Home Explore Blog CI



neovim

9th chunk of `runtime/doc/ui.txt`
976fde849567c3892f323ae29acc0f229604690f4441bc550000000100000fa9

Note: "ui" items will have both `ui_name` and `hi_name` present. These can
differ, because the builtin group was linked to another group |:hi-link| , or
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.

==============================================================================
Multigrid Events						 *ui-multigrid*

Activated by the `ext_multigrid` |ui-option|.
Activates |ui-linegrid| implicitly.

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.
- A dedicated grid is used for messages, which may scroll over the window
  area. (Alternatively |ui-messages| can be used).

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
the UI must change the grid size whenever the outer size is changed. To
delegate grid-size handling back to Nvim, request the size (0, 0).

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.

["win_pos", grid, win, start_row, start_col, width, height] ~
	Set the position and size of the grid in Nvim (i.e. the outer grid
	size). If the window was previously hidden, it should now be shown
	again.

["win_float_pos", grid, win, anchor, anchor_grid, anchor_row, anchor_col, mouse_enabled, zindex, compindex, screen_row, screen_col] ~
	Display or reconfigure floating window `win`.

	There are two alternative ways of positioning the window
	  -  Manually - 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()|. NOTE: you have to manually
	     ensure that the window fits the screen, possibly by further
	     reposition it. Ignore `screen_row` and `screen_col` in this case.
	  - Let nvim take care of the positioning - You can ignore `anchor`
	    and display the window at `screen_row` and `screen_col`.

	`mouse_enabled` is true if the window can receive mouse events.

	`zindex` is the configured zindex, while `compindex` is the exact
	rendering order of the windows determined by nvim. To render exactly
	like the TUI, first render all the non-floating windows, then render
	in the `compindex` order, overwriting any floating window cells.
	Finally, blend the floating window cells against the non-floating
	background. To add more blending, you can group the windows by zindex,
	and blend between the layers. But note that windows inside the same
	zindex should still overwrite previous cells inside the same layer
	without blending. This ensures that plugins that render multiple
	windows, to add borders for example, work as expected.

["win_external_pos", grid, win] ~
	Display or reconfigure external window `win`. The window should be
	displayed as a separate top-level window in the desktop environment,
	or something similar.

["win_hide", grid] ~
	Stop displaying the window. The window can be shown again later.

["win_close", grid] ~
	Close the window.

["msg_set_pos", grid, row, scrolled, sep_char, zindex, compindex] ~
	Display messages on `grid`.  The grid will be displayed at `row` on
	the default grid (grid=1),

Title: Multigrid Events: Details and Window Management
Summary
This section elaborates on the Multigrid extension in Neovim, activated by the `ext_multigrid` option. It describes how UIs gain more control over window display through separate grids, independent grid sizing, and a dedicated grid for messages. It details how grid size handling can be delegated back to Neovim and how windows can be hidden and redisplayed without deallocation. Furthermore, it explains events such as `win_pos`, `win_float_pos`, `win_external_pos`, `win_hide`, `win_close`, and `msg_set_pos` for managing window position, floating windows, external windows, window visibility, and message display on grids.