mirror of
https://github.com/koreader/koreader.git
synced 2025-08-10 00:52:38 +00:00
naive implementation of search highlight issue #75
This commit is contained in:
Submodule kpvcrlib/crengine updated: b62d054cca...7f0e8a096e
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user