0
0
mirror of https://github.com/vim/vim.git synced 2025-09-23 03:43:49 -04:00

patch 8.2.4713: plugins cannot track text scrolling

Problem:    Plugins cannot track text scrolling.
Solution:   Add the WinScrolled event. (closes #10102)
This commit is contained in:
LemonBoy
2022-04-08 15:18:45 +01:00
committed by Bram Moolenaar
parent 18ee0f603e
commit 0937182d49
12 changed files with 153 additions and 5 deletions

View File

@@ -2779,11 +2779,38 @@ trigger_winclosed(win_T *win)
if (recursive)
return;
recursive = TRUE;
vim_snprintf((char *)winid, sizeof(winid), "%i", win->w_id);
vim_snprintf((char *)winid, sizeof(winid), "%d", win->w_id);
apply_autocmds(EVENT_WINCLOSED, winid, winid, FALSE, win->w_buffer);
recursive = FALSE;
}
void
may_trigger_winscrolled(win_T *wp)
{
static int recursive = FALSE;
char_u winid[NUMBUFLEN];
if (recursive || !has_winscrolled())
return;
if (wp->w_last_topline != wp->w_topline
|| wp->w_last_leftcol != wp->w_leftcol
|| wp->w_last_width != wp->w_width
|| wp->w_last_height != wp->w_height)
{
vim_snprintf((char *)winid, sizeof(winid), "%d", wp->w_id);
recursive = TRUE;
apply_autocmds(EVENT_WINSCROLLED, winid, winid, FALSE, wp->w_buffer);
recursive = FALSE;
wp->w_last_topline = wp->w_topline;
wp->w_last_leftcol = wp->w_leftcol;
wp->w_last_width = wp->w_width;
wp->w_last_height = wp->w_height;
}
}
/*
* Close window "win" in tab page "tp", which is not the current tab page.
* This may be the last window in that tab page and result in closing the tab,