TouchMenu: menu search without patterns (#9884)

See <https://github.com/koreader/koreader/pull/9876#issuecomment-1340090208>.
reviewable/pr9886/r1
Frans de Jonge 1 year ago committed by GitHub
parent e58a12ba04
commit e026598f72
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -1010,7 +1010,7 @@ function TouchMenu:search(search_for)
local next_text = text and (text .. "\n" .. indent .. entry_text) or (indent .. entry_text)
local next_path = path .. "." .. i
recurse(val[i], next_path, next_text, icon, depth)
if Utf8Proc.lowercase(entry_text):find(search_for) then
if Utf8Proc.lowercase(entry_text):find(search_for, 1, true) then
table.insert(found_menu_items, {entry_text, icon, next_path, next_text})
end
end
@ -1319,18 +1319,10 @@ function TouchMenu:onShowMenuSearch()
text = _("Search"),
callback = function()
local search_for = search_dialog:getInputText()
local status, err = pcall( function() ("test_string"):find(search_for) end)
if status then
search_for = Utf8Proc.lowercase(search_for)
G_reader_settings:saveSetting("menu_search_string", search_for)
UIManager:close(search_dialog)
show_search_results(search_for)
else
err = err:sub(err:find("lua") + 10) -- 10 = strlen("lua:1165: ")
UIManager:show(InfoMessage:new{
text = T(_("Malformed message:\n%1"), err)
})
end
search_for = Utf8Proc.lowercase(search_for)
G_reader_settings:saveSetting("menu_search_string", search_for)
UIManager:close(search_dialog)
show_search_results(search_for)
end,
},
}

Loading…
Cancel
Save