cre.getWordFromPosition(): fix a few issues

Drop the use of crengine's getWordFromPosition() which
is a bit unreliable: it may returns wrong coordinates,
or words from far away in the book (ie. when holding
in the margins).
Rely only on the robust getTextFromPositions() that
we already use for multi words selection.
Having good coordinates allows refreshing a smaller region
(the higlighted word, or the 2 lines if hyphenated).
This commit is contained in:
poire-z committed 2020-12-31 13:28:08 +01:00
1 parent d560f9011d
commit dd74194e0a
2 files changed
+76 -22

No files matched your search

@@ -760,10 +760,10 @@ function ReaderHighlight:onHold(arg, ges)
table.insert(boxes, self.selected_word.sbox)
self.view.highlight.temp[self.hold_pos.page] = boxes
end
UIManager:setDirty(self.dialog, "ui")
--- @todo only mark word?
-- Unfortunately, CREngine does not return good coordinates
-- UIManager:setDirty(self.dialog, "partial", self.selected_word.sbox)
-- UIManager:setDirty(self.dialog, "ui")
-- But now it does:
UIManager:setDirty(self.dialog, "ui", self.selected_word.sbox)
self:_resetHoldTimer()
if word.pos0 then
-- Remember original highlight start position, so we can show