robin/laufey
git clone https://git.robinwobin.dev/robin/laufey
d16bd456a8
master
1*api-ui-events.txt* Nvim 2 3 4 NVIM REFERENCE MANUAL 5 6 7Nvim UI protocol *UI* *ui* *api-ui-events* 8 9This document describes the UI protocol. See |gui| and |tui| for user-facing 10UI components and features. 11 12 Type |gO| to see the table of contents. 13 14============================================================================== 15UI Events *ui-protocol* *ui-events* 16 17UIs can be implemented as external client processes communicating with Nvim 18over the RPC API. The default UI model is a terminal-like grid with a single, 19monospace font. The UI can opt-in to have windows drawn on separate grids, and 20have some elements ("widgets") presented by the UI itself rather than by Nvim 21("externalized"). 22 23 *ui-option* 24Call |nvim_ui_attach()| to tell Nvim that your program wants to draw the Nvim 25screen grid with a size of width × height cells. This is typically done by an 26embedder at startup (see |ui-startup|), but UIs can also connect to a running 27Nvim instance and invoke nvim_ui_attach(). The `options` parameter is a map 28with these (optional) keys: 29 30 *ui-rgb* 31- `rgb` Decides the color format. 32 - true: (default) 24-bit RGB colors 33 - false: Terminal colors (8-bit, max 256) 34 35 *ui-override* 36- `override` Decides how UI capabilities are resolved. 37 - true: Enable requested UI capabilities, even if not 38 supported by all connected UIs (including |TUI|). 39 - false: (default) Disable UI capabilities not 40 supported by all connected UIs (including TUI). 41 42 *ui-ext-options* 43- `ext_cmdline` Externalize the cmdline. |ui-cmdline| 44- `ext_hlstate` Detailed highlight state. |ui-hlstate| 45 Sets `ext_linegrid` implicitly. 46- `ext_linegrid` Line-based grid events. |ui-linegrid| 47 Deactivates |ui-grid-old| implicitly. 48- `ext_messages` Externalize messages. |ui-messages| 49 Sets `ext_linegrid` and `ext_cmdline` implicitly. 50- `ext_multigrid` Per-window grid events. |ui-multigrid| 51 Sets `ext_linegrid` implicitly. 52- `ext_popupmenu` Externalize |popupmenu-completion| and 53 'wildmenu'. |ui-popupmenu| 54- `ext_tabline` Externalize the tabline. |ui-tabline| 55- `ext_termcolors` Use external default colors. 56- `term_name` Sets the name of the terminal 'term'. 57- `term_colors` Sets the number of supported colors 't_Co'. 58- `stdin_fd` Treat this fd as if it were stdin when using |--|. 59 Only from |--embed| UI on startup. |ui-startup-stdin| 60- `stdin_tty` Tells if `stdin` is a `tty` or not. 61- `stdout_tty` Tells if `stdout` is a `tty` or not. 62 63Specifying an unknown option is an error; UIs can check the |api-metadata| 64`ui_options` key for supported options. 65 66By default Nvim requires all connected UIs to support the same capabilities, 67thus the active capabilities are the intersection of those requested. UIs may 68specify |ui-override| to invert this behavior (useful for debugging). The 69"option_set" event announces which capabilities are active. 70 71Nvim sends RPC notifications to all attached UIs, with method name "redraw" 72and a single argument: an array (batch) of screen "update events". Each update 73event is itself an array whose first element is the event name and remaining 74elements are event-parameter tuples. Thus multiple events of the same kind can 75be sent contiguously without repeating the event name. 76 77Example of a typical "redraw" batch in a single RPC notification: > 78 79 ['notification', 'redraw', 80 [ 81 ['grid_resize', [2, 77, 36]], 82 ['grid_line', 83 [2, 0, 0, [[' ' , 0, 77]], false], 84 [2, 1, 0, [['~', 7], [' ', 7, 76]], false], 85 [2, 9, 0, [['~', 7], [' ', 7, 76]], false], 86 ... 87 [2, 35, 0, [['~', 7], [' ', 7, 76]], false], 88 [1, 36, 0, [['[', 9], ['N'], ['o'], [' '], ['N'], ['a'], ['m'], ['e'], [']']], false], 89 [1, 36, 9, [[' ', 9, 50]], false], 90 [1, 36, 59, [['0', 9], [','], ['0'], ['-' ], ['1'], [' ', 9, 10], ['A'], ['l', 9, 2]], false] 91 ], 92 ['msg_showmode', [[]]], 93 ['win_pos', [2, 1000, 0, 0, 77, 36]], 94 ['grid_cursor_goto', [2, 0, 0]], 95 ['flush', []] 96 ] 97 ] 98 99Events must be handled in-order. Nvim sends a "flush" event when it has 100completed a redraw of the entire screen (so all windows have a consistent view 101of buffer state, options, etc.). Multiple "redraw" batches may be sent before 102the entire screen has been redrawn, with "flush" following only the last 103batch. The user should only see the final state (when "flush" is sent), not 104any intermediate state while processing part of the batch array, nor after 105a batch not ending with "flush". 106 107By default, Nvim sends |ui-global| and |ui-grid-old| events (for backwards 108compatibility); these suffice to implement a terminal-like interface. However 109the new |ui-linegrid| represents text more efficiently (especially highlighted 110text), and allows UI capabilities requiring multiple grids. New UIs should 111implement |ui-linegrid| instead of |ui-grid-old|. 112 113Nvim optionally sends various screen elements "semantically" as structured 114events instead of raw grid-lines, as specified by |ui-ext-options|. The UI 115must present such elements itself, Nvim will not draw them on the grid. 116 117Future versions of Nvim may add new update kinds and may append new parameters 118to existing update kinds. Clients must be prepared to ignore such extensions, 119for forward-compatibility. |api-contract| 120 121============================================================================== 122UI startup *ui-startup* 123 124UI embedders (clients that start Nvim with |--embed| and later call 125|nvim_ui_attach()|) must start Nvim without |--headless|: >bash 126 nvim --embed 127Nvim will pause before loading startup files and reading buffers, so the UI 128has a chance to invoke requests and do early initialization. Startup will 129continue when the UI invokes |nvim_ui_attach()|. 130 131A simple UI only needs to do a single |nvim_ui_attach()| request and then 132prepare to handle any UI event. A more featureful UI, which might need 133additional configuration of the Nvim process, should use the following startup 134procedure: 135 1361. Invoke |nvim_get_api_info()|, if needed to setup the client library and/or 137 to get the list of supported UI extensions. 1382. Do any configuration that should be happen before user config is loaded. 139 Buffers and windows are not available at this point, but this could be used 140 to set |g:| variables visible to init.vim 1413. If the UI wants to do additional setup after user config is loaded, 142 register a VimEnter autocmd: >lua 143 nvim_command("autocmd VimEnter * call rpcrequest(1, 'vimenter')") 1444. Now invoke |nvim_ui_attach()|. The UI must handle user input by now: 145 sourcing init.vim and loading buffers might lead to blocking prompts. 1465. If step 3 was used, Nvim will send a blocking "vimenter" request to the UI. 147 Inside this request handler, the UI can safely do any initialization before 148 entering normal mode, for example reading variables set by init.vim. 149 150 *ui-startup-stdin* 151UIs can support reading from stdin (like `command | nvim -`, see |--|) as follows: 152 1531. The embedding process detects that the stdin fd is not a terminal. 1542. It then needs to forward this fd to Nvim. Because fd=0 is already is used 155 to send RPC data from embedder to Nvim, it must use some other file 156 descriptor, like fd=3 or higher. 1573. Then pass the fd as the `stdin_fd` parameter of `nvim_ui_attach`. Nvim will 158 read it as text into buffer 1. 159 160============================================================================== 161Global Events *ui-global* 162 163The following UI events are always emitted, and describe global state of 164the editor. 165 166["set_title", title] ~ 167["set_icon", icon] ~ 168 Set the window title, and icon (minimized) window title, respectively. 169 In windowing systems not distinguishing between the two, "set_icon" 170 can be ignored. 171 172["mode_info_set", cursor_style_enabled, mode_info] ~ 173 `cursor_style_enabled` is a boolean indicating if the UI should set 174 the cursor style. `mode_info` is a list of mode property maps. The 175 current mode is given by the `mode_idx` field of the `mode_change` 176 event. 177 178 Each mode property map may contain these keys: 179 180 KEY DESCRIPTION ~ 181 `cursor_shape`: "block", "horizontal", "vertical" 182 `cell_percentage`: Cell % occupied by the cursor. 183 `blinkwait`, `blinkon`, `blinkoff`: See |cursor-blinking|. 184 `attr_id`: Cursor attribute id (defined by `hl_attr_define`). 185 When attr_id is 0, the background and foreground 186 colors should be swapped. 187 `attr_id_lm`: Cursor attribute id for when |:lmap| is on. 188 `short_name`: Mode code name, see 'guicursor'. 189 `name`: Mode descriptive name. 190 `mouse_shape`: (To be implemented.) 191 192 Some keys are missing in some modes. 193 194 The following keys are deprecated: 195 196 `hl_id`: Use `attr_id` instead. 197 `id_lm`: Use `attr_id_lm` instead. 198 199["option_set", name, value] ~ 200 UI-related option changed, where `name` is one of: 201 202 - 'arabicshape' 203 - 'ambiwidth' 204 - 'emoji' 205 - 'guifont' 206 - 'guifontwide' 207 - 'linespace' 208 - 'mousefocus' 209 - 'mousehide' 210 - 'mousemoveevent' 211 - 'pumblend' 212 - 'showtabline' 213 - 'termguicolors' 214 - "ext_*" (all |ui-ext-options|) 215 216 Triggered when the UI first connects to Nvim, and whenever an option 217 is changed by the user or a plugin. 218 219 Options are not represented here if their effects are communicated in 220 other UI events. For example, instead of forwarding the 'mouse' option 221 value, the "mouse_on" and "mouse_off" UI events directly indicate if 222 mouse support is active. Some options like 'ambiwidth' have already 223 taken effect on the grid, where appropriate empty cells are added, 224 however a UI might still use such options when rendering raw text 225 sent from Nvim, like for |ui-cmdline|. 226 227["chdir", path] ~ 228 The |current-directory| changed to `path`. 229 230["mode_change", mode, mode_idx] ~ 231 Editor mode changed. The `mode` parameter is a string representing 232 the current mode. `mode_idx` is an index into the array emitted in 233 the `mode_info_set` event. UIs should change the cursor style 234 according to the properties specified in the corresponding item. The 235 set of modes reported will change in new versions of Nvim, for 236 instance more submodes and temporary states might be represented as 237 separate modes. 238 239["mouse_on"] ~ 240["mouse_off"] ~ 241 'mouse' was enabled/disabled in the current editor mode. Useful for 242 a terminal UI, or embedding into an application where Nvim mouse would 243 conflict with other usages of the mouse. Other UI:s may ignore this event. 244 245["busy_start"] ~ 246["busy_stop"] ~ 247 Indicates to the UI that it must stop rendering the cursor. This event 248 is misnamed and does not actually have anything to do with busyness. 249 250["connect", server_addr] ~ 251 User invoked the |:connect| command. Nvim detached the current UI. 252 253 UI is expected to: 254 1. Attach to the server at `server_addr`. 255 256["restart", listen_addr] ~ 257 User invoked the |:restart| command. Nvim started a new server. The 258 old server is about to exit and close its channel. 259 260 UI is expected to: 261 1. Wait for the channel to be closed, to confirm that the old server 262 actually exited. 263 2. Attach to the new server at `listen_addr`. 264 265["suspend"] ~ 266 |:suspend| command or |CTRL-Z| mapping is used. A terminal client (or 267 another client where it makes sense) could suspend itself. Other 268 clients can safely ignore it. 269 270["update_menu"] ~ 271 The menu mappings changed. 272 273["bell"] ~ 274["visual_bell"] ~ 275 Notify the user with an audible or visual bell, respectively. 276 277["flush"] ~ 278 Nvim is done redrawing the screen. For an implementation that renders 279 to an internal buffer, this is the time to display the redrawn parts 280 to the user. 281 282["ui_send", content] ~ 283 Write {content} to the connected TTY. Only UIs that have the 284 "stdout_tty" |ui-option| set will receive this event. 285 286============================================================================== 287Grid Events (line-based) *ui-linegrid* 288 289Activated by the `ext_linegrid` |ui-option|. Recommended for all new UIs. 290Deactivates |ui-grid-old| implicitly. 291 292Unlike |ui-grid-old|, this UI extension emits a single `grid_line` event to 293update a screen-line (whereas the old protocol emitted separate cursor, 294highlight and text events per screen-line). 295 296Most of these events take a `grid` index as first parameter. Grid 1 is the 297global grid used by default for the entire editor screen state. The 298`ext_linegrid` capability by itself will never cause any additional grids to 299be created; to enable per-window grids, activate |ui-multigrid|. 300 301Highlight attribute groups are predefined. UIs should maintain a table to map 302numerical highlight ids to the actual attributes. 303 304["grid_resize", grid, width, height] ~ 305 Resize a `grid`. If `grid` wasn't seen by the client before, a new grid is 306 being created with this size. 307 308["default_colors_set", rgb_fg, rgb_bg, rgb_sp, cterm_fg, cterm_bg] ~ 309 The first three arguments set the default foreground, background and 310 special colors respectively. `cterm_fg` and `cterm_bg` specifies the 311 default color codes to use in a 256-color terminal. 312 313 The RGB values will always be valid colors, by default. If no 314 colors have been set, they will default to black and white, depending 315 on 'background'. By setting the `ext_termcolors` option, instead 316 -1 will be used for unset colors. This is mostly useful for a TUI 317 implementation, where using the terminal builtin ("ANSI") defaults 318 are expected. 319 320 Note: Unlike the corresponding |ui-grid-old| events, the screen is not 321 always cleared after sending this event. The UI must repaint the 322 screen with changed background color itself. 323 324 *ui-event-hl_attr_define* 325["hl_attr_define", id, rgb_attr, cterm_attr, info] ~ 326 Add a highlight with `id` to the highlight table, with the 327 attributes specified by the `rgb_attr` and `cterm_attr` dicts, with the 328 following (all optional) keys. 329 330 `foreground`: foreground color. 331 `background`: background color. 332 `special`: color to use for various underlines, when 333 present. 334 `reverse`: reverse video. Foreground and background colors 335 are switched. 336 `italic`: italic text. 337 `bold`: bold text. 338 `strikethrough`: struckthrough text. 339 `underline`: underlined text. The line has `special` color. 340 `undercurl`: undercurled text. The curl has `special` color. 341 `underdouble`: double underlined text. The lines have `special` color. 342 `underdotted`: underdotted text. The dots have `special` color. 343 `underdashed`: underdashed text. The dashes have `special` color. 344 `altfont`: alternative font. 345 `dim`: half-bright/faint text. 346 `blink`: blinking text. 347 `conceal`: concealed/hidden text. 348 `overline`: overlined text. 349 `blend`: blend level (0-100). Could be used by UIs to 350 support blending floating windows to the 351 background or to signal a transparent cursor. 352 `url`: URL associated with this highlight. UIs should 353 present the region as a clickable hyperlink. 354 355 For absent color keys the default color should be used. Don't store 356 the default value in the table, rather a sentinel value, so that 357 a changed default color will take effect. 358 All boolean keys default to false, and will only be sent when they 359 are true. 360 361 Highlights are always transmitted both for both the RGB format and as 362 terminal 256-color codes, as the `rgb_attr` and `cterm_attr` parameters 363 respectively. The |ui-rgb| option has no effect anymore. 364 Most external UIs will only need to store and use the `rgb_attr` 365 attributes. 366 367 `id` 0 will always be used for the default highlight with colors defined 368 by `default_colors_set` and no styles applied. 369 370 Note: Nvim may reuse `id` values if its internal highlight table is full. 371 In that case Nvim will always issue redraws of screen cells that are 372 affected by redefined ids, so UIs do not need to keep track of this 373 themselves. 374 375 `info` is an empty array unless |ui-hlstate| is enabled. 376 377["hl_group_set", name, hl_id] ~ 378 The built-in highlight group `name` was set to use the attributes `hl_id` 379 defined by a previous `hl_attr_define` call. This event is not needed 380 to render the grids which use attribute ids directly, but is useful 381 for a UI who want to render its own elements with consistent 382 highlighting. For instance a UI using |ui-popupmenu| events, might 383 use the |hl-Pmenu| family of builtin highlights. 384 385 *ui-event-grid_line* 386["grid_line", grid, row, col_start, cells, wrap] ~ 387 Redraw a continuous part of a `row` on a `grid`, starting at the column 388 `col_start`. `cells` is an array of arrays each with 1 to 3 items: 389 `[text(, hl_id, repeat)]` . `text` is the UTF-8 text that should be put in 390 a cell, with the highlight `hl_id` defined by a previous `hl_attr_define` 391 call. If `hl_id` is not present the most recently seen `hl_id` in 392 the same call should be used (it is always sent for the first 393 cell in the event). If `repeat` is present, the cell should be 394 repeated `repeat` times (including the first time), otherwise just 395 once. 396 397 The right cell of a double-width char will be represented as the empty 398 string. Double-width chars never use `repeat`. 399 400 If the array of cell changes doesn't reach to the end of the line, the 401 rest should remain unchanged. A whitespace char, repeated 402 enough to cover the remaining line, will be sent when the rest of the 403 line should be cleared. 404 405 `wrap` is a boolean indicating that this line wraps to the next row. 406 When redrawing a line which wraps to the next row, Nvim will emit a 407 `grid_line` event covering the last column of the line with `wrap` set 408 to true, followed immediately by a `grid_line` event starting at the 409 first column of the next row. 410 411["grid_clear", grid] ~ 412 Clear a `grid`. 413 414["grid_destroy", grid] ~ 415 `grid` will not be used anymore and the UI can free any data associated 416 with it. 417 418["grid_cursor_goto", grid, row, col] ~ 419 Makes `grid` the current grid and `row, col` the cursor position on this 420 grid. This event will be sent at most once in a `redraw` batch and 421 indicates the visible cursor position. 422 423["grid_scroll", grid, top, bot, left, right, rows, cols] ~ 424 Scroll a region of `grid`. This is semantically unrelated to editor 425 |scrolling|, rather this is an optimized way to say "copy these screen 426 cells". 427 428 The following diagrams show what happens per scroll direction. 429 "===" represents the SR (scroll region) boundaries. 430 "---" represents the moved rectangles. 431 Note that dst and src share a common region. 432 433 If `rows` is bigger than 0, move a rectangle in the SR up, this can 434 happen while scrolling down. 435> 436 +-------------------------+ 437 | (clipped above SR) | ^ 438 |=========================| dst_top | 439 | dst (still in SR) | | 440 +-------------------------+ src_top | 441 | src (moved up) and dst | | 442 |-------------------------| dst_bot | 443 | src (invalid) | | 444 +=========================+ src_bot 445< 446 If `rows` is less than zero, move a rectangle in the SR down, this can 447 happen while scrolling up. 448> 449 +=========================+ src_top 450 | src (invalid) | | 451 |------------------------ | dst_top | 452 | src (moved down) and dst| | 453 +-------------------------+ src_bot | 454 | dst (still in SR) | | 455 |=========================| dst_bot | 456 | (clipped below SR) | v 457 +-------------------------+ 458< 459 `cols` is always zero in this version of Nvim, and reserved for future 460 use. 461 462 Note when updating code from |ui-grid-old| events: ranges are 463 end-exclusive, which is consistent with API conventions, but different 464 from `set_scroll_region` which was end-inclusive. 465 466 The scrolled-in area will be filled using |ui-event-grid_line| directly 467 after the scroll event. The UI thus doesn't need to clear this area as 468 part of handling the scroll event. 469 470============================================================================== 471Grid Events (cell-based) *ui-grid-old* 472 473This is the legacy representation of the screen grid, emitted if |ui-linegrid| 474is not active. New UIs should implement |ui-linegrid| instead. 475 476["resize", width, height] ~ 477 The grid is resized to `width` and `height` cells. 478 479["clear"] ~ 480 Clear the grid. 481 482["eol_clear"] ~ 483 Clear from the cursor position to the end of the current line. 484 485["cursor_goto", row, col] ~ 486 Move the cursor to position (row, col). Currently, the same cursor is 487 used to define the position for text insertion and the visible cursor. 488 However, only the last cursor position, after processing the entire 489 array in the "redraw" event, is intended to be a visible cursor 490 position. 491 492["update_fg", color] ~ 493["update_bg", color] ~ 494["update_sp", color] ~ 495 Set the default foreground, background and special colors 496 respectively. 497 498 *ui-event-highlight_set* 499["highlight_set", attrs] ~ 500 Set the attributes that the next text put on the grid will have. 501 `attrs` is a dict with the keys below. Any absent key is reset 502 to its default value. Color defaults are set by the `update_fg` etc 503 updates. All boolean keys default to false. 504 505 `foreground`: foreground color. 506 `background`: background color. 507 `special`: color to use for various underlines, when present. 508 `reverse`: reverse video. Foreground and background colors are 509 switched. 510 `italic`: italic text. 511 `bold`: bold text. 512 `strikethrough`: struckthrough text. 513 `underline`: underlined text. The line has `special` color. 514 `undercurl`: undercurled text. The curl has `special` color. 515 `underdouble`: double underlined text. The lines have `special` color. 516 `underdotted`: underdotted text. The dots have `special` color. 517 `underdashed`: underdashed text. The dashes have `special` color. 518 `dim`: half-bright/faint text. 519 `blink`: blinking text. 520 `conceal`: concealed/hidden text. 521 `overline`: overlined text. 522 523["put", text] ~ 524 The (utf-8 encoded) string `text` is put at the cursor position 525 (and the cursor is advanced), with the highlights as set by the 526 last `highlight_set` update. 527 528["set_scroll_region", top, bot, left, right] ~ 529 Define the scroll region used by `scroll` below. 530 531 Note: ranges are end-inclusive, which is inconsistent with API 532 conventions. 533 534["scroll", count] ~ 535 Scroll the text in the scroll region. The diagrams below illustrate 536 what will happen, depending on the scroll direction. "=" is used to 537 represent the SR(scroll region) boundaries and "-" the moved rectangles. 538 Note that dst and src share a common region. 539 540 If count is bigger than 0, move a rectangle in the SR up, this can 541 happen while scrolling down. 542> 543 +-------------------------+ 544 | (clipped above SR) | ^ 545 |=========================| dst_top | 546 | dst (still in SR) | | 547 +-------------------------+ src_top | 548 | src (moved up) and dst | | 549 |-------------------------| dst_bot | 550 | src (cleared) | | 551 +=========================+ src_bot 552< 553 If count is less than zero, move a rectangle in the SR down, this can 554 happen while scrolling up. 555> 556 +=========================+ src_top 557 | src (cleared) | | 558 |------------------------ | dst_top | 559 | src (moved down) and dst| | 560 +-------------------------+ src_bot | 561 | dst (still in SR) | | 562 |=========================| dst_bot | 563 | (clipped below SR) | v 564 +-------------------------+ 565< 566============================================================================== 567Highlight Events *ui-hlstate* 568 569Activated by the `ext_hlstate` |ui-option|. 570Activates |ui-linegrid| implicitly. 571 572If `ext_hlstate` is enabled, Nvim will emit detailed highlight state in 573|ui-linegrid| events. Otherwise (by default) Nvim only describes grid cells 574using the final calculated highlight attributes described at 575|ui-event-highlight_set|. 576 577`ext_hlstate` provides a semantic description of active highlights for each 578grid cell. Highlights are predefined in a table, see |ui-event-hl_attr_define| 579and |ui-event-grid_line|. 580 581The `info` parameter in `hl_attr_define` contains a semantic description of 582the highlights. Because highlight groups can be combined, this is an array 583where the highest-priority item is last. Each item is a dict with these keys: 584 585 `kind`: always present. One of the following values: 586 "ui": Builtin UI highlight. |highlight-groups| 587 "syntax": Highlight applied to a buffer by a syntax declaration or 588 other runtime/plugin functionality such as 589 |nvim_buf_set_extmark()| 590 "terminal": highlight from a process running in a |terminal-emulator|. 591 Contains no further semantic information. 592 `ui_name`: Highlight name from |highlight-groups|. Only for "ui" kind. 593 `hi_name`: Name of the final |:highlight| group where the used 594 attributes are defined. 595 `id`: Unique numeric id representing this item. 596 597Note: "ui" items will have both `ui_name` and `hi_name` present. These can 598differ, because the builtin group was linked to another group |:hi-link| , or 599because 'winhighlight' was used. UI items will be transmitted, even if the 600highlight group is cleared, so `ui_name` can always be used to reliably identify 601screen elements, even if no attributes have been applied. 602 603============================================================================== 604Multigrid Events *ui-multigrid* 605 606Activated by the `ext_multigrid` |ui-option|. 607Activates |ui-linegrid| implicitly. 608 609See |ui-linegrid| for grid events. 610See |nvim_ui_try_resize_grid()| to request changing the grid size. 611See |nvim_input_mouse()| for sending mouse events to Nvim. 612 613The multigrid extension gives UIs more control over how windows are displayed: 614- UIs receive updates on a separate grid for each window. 615- UIs can set the grid size independently of how much space the window 616 occupies on the global layout. So the UI could use a different font size 617 per-window. Or reserve space around the border of the window for its own 618 elements, such as scrollbars from the UI toolkit. 619- A dedicated grid is used for messages, which may scroll over the window 620 area. (Alternatively |ui-messages| can be used). 621 622By default, the grid size is handled by Nvim and set to the outer grid size 623(i.e. the size of the window frame in Nvim) whenever the split is created. 624Once a UI sets a grid size, Nvim does not handle the size for that grid and 625the UI must change the grid size whenever the outer size is changed. To 626delegate grid-size handling back to Nvim, request the size (0, 0). 627 628A window can be hidden and redisplayed without its grid being deallocated. 629This can happen multiple times for the same window, for instance when switching 630tabs. 631 632["win_pos", grid, win, start_row, start_col, width, height] ~ 633 Set the position and size of the grid in Nvim (i.e. the outer grid 634 size). If the window was previously hidden, it should now be shown 635 again. 636 637["win_float_pos", grid, win, anchor, anchor_grid, anchor_row, anchor_col, mouse_enabled, zindex, compindex, screen_row, screen_col] ~ 638 Display or reconfigure floating window `win`. 639 640 There are two alternative ways of positioning the window 641 - Manually - The window should be displayed above another grid 642 `anchor_grid` at the specified position `anchor_row` and 643 `anchor_col`. For the meaning of `anchor` and more details of 644 positioning, see |nvim_open_win()|. NOTE: you have to manually 645 ensure that the window fits the screen, possibly by further 646 reposition it. Ignore `screen_row` and `screen_col` in this case. 647 - Let nvim take care of the positioning - You can ignore `anchor` 648 and display the window at `screen_row` and `screen_col`. 649 650 `mouse_enabled` is true if the window can receive mouse events. 651 652 `zindex` is the configured zindex, while `compindex` is the exact 653 rendering order of the windows determined by nvim. To render exactly 654 like the TUI, first render all the non-floating windows, then render 655 in the `compindex` order, overwriting any floating window cells. 656 Finally, blend the floating window cells against the non-floating 657 background. To add more blending, you can group the windows by zindex, 658 and blend between the layers. But note that windows inside the same 659 zindex should still overwrite previous cells inside the same layer 660 without blending. This ensures that plugins that render multiple 661 windows, to add borders for example, work as expected. 662 663["win_external_pos", grid, win] ~ 664 Display or reconfigure external window `win`. The window should be 665 displayed as a separate top-level window in the desktop environment, 666 or something similar. 667 668["win_hide", grid] ~ 669 Stop displaying the window. The window can be shown again later. 670 671["win_close", grid] ~ 672 Close the window. 673 674["msg_set_pos", grid, row, scrolled, sep_char, zindex, compindex] ~ 675 Display messages on `grid`. The grid will be displayed at `row` on 676 the default grid (grid=1), covering the full column width. `scrolled` 677 indicates whether the message area has been scrolled to cover other 678 grids. It can be useful to draw a separator then |msgsep|. The Builtin 679 TUI draws a full line filled with `sep_char` ('fillchars' msgsep 680 field) and |hl-MsgSeparator| highlight. 681 682 When |ui-messages| is active, no message grid is used, and this event 683 will not be sent. 684 685 `zindex` and `compindex` have the same meaning as for `win_float_pos`. 686 The `zindex` always has a fixed value of 200 and included for 687 completeness. 688 689["win_viewport", grid, win, topline, botline, curline, curcol, line_count, scroll_delta] ~ 690 Indicates the range of buffer text displayed in the window, as well 691 as the cursor position in the buffer. All positions are zero-based. 692 `botline` is set to one more than the line count of the buffer, if 693 there are filler lines past the end. `scroll_delta` contains how much 694 the top line of a window moved since `win_viewport` was last emitted. 695 It is intended to be used to implement smooth scrolling. For this 696 purpose it only counts "virtual" or "displayed" lines, so folds 697 only count as one line. When scrolling more than a full screen it is 698 an approximate value. 699 700 All updates, such as `grid_line`, in a batch affects the new viewport, 701 despite the fact that `win_viewport` is received after the updates. 702 Applications implementing, for example, smooth scrolling should take 703 this into account and keep the grid separated from what's displayed on 704 the screen and copy it to the viewport destination once `win_viewport` 705 is received. 706 707["win_viewport_margins", grid, win, top, bottom, left, right] ~ 708 Indicates the margins of a window grid which are _not_ part of the 709 viewport as indicated by the `win_viewport` event. This happens 710 e.g. in the presence of 'winbar' and floating window borders. 711 712["win_extmark", grid, win, ns_id, mark_id, row, col] ~ 713 Updates the position of an extmark which is currently visible in a 714 window. Only emitted if the mark has the `ui_watched` attribute. 715 716============================================================================== 717Popupmenu Events *ui-popupmenu* 718 719Activated by the `ext_popupmenu` |ui-option|. 720 721This UI extension delegates presentation of the |popupmenu-completion| and 722command-line 'wildmenu'. 723 724The UI decides how to present the menu. For example, depending on the last 725`mode_change` event, command-line wildmenu may be presented horizontally, 726while insert-mode completion would show a vertical popupmenu. 727 728["popupmenu_show", items, selected, row, col, grid] ~ 729 Show |popupmenu-completion|. `items` is an array of completion items 730 to show; each item is an array of the form [word, kind, menu, info] as 731 defined at |complete-items|, except that `word` is replaced by `abbr` 732 if present. `selected` is the initially-selected item, a zero-based 733 index into the array of items (-1 if no item is selected). `row` and 734 `col` give the anchor position, where the first character of the 735 completed word will be. When |ui-multigrid| is used, `grid` is the 736 grid for the anchor position. When `ext_cmdline` is active, `grid` is 737 set to -1 to indicate the popupmenu should be anchored to the external 738 cmdline. Then `col` will be a byte position in the cmdline text. 739 740["popupmenu_select", selected] ~ 741 Select an item in the current popupmenu. `selected` is a zero-based 742 index into the array of items from the last popupmenu_show event, or 743 -1 if no item is selected. 744 745["popupmenu_hide"] ~ 746 Hide the popupmenu. 747 748============================================================================== 749Tabline Events *ui-tabline* 750 751Activated by the `ext_tabline` |ui-option|. 752 753["tabline_update", curtab, tabs, curbuf, buffers] ~ 754 Tabline was updated. UIs should present this data in a custom tabline 755 widget. Note: options `curbuf` + `buffers` were added in API7. 756 curtab: Current Tabpage 757 tabs: List of Dicts [{ "tab": Tabpage, "name": String }, ...] 758 curbuf: Current buffer handle. 759 buffers: List of Dicts [{ "buffer": buffer handle, "name": String}, ...] 760 761============================================================================== 762Cmdline Events *ui-cmdline* 763 764Activated by the `ext_cmdline` |ui-option|. 765 766This UI extension delegates presentation of the |cmdline| (except 'wildmenu'). 767For command-line 'wildmenu' UI events, activate |ui-popupmenu|. 768 769["cmdline_show", content, pos, firstc, prompt, indent, level, hl_id] ~ 770 Triggered when the cmdline is displayed or changed. 771 772 content 773 Array of `[attr_id, text_chunk, hl_id]` tuples, building up the 774 cmdline text of chunks with different highlights. 775 776 pos 777 Position of the cursor in the cmdline (byte offset). 778 779 firstc 780 Character preceding the cmdline content (|getcmdtype()|). 781 782 prompt 783 String preceding the cmdline content when an |input()| prompt is 784 active, false otherwise. Highlighted with `hl_id`. 785 786 indent 787 Number of spaces the content should be indented. 788 789 level 790 Number indicating the cmdline recursion level. Incremented by 791 e.g |c_CTRL-R_=|, prompts or a commandline invoked from the 792 |cmdline-window|. 793 794 hl_id 795 Highlight group ID of the prompt, -1 with no active prompt. 796 797["cmdline_pos", pos, level] ~ 798 Change the cursor position in the cmdline. 799 800["cmdline_special_char", c, shift, level] ~ 801 Display a special char in the cmdline at the cursor position. This is 802 typically used to indicate a pending state, e.g. after |c_CTRL-V|. If 803 `shift` is true the text after the cursor should be shifted, otherwise 804 it should overwrite the char at the cursor. 805 806 Should be hidden at next cmdline_show. 807 808["cmdline_hide", level, abort] ~ 809 Hide the cmdline. `level` is the nesting level of the cmdline being hidden. 810 `abort` is true if the cmdline is hidden after an aborting condition 811 (|c_Esc| or |c_CTRL-C|). 812 813["cmdline_block_show", lines] ~ 814 Show a block of context to the current command line. For example if 815 the user defines a |:function| interactively: >vim 816 :function Foo() 817 : echo "foo" 818 : 819< 820 `lines` is a list of lines of highlighted chunks, in the same form as 821 the "cmdline_show" `contents` parameter. 822 823["cmdline_block_append", line] ~ 824 Append a line at the end of the currently shown block. 825 826["cmdline_block_hide"] ~ 827 Hide the block. 828 829============================================================================== 830Message/Dialog Events *ui-messages* 831 832Activated by the `ext_messages` |ui-option|. 833Activates |ui-linegrid| and |ui-cmdline| implicitly. 834 835This UI extension delegates presentation of messages and dialogs. Messages 836that would otherwise render in the message/cmdline screen space, are emitted 837as UI events. 838 839Nvim will not allocate screen space for the cmdline or messages. 'cmdheight' 840will be set to zero, but can be changed and used for the replacing cmdline or 841message window. Cmdline state is emitted as |ui-cmdline| events, which the UI 842must handle. 843 844["msg_show", kind, content, replace_last, history, append, id, trigger] ~ 845 Display a message to the user. Update (replace) any existing message 846 matching `id`. 847 848 kind 849 Name indicating the message kind: 850 "" (empty) Unknown (consider a |feature-request|) 851 "empty" Empty message (`:echo ""`), with empty `content`. 852 Should clear messages sharing the 'cmdheight' 853 area if it is the only message in a batch. 854 "confirm" Message preceding a prompt (|:confirm|, 855 |confirm()|, |inputlist()|, |z=|, …) 856 "emsg" Error (|errors|, internal error, |:throw|, …) 857 "echo" |:echo| message 858 "echomsg" |:echomsg| message 859 "echoerr" |:echoerr| message 860 "completion" |ins-completion-menu| message 861 "list_cmd" List output for various commands (|:ls|, |:set|, …) 862 "lua_error" Error in |:lua| code 863 "lua_print" |print()| from |:lua| code 864 "progress" Progress message emitted by |nvim_echo()|. 865 Internal progress messages use these ids: 866 - `nvim.bufwrite "<filename>"` 867 - `nvim.completion` 868 - `nvim.indent` 869 "quickfix" Quickfix navigation message 870 "rpc_error" Error response from |rpcrequest()| 871 "search_cmd" Entered search command 872 "search_count" Search count message ("S" flag of 'shortmess') 873 "shell_cmd" |:!cmd| executed command 874 "shell_err" |:!cmd| shell stderr output 875 "shell_out" |:!cmd| shell stdout output 876 "shell_ret" |:!cmd| shell return code 877 "undo" |:undo| and |:redo| message 878 "verbose" 'verbose' message 879 "wildlist" 'wildmode' "list" message 880 "wmsg" Warning ("search hit BOTTOM", |W10|, …) 881 New kinds may be added in the future; clients should treat unknown 882 kinds as the empty kind. 883 884 content 885 Array of `[attr_id, text_chunk, hl_id]` tuples, building up the 886 message text of chunks with different highlights. No extra spacing 887 should be added between chunks, the `text_chunk` by itself 888 contains any necessary whitespace. Messages can contain line 889 breaks "\n". 890 891 replace_last 892 Decides how multiple messages should be displayed: 893 false: Display the message together with all previous messages 894 that are still visible. 895 true: Replace the message in the most-recent `msg_show` call, 896 but any other visible message should still remain. 897 898 history 899 True if the message was added to the |:messages| history. 900 901 append 902 True if the message should be appended to the previous message, 903 rather than started on a new line. Is set for |:echon|. 904 905 id 906 Unique identifier for the message. It can either be an integer or 907 string. A (visible) message with the same id should be replaced. 908 909 trigger 910 Type of action that triggered the message: 911 "" (empty) Unknown (consider a |feature-request|) 912 "typed_cmd" Interactively typed command on the |cmdline| 913 914["msg_clear"] ~ 915 Clear all messages currently displayed by "msg_show", emitted after 916 clearing the screen (messages sent by other "msg_" events below should 917 not be affected). 918 919 Guidance: The "clear messages" behavior is UI-specific. If the UI 920 presents messages in a new window, it may choose to clear messages 921 after a few seconds. If the UI presents messages in a persistent area 922 (e.g. cmdline), it should clear messages at the start of the next 923 batch (typically, the next event-loop cycle). 924 925["msg_showmode", content] ~ 926 Shows 'showmode' and |recording| messages. `content` has the same 927 format as in "msg_show". This event is sent with empty `content` to 928 hide the last message. 929 930["msg_showcmd", content] ~ 931 Shows 'showcmd' messages. `content` has the same format as in "msg_show". 932 This event is sent with empty `content` to hide the last message. 933 934["msg_ruler", content] ~ 935 Used to display 'ruler' when there is no space for the ruler in a 936 statusline. `content` has the same format as in "msg_show". This event is 937 sent with empty `content` to hide the last message. 938 939["msg_history_show", entries, prev_cmd] ~ 940 Sent when |:messages| or |g<| command is invoked. History is sent as a 941 list of entries, where each entry is a `[kind, content, append]` tuple. 942 943 prev_cmd 944 True when sent with |g<| command, false with |:messages|. 945 946 vim:tw=78:ts=8:noet:ft=help:norl: