diff options
| author | David Vazgenovich Shakaryan <dvshakaryan@gmail.com> | 2026-01-07 15:46:45 -0800 |
|---|---|---|
| committer | David Vazgenovich Shakaryan <dvshakaryan@gmail.com> | 2026-01-07 15:46:45 -0800 |
| commit | 83b4d6ff1dac0d483ad1a470fef80485c151a0ea (patch) | |
| tree | 309f44a0613becd0c4292edcc6b1b30c3d06cd47 /state.lua | |
| parent | 2dc4809f5cba14838def5abea3220793ae0d8e4a (diff) | |
| download | mpv-iptv-menu-83b4d6ff1dac0d483ad1a470fef80485c151a0ea.tar.gz mpv-iptv-menu-83b4d6ff1dac0d483ad1a470fef80485c151a0ea.tar.xz | |
don't redraw when cursor position doesn't change
Diffstat (limited to 'state.lua')
| -rw-r--r-- | state.lua | 11 |
1 files changed, 11 insertions, 0 deletions
@@ -85,6 +85,12 @@ end function menu_mt:set_cursor(pos, lines, opts) local pos = math.max(1, math.min(pos, #self.options)) local top = self.view_top + + if not lines then + top = pos + goto update + end + if opts and opts.centre then top = pos - math.floor((lines - 1) / 2) elseif opts and opts.keep_offset then @@ -100,8 +106,13 @@ function menu_mt:set_cursor(pos, lines, opts) top = math.max(1, math.min(top, #self.options - lines + 1)) + ::update:: + if pos == self.cursor and top == self.view_top then + return false + end self.cursor = pos self.view_top = top + return true end function menu_mt:set_sort(bool, f) |
