feat(ui): add scroll_delta to win_viewport event #19270

scroll_delta contains how much the top line of a window moved since the
last time win_viewport was emitted. It is expected to be used to
implement smooth scrolling. For this purpose it only counts "virtual" or
"displayed" so folds should count as one line. Because of this it
adds extra information that cannot be computed from the topline
parameter.

Fixes #19227
This commit is contained in:
Matthias Deiml
2023-03-12 23:58:46 +01:00
committed by GitHub
parent e5f4394eb7
commit fd2ece278b
10 changed files with 192 additions and 114 deletions

View File

@@ -803,14 +803,17 @@ function Screen:_handle_win_pos(grid, win, startrow, startcol, width, height)
self.float_pos[grid] = nil
end
function Screen:_handle_win_viewport(grid, win, topline, botline, curline, curcol, linecount)
function Screen:_handle_win_viewport(grid, win, topline, botline, curline, curcol, linecount, scroll_delta)
-- accumulate scroll delta
local last_scroll_delta = self.win_viewport[grid] and self.win_viewport[grid].sum_scroll_delta or 0
self.win_viewport[grid] = {
win = win,
topline = topline,
botline = botline,
curline = curline,
curcol = curcol,
linecount = linecount
linecount = linecount,
sum_scroll_delta = scroll_delta + last_scroll_delta
}
end
@@ -1348,7 +1351,7 @@ local function fmt_ext_state(name, state)
for k,v in pairs(state) do
str = (str.." ["..k.."] = {win = {id = "..v.win.id.."}, topline = "
..v.topline..", botline = "..v.botline..", curline = "..v.curline
..", curcol = "..v.curcol..", linecount = "..v.linecount.."};\n")
..", curcol = "..v.curcol..", linecount = "..v.linecount..", scroll_delta = "..v.scroll_delta.."};\n")
end
return str .. "}"
elseif name == "float_pos" then