diff options
Diffstat (limited to 'state.lua')
| -rw-r--r-- | state.lua | 9 |
1 files changed, 6 insertions, 3 deletions
@@ -92,14 +92,17 @@ function menu_mt:set_cursor(pos, lines, opts) goto update end + if opts and opts.margin then + margin = math.min(opts.margin, math.floor((lines - 1) / 2)) + end + if opts and opts.centre then top = pos - math.floor((lines - 1) / 2) elseif opts and opts.keep_offset then top = top + pos - self.cursor - elseif opts and opts.margin then + elseif margin > 0 then margin = math.max(0, math.min( - opts.margin, - math.floor((lines - 1) / 2), + margin, self.cursor - self.view_top, self.view_top + lines - 1 - self.cursor)) end |
