mirror of
https://github.com/koreader/koreader.git
synced 2025-08-10 00:52:38 +00:00
[feat] Implement fulltext search direction (#5283)
Closes <https://github.com/koreader/koreader/issues/5054>.
This commit is contained in:
@@ -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")
|
||||
|
||||
Reference in New Issue
Block a user