From f6270278aa1265b0aba83f8fa8bae8678e060a06 Mon Sep 17 00:00:00 2001 From: Frans de Jonge Date: Fri, 30 Aug 2019 13:27:03 +0200 Subject: [PATCH] [feat] Implement fulltext search direction (#5283) Closes . --- frontend/apps/reader/modules/readersearch.lua | 41 ++++++++++++++----- 1 file changed, 31 insertions(+), 10 deletions(-) diff --git a/frontend/apps/reader/modules/readersearch.lua b/frontend/apps/reader/modules/readersearch.lua index 12aa1d555..e2986121e 100644 --- a/frontend/apps/reader/modules/readersearch.lua +++ b/frontend/apps/reader/modules/readersearch.lua @@ -30,15 +30,36 @@ end function ReaderSearch:onShowFulltextSearchInput() self:onInput{ title = _("Enter text to search for"), - ok_text = _("Search all text"), type = "text", - callback = function(input) - self:onShowSearchDialog(input) - end, + buttons = { + { + { + text = _("Cancel"), + callback = function() + self:closeInputDialog() + end, + }, + { + text = "◁", + callback = function() + self:onShowSearchDialog(self.input_dialog:getInputText(), 1) + self:closeInputDialog() + end, + }, + { + text = "▷", + is_enter_default = true, + callback = function() + self:onShowSearchDialog(self.input_dialog:getInputText(), 0) + self:closeInputDialog() + end, + }, + }, + }, } end -function ReaderSearch:onShowSearchDialog(text) +function ReaderSearch:onShowSearchDialog(text, direction) local neglect_current_location = false local current_page local do_search = function(search_func, _text, param) @@ -122,19 +143,19 @@ function ReaderSearch:onShowSearchDialog(text) buttons = { { { - text = "|<", + text = "▕◁", callback = do_search(self.searchFromStart, text), }, { - text = "<", + text = "◁", callback = do_search(self.searchNext, text, 1), }, { - text = ">", + text = "▷", callback = do_search(self.searchNext, text, 0), }, { - text = ">|", + text = "▷▏", callback = do_search(self.searchFromEnd, text), }, } @@ -145,7 +166,7 @@ function ReaderSearch:onShowSearchDialog(text) UIManager:setDirty(self.dialog, "ui") end, } - do_search(self.searchFromCurrent, text, 0)() + do_search(self.searchFromCurrent, text, direction)() UIManager:show(self.search_dialog) --- @todo regional UIManager:setDirty(self.dialog, "partial")