mirror of
https://github.com/neovim/neovim.git
synced 2025-11-27 04:30:41 +00:00
feat(api): add nvim_win_text_height (#24236)
It uses the same code as "scroll_delta" of "win_viewport" UI event to calculate text height, but is more flexible.
This commit is contained in:
@@ -2961,6 +2961,38 @@ nvim_win_set_width({window}, {width}) *nvim_win_set_width()*
|
||||
• {window} Window handle, or 0 for current window
|
||||
• {width} Width as a count of columns
|
||||
|
||||
nvim_win_text_height({window}, {*opts}) *nvim_win_text_height()*
|
||||
Computes the number of screen lines occupied by a range of text in a given
|
||||
window. Works for off-screen text and takes folds into account.
|
||||
|
||||
Diff filler or virtual lines above a line are counted as a part of that
|
||||
line, unless the line is on "start_row" and "start_vcol" is specified.
|
||||
|
||||
Diff filler or virtual lines below the last buffer line are counted in the
|
||||
result when "end_row" is omitted.
|
||||
|
||||
Line indexing is similar to |nvim_buf_get_text()|.
|
||||
|
||||
Parameters: ~
|
||||
• {window} Window handle, or 0 for current window.
|
||||
• {opts} Optional parameters:
|
||||
• start_row: Starting line index, 0-based inclusive. When
|
||||
omitted start at the very top.
|
||||
• end_row: Ending line index, 0-based inclusive. When
|
||||
omitted end at the very bottom.
|
||||
• start_vcol: Starting virtual column index on "start_row",
|
||||
0-based inclusive, rounded down to full screen lines. When
|
||||
omitted include the whole line.
|
||||
• end_vcol: Ending virtual column index on "end_row",
|
||||
0-based exclusive, rounded up to full screen lines. When
|
||||
omitted include the whole line.
|
||||
|
||||
Return: ~
|
||||
The number of screen lines that the range of text occupy.
|
||||
|
||||
See also: ~
|
||||
• |virtcol()| for text width.
|
||||
|
||||
|
||||
==============================================================================
|
||||
Win_Config Functions *api-win_config*
|
||||
|
||||
@@ -99,6 +99,9 @@ The following new APIs and features were added.
|
||||
|
||||
• |vim.system()| for running system commands.
|
||||
|
||||
• Added |nvim_win_text_height()| to get the number of screen lines occupied by
|
||||
a range of text in a given window.
|
||||
|
||||
• |nvim_set_keymap()| and |nvim_del_keymap()| now support abbreviations.
|
||||
|
||||
• Implemented LSP inlay hints: |vim.lsp.inlay_hint()|
|
||||
|
||||
Reference in New Issue
Block a user