sokoban.love/0035-compute_scrollbar

8 lines
461 B
Plaintext

-- returns:
-- * a float between 0 and 1 regarding the relative position of the top line on screen
-- * a float between 0 and 1 regarding the relative position of the bottom line on screen
compute_scrollbar = function(state)
local top = state.line_cache[state.screen_top1.line].start_screen_line_index
local bot = state.line_cache[state.screen_bottom1.line].start_screen_line_index
return (top-1)/state.screen_line_count, bot/state.screen_line_count
end