sokoban.love/0036-adjust_scrollbar

13 lines
405 B
Plaintext
Raw Normal View History

adjust_scrollbar = function(y)
local s = (y-Editor_state.top) / (Editor_state.bottom-Editor_state.top)
local screen_line = s*Editor_state.screen_line_count
local line = 1
for i=1,#Editor_state.lines do
if Editor_state.line_cache[i].start_screen_line_index > screen_line then
break
end
line = i
end
Editor_state.screen_top1 = {line=line, pos=1}
Editor_state.cursor1 = {line=line, pos=1}
end