fix cannot highlight hyphenated words in crereader

pull/486/head
chrox 11 years ago
parent 561ba08761
commit bfff863861

@ -135,9 +135,10 @@ end
function CreDocument:getWordFromPosition(pos) function CreDocument:getWordFromPosition(pos)
local word_box = self._document:getWordFromPosition(pos.x, pos.y) local word_box = self._document:getWordFromPosition(pos.x, pos.y)
local text_range = self._document:getTextFromPositions(pos.x, pos.y, pos.x, pos.y)
if word_box.word then if word_box.word then
return { return {
word = word_box.word, word = text_range.text == "" and word_box.word or text_range.text,
page = self._document:getCurrentPage(), page = self._document:getCurrentPage(),
sbox = Geom:new{ sbox = Geom:new{
x = word_box.x0, y = word_box.y0, x = word_box.x0, y = word_box.y0,
@ -156,7 +157,7 @@ function CreDocument:getTextFromPositions(pos0, pos1)
text = text_range.text, text = text_range.text,
pos0 = text_range.pos0, pos0 = text_range.pos0,
pos1 = text_range.pos1, pos1 = text_range.pos1,
sboxes = line_boxes, -- boxes on screen --sboxes = line_boxes, -- boxes on screen
} }
end end
@ -273,6 +274,10 @@ function CreDocument:setFontFace(new_font_face)
end end
end end
function CreDocument:clearSelection()
self._document:clearSelection()
end
function CreDocument:getFontSize() function CreDocument:getFontSize()
return self._document:getFontSize() return self._document:getFontSize()
end end

@ -159,9 +159,13 @@ end
function ReaderHighlight:onTap(arg, ges) function ReaderHighlight:onTap(arg, ges)
if self.hold_pos then if self.hold_pos then
self.view.highlight.temp[self.hold_pos.page] = nil if self.ui.document.info.has_pages then
UIManager:setDirty(self.dialog, "partial") self.view.highlight.temp[self.hold_pos.page] = nil
else
self.ui.document:clearSelection()
end
self.hold_pos = nil self.hold_pos = nil
UIManager:setDirty(self.dialog, "partial")
return true return true
end end
if self.ui.document.info.has_pages then if self.ui.document.info.has_pages then
@ -260,9 +264,11 @@ function ReaderHighlight:onHold(arg, ges)
self.selected_word = self.ui.document:getWordFromPosition(self.hold_pos) self.selected_word = self.ui.document:getWordFromPosition(self.hold_pos)
DEBUG("selected word:", self.selected_word) DEBUG("selected word:", self.selected_word)
if self.selected_word then if self.selected_word then
local boxes = {} if self.ui.document.info.has_pages then
table.insert(boxes, self.selected_word.sbox) local boxes = {}
self.view.highlight.temp[self.hold_pos.page] = boxes table.insert(boxes, self.selected_word.sbox)
self.view.highlight.temp[self.hold_pos.page] = boxes
end
UIManager:setDirty(self.dialog, "partial") UIManager:setDirty(self.dialog, "partial")
end end
return true return true

Loading…
Cancel
Save