summaryrefslogtreecommitdiff
path: root/state.lua
diff options
context:
space:
mode:
Diffstat (limited to 'state.lua')
-rw-r--r--state.lua15
1 files changed, 15 insertions, 0 deletions
diff --git a/state.lua b/state.lua
index 326fa28..3abb892 100644
--- a/state.lua
+++ b/state.lua
@@ -82,6 +82,21 @@ function mt:insert_favourite_before_next_in_menu(id)
self:add_favourite(id)
end
+function menu_mt:save_checkpoint()
+ self.checkpoint = {
+ search_text = self.search_text,
+ cursor = self.cursor,
+ view_top = self.view_top,
+ }
+end
+
+function menu_mt:restore_checkpoint()
+ local t = self.checkpoint
+ self:set_search_text(t.search_text)
+ self.cursor = t.cursor
+ self.view_top = t.view_top
+end
+
function menu_mt:set_cursor(pos, lines, opts)
local pos = math.max(1, math.min(pos, #self.options))
local top = self.view_top