aboutsummaryrefslogtreecommitdiff
path: root/runtime
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2023-07-11 07:15:46 +0800
committerGitHub <noreply@github.com>2023-07-11 07:15:46 +0800
commitdb8fe63a9398efd57c3ff28aa3d93e45fb70ee1a (patch)
tree31107910712b0454160b28441b7945a8167628c7 /runtime
parent3750e5ed9c740a4334628c4a560d77c1dc2d0bfd (diff)
downloadrneovim-db8fe63a9398efd57c3ff28aa3d93e45fb70ee1a.tar.gz
rneovim-db8fe63a9398efd57c3ff28aa3d93e45fb70ee1a.tar.bz2
rneovim-db8fe63a9398efd57c3ff28aa3d93e45fb70ee1a.zip
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.
Diffstat (limited to 'runtime')
-rw-r--r--runtime/doc/api.txt32
-rw-r--r--runtime/doc/news.txt3
2 files changed, 35 insertions, 0 deletions
diff --git a/runtime/doc/api.txt b/runtime/doc/api.txt
index d96169066c..d128bf0221 100644
--- a/runtime/doc/api.txt
+++ b/runtime/doc/api.txt
@@ -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*
diff --git a/runtime/doc/news.txt b/runtime/doc/news.txt
index ac0a57e4d3..51ff0b4468 100644
--- a/runtime/doc/news.txt
+++ b/runtime/doc/news.txt
@@ -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()|