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