mirror of
https://github.com/koreader/koreader.git
synced 2025-08-10 00:52:38 +00:00
mod: fix bug in cursor move
only move cursor to word in current view
This commit is contained in:
@@ -277,15 +277,14 @@ function DJVUReader:startHighLightMode()
|
||||
l.new, w.new = _prevWord(t, l.cur, w.cur)
|
||||
end
|
||||
|
||||
self.cursor:clear()
|
||||
if w.new ~= 0 and
|
||||
not self:_isWordInScreenHeightRange(t[l.new][w.new]) then
|
||||
not self:_isWordInScreenHeightRange(t[l.new][w.new])
|
||||
and self:_isWordInScreenWidthRange(t[l.new][w.new]) then
|
||||
-- word is in previous view
|
||||
local pageno = self:prevView()
|
||||
self:goto(pageno)
|
||||
is_next_view = true
|
||||
else
|
||||
-- no need to goto next view, clear previous cursor manually
|
||||
self.cursor:clear()
|
||||
end
|
||||
|
||||
-- update cursor
|
||||
@@ -314,13 +313,13 @@ function DJVUReader:startHighLightMode()
|
||||
end
|
||||
end
|
||||
|
||||
self.cursor:clear()
|
||||
if w.new ~= 0 and
|
||||
not self:_isWordInScreenHeightRange(t[l.new][w.new]) then
|
||||
not self:_isWordInScreenHeightRange(t[l.new][w.new])
|
||||
and self:_isWordInScreenWidthRange(t[l.new][w.new]) then
|
||||
local pageno = self:nextView()
|
||||
self:goto(pageno)
|
||||
is_next_view = true
|
||||
else
|
||||
self.cursor:clear()
|
||||
end
|
||||
|
||||
if w.cur == 0 then
|
||||
@@ -345,15 +344,15 @@ function DJVUReader:startHighLightMode()
|
||||
l.new, w.new = _wordInPrevLine(t, l.cur, w.cur)
|
||||
end
|
||||
|
||||
if w.new ~= 0 and
|
||||
not self:_isWordInScreenHeightRange(t[l.new][w.new])
|
||||
self.cursor:clear()
|
||||
if w.new ~= 0
|
||||
and not self:_isWordInScreenHeightRange(t[l.new][w.new])
|
||||
and self:_isWordInScreenWidthRange(t[l.new][w.new])
|
||||
or w.new == 0 and not self:_isWordInScreenHeightRange(t[l.new][1]) then
|
||||
-- goto next view of current page
|
||||
local pageno = self:prevView()
|
||||
self:goto(pageno)
|
||||
is_next_view = true
|
||||
else
|
||||
self.cursor:clear()
|
||||
end
|
||||
|
||||
if w.new == 0 then
|
||||
@@ -375,15 +374,16 @@ function DJVUReader:startHighLightMode()
|
||||
l.new, w.new = _wordInNextLine(t, l.cur, w.cur)
|
||||
end
|
||||
|
||||
self.cursor:clear()
|
||||
if w.cur ~= 0 and
|
||||
not self:_isWordInScreenHeightRange(t[l.new][w.new])
|
||||
or w.cur == 0 and not self:_isWordInScreenHeightRange(t[l.new][1]) then
|
||||
and self:_isWordInScreenWidthRange(t[l.new][w.new])
|
||||
or w.cur == 0
|
||||
and not self:_isWordInScreenHeightRange(t[l.new][1]) then
|
||||
-- goto next view of current page
|
||||
local pageno = self:nextView()
|
||||
self:goto(pageno)
|
||||
is_next_view = true
|
||||
else
|
||||
self.cursor:clear()
|
||||
end
|
||||
|
||||
if w.cur == 0 then
|
||||
|
||||
11
graphics.lua
11
graphics.lua
@@ -42,6 +42,7 @@ Cursor = {
|
||||
h = 10,
|
||||
w = nil,
|
||||
line_w = nil,
|
||||
is_cleared = true,
|
||||
}
|
||||
|
||||
function Cursor:new(o)
|
||||
@@ -76,11 +77,17 @@ function Cursor:_draw(x, y)
|
||||
end
|
||||
|
||||
function Cursor:draw()
|
||||
self:_draw(self.x_pos, self.y_pos)
|
||||
if self.is_cleared then
|
||||
self.is_cleared = false
|
||||
self:_draw(self.x_pos, self.y_pos)
|
||||
end
|
||||
end
|
||||
|
||||
function Cursor:clear()
|
||||
self:_draw(self.x_pos, self.y_pos)
|
||||
if not self.is_cleared then
|
||||
self.is_cleared = true
|
||||
self:_draw(self.x_pos, self.y_pos)
|
||||
end
|
||||
end
|
||||
|
||||
function Cursor:move(x_off, y_off)
|
||||
|
||||
Reference in New Issue
Block a user