mirror of
https://github.com/koreader/koreader.git
synced 2025-08-10 00:52:38 +00:00
Merge pull request #470 from thotypous/fix-box-empty-page
Fix crash trying to select text in an empty page
This commit is contained in:
@@ -593,6 +593,7 @@ end
|
||||
get word and word box around pos
|
||||
--]]
|
||||
function KoptInterface:getWordFromBoxes(boxes, pos)
|
||||
if not pos or #boxes == 0 then return {} end
|
||||
local i, j = getWordBoxIndices(boxes, pos)
|
||||
local lb = boxes[i]
|
||||
local wb = boxes[i][j]
|
||||
@@ -613,7 +614,7 @@ end
|
||||
get text and text boxes between pos0 and pos1
|
||||
--]]
|
||||
function KoptInterface:getTextFromBoxes(boxes, pos0, pos1)
|
||||
if not pos0 or not pos1 then return {} end
|
||||
if not pos0 or not pos1 or #boxes == 0 then return {} end
|
||||
local line_text = ""
|
||||
local line_boxes = {}
|
||||
local i_start, j_start = getWordBoxIndices(boxes, pos0)
|
||||
|
||||
@@ -296,7 +296,7 @@ function ReaderHighlight:lookup(selected_word)
|
||||
local word_box = self.view:pageToScreenTransform(self.hold_pos.page, selected_word.sbox)
|
||||
self.ui:handleEvent(Event:new("LookupWord", self, selected_word.word, word_box))
|
||||
-- or we will do OCR
|
||||
else
|
||||
elseif selected_word.sbox then
|
||||
local word = self.ui.document:getOCRWord(self.hold_pos.page, selected_word)
|
||||
DEBUG("OCRed word:", word)
|
||||
local word_box = self.view:pageToScreenTransform(self.hold_pos.page, selected_word.sbox)
|
||||
|
||||
Reference in New Issue
Block a user