diff --git a/kpvcrlib/crengine b/kpvcrlib/crengine index b62d054cc..7f0e8a096 160000 --- a/kpvcrlib/crengine +++ b/kpvcrlib/crengine @@ -1 +1 @@ -Subproject commit b62d054cca57366bc1ba2fa249c5bbf5c5234346 +Subproject commit 7f0e8a096e80f366b20ba2a301f44bfc27568b98 diff --git a/unireader.lua b/unireader.lua index b041336cd..d77ad239f 100644 --- a/unireader.lua +++ b/unireader.lua @@ -2462,6 +2462,56 @@ function UniReader:addAllCommands() unireader:goto(unireader.pageno) end ) + self.commands:add(KEY_DOT, nil, ".", + "search and highlight text", + function(unireader) + local search = InputBox:input(G_height - 100, 100, + "Search:") + + if search == nil or string.len( search ) < 1 then + unireader:goto(unireader.pageno) + return nil + end + + local t = self:getText(self.pageno) + if not t or #t == 0 then + showInfoMsgWithDelay("No text available for search", 2000, 1); + return nil + end + + Debug("self:getText", self.pageno,t) + + for i = 1, #t, 1 do + for j = 1, #t[i], 1 do + local e = t[i][j] + if e.word ~= nil then + if string.match( e.word, search ) then + + if not self.highlight[self.pageno] then + self.highlight[self.pageno] = {} + end + + local hl_item = { + text = e.word, + [1] = { + x0 = e.x0, + y0 = e.y0, + x1 = e.x1, + y1 = e.y1, + } + } + + table.insert(self.highlight[self.pageno], hl_item) + end + end + end + end + + Debug("self.highlight", self.highlight); + + unireader:goto(unireader.pageno) + end + ) self.commands:add(KEY_P, MOD_SHIFT, "P", "make screenshot", function(unireader)