diff options
author | zeertzjq <zeertzjq@outlook.com> | 2022-11-23 09:54:48 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-11-23 09:54:48 +0800 |
commit | 4571ba4d0a5234408e544c3a98f107688a792f0d (patch) | |
tree | 0418fe6a170f8d2f6f97dd6182753dfdd89eb7bf /runtime | |
parent | d41e93d5a83642f90898cae211e017d99ff97fd9 (diff) | |
download | rneovim-4571ba4d0a5234408e544c3a98f107688a792f0d.tar.gz rneovim-4571ba4d0a5234408e544c3a98f107688a792f0d.tar.bz2 rneovim-4571ba4d0a5234408e544c3a98f107688a792f0d.zip |
vim-patch:partial:9.0.0917: the WinScrolled autocommand event is not enough (#21161)
Problem: The WinScrolled autocommand event is not enough.
Solution: Add WinResized and provide information about what changed.
(closes vim/vim#11576)
https://github.com/vim/vim/commit/35fc61cb5b5eba8bbb9d8f0700332fbab38f40ca
Omit "func_name" comment in tv_dict_extend(): Vim9 script only.
Skip layout locking and E1312.
Skip list_alloc_with_items() and list_set_item().
Since this overrides remaining changes in patch 9.0.0913, that patch can
now be marked as fully ported:
vim-patch:9.0.0913: only change in current window triggers the WinScrolled event
N/A patches for version.c:
vim-patch:9.0.0919: build failure with tiny features
Problem: Build failure with tiny features.
Solution: Adjust #ifdef's.
https://github.com/vim/vim/commit/9c5b7cb4cf67c64648a324e9dfd1e17d793335a4
Co-authored-by: Bram Moolenaar <Bram@vim.org>
Diffstat (limited to 'runtime')
-rw-r--r-- | runtime/doc/autocmd.txt | 30 | ||||
-rw-r--r-- | runtime/doc/windows.txt | 45 |
2 files changed, 66 insertions, 9 deletions
diff --git a/runtime/doc/autocmd.txt b/runtime/doc/autocmd.txt index b6c9253a41..9bb835e661 100644 --- a/runtime/doc/autocmd.txt +++ b/runtime/doc/autocmd.txt @@ -1095,21 +1095,24 @@ WinNew When a new window was created. Not done for Before WinEnter. *WinScrolled* -WinScrolled After scrolling the content of a window or - resizing a window in the current tab page. - - When more than one window scrolled or resized - only one WinScrolled event is triggered. You - can use the `winlayout()` and `getwininfo()` - functions to see what changed. +WinScrolled After any window in the current tab page + scrolled the text (horizontally or vertically) + or changed width or height. See + |win-scrolled-resized|. The pattern is matched against the |window-ID| of the first window that scrolled or resized. Both <amatch> and <afile> are set to the |window-ID|. + |v:event| is set with information about size + and scroll changes. |WinScrolled-event| + Only starts triggering after startup finished and the first screen redraw was done. + Does not trigger when defining the first + WinScrolled or WinResized event, but may + trigger when adding more. Non-recursive: the event will not trigger while executing commands for the WinScrolled @@ -1117,8 +1120,17 @@ WinScrolled After scrolling the content of a window or window to scroll or change size, then another WinScrolled event will be triggered later. - Does not trigger when the command is added, - only after the first scroll or resize. + + *WinResized* +WinResized After a window in the current tab page changed + width or height. + See |win-scrolled-resized|. + + |v:event| is set with information about size + changes. |WinResized-event| + + Same behavior as |WinScrolled| for the + pattern, triggering and recursiveness. ============================================================================== 6. Patterns *autocmd-pattern* *{aupat}* diff --git a/runtime/doc/windows.txt b/runtime/doc/windows.txt index dfc2fb5abf..1776c47d33 100644 --- a/runtime/doc/windows.txt +++ b/runtime/doc/windows.txt @@ -607,6 +607,51 @@ it). The minimal height and width of a window is set with 'winminheight' and 'winminwidth'. These are hard values, a window will never become smaller. + +WinScrolled and WinResized autocommands ~ + *win-scrolled-resized* +If you want to get notified of changes in window sizes, the |WinResized| +autocommand event can be used. +If you want to get notified of text in windows scrolling vertically or +horizontally, the |WinScrolled| autocommand event can be used. This will also +trigger in window size changes. + *WinResized-event* +The |WinResized| event is triggered after updating the display, several +windows may have changed size then. A list of the IDs of windows that changed +since last time is provided in the v:event.windows variable, for example: + [1003, 1006] + *WinScrolled-event* +The |WinScrolled| event is triggered after |WinResized|, and also if a window +was scrolled. That can be vertically (the text at the top of the window +changed) or horizontally (when 'wrap' is off or when the first displayed part +of the first line changes). Note that |WinScrolled| will trigger many more +times than |WinResized|, it may slow down editing a bit. + +The information provided by |WinScrolled| is a dictionary for each window that +has changes, using the window ID as the key, and a total count of the changes +with the key "all". Example value for |v:event|: + { + all: {width: 0, height: 2, leftcol: 0, topline: 1, skipcol: 0}, + 1003: {width: 0, height: -1, leftcol: 0, topline: 0, skipcol: 0}, + 1006: {width: 0, height: 1, leftcol: 0, topline: 1, skipcol: 0}, + } + +Note that the "all" entry has the absolute values of the individual windows +accumulated. + +If you need more information about what changed, or you want to "debounce" the +events (not handle every event to avoid doing too much work), you may want to +use the `winlayout()` and `getwininfo()` functions. + +|WinScrolled| and |WinResized| do not trigger when the first autocommand is +added, only after the first scroll or resize. They may trigger when switching +to another tab page. + +The commands executed are expected to not cause window size or scroll changes. +If this happens anyway, the event will trigger again very soon. In other +words: Just before triggering the event, the current sizes and scroll +positions are stored and used to decide whether there was a change. + ============================================================================== 7. Argument and buffer list commands *buffer-list* |