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