ui.txt 35 KB

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