From 904a1d8a992029d07eb9ab99df1c00eca44f891c Mon Sep 17 00:00:00 2001 From: David Vazgenovich Shakaryan Date: Tue, 6 May 2025 18:17:05 -0700 Subject: allow resuming previous search --- main.lua | 29 +++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-) (limited to 'main.lua') diff --git a/main.lua b/main.lua index 8d7f40f..c811db1 100644 --- a/main.lua +++ b/main.lua @@ -147,14 +147,18 @@ local function last_option() advance_cursor(math.huge) end -local function push_menu(options, title) - menu = { +local function push_menu(t) + local menu = { + options={}, title=title, - options=options or {}, cursor_pos=1, page_pos=1, } + for k, v in pairs(t) do + menu[k] = v + end + depth = depth + 1 menus[depth] = menu end @@ -172,7 +176,7 @@ local function add_category_menu(category_id, category_name) end end - push_menu(options, category_name) + push_menu({options=options, title=category_name}) update_osd() end @@ -289,11 +293,20 @@ local bind_menu_keys local function search_start() search_active = true - search_text = '' - search_text_cursor = 1 - push_menu() - search_update() + local menu = menus[depth] + if menu.type == 'search' then + search_text_cursor = #search_text + 1 + menu.cursor_pos = 1 + menu.page_pos = 1 + search_update_osd() + else + search_text = '' + search_text_cursor = 1 + push_menu({type='search'}) + search_update() + end + bind_search_keys() end -- cgit v1.2.3-70-g09d2