TOC, bookmarks: remember current page so we can go back to it

This commit is contained in:
poire-z
2018-01-31 13:18:37 +01:00
committed by Frans de Jonge
parent d0f9b53eb3
commit e615345ffa
3 changed files with 13 additions and 2 deletions

View File

@@ -199,6 +199,15 @@ function ReaderLink:onTap(_, ges)
end
end
--- Remember current location so we can go back to it
function ReaderLink:addCurrentLocationToStack()
if self.ui.document.info.has_pages then
table.insert(self.location_stack, self.ui.paging:getBookLocation())
else
table.insert(self.location_stack, self.ui.rolling:getBookLocation())
end
end
--- Goes to link.
function ReaderLink:onGotoLink(link)
logger.dbg("onGotoLink:", link)
@@ -206,7 +215,7 @@ function ReaderLink:onGotoLink(link)
-- internal pdf links have a "page" attribute, while external ones have an "uri" attribute
if link.page then -- Internal link
logger.dbg("Internal link:", link)
table.insert(self.location_stack, self.ui.paging:getBookLocation())
self:addCurrentLocationToStack()
self.ui:handleEvent(Event:new("GotoPage", link.page + 1))
return true
end
@@ -220,7 +229,7 @@ function ReaderLink:onGotoLink(link)
-- which accepts both of the above legitimate xpointer as input.
if self.ui.document:isXPointerInDocument(link) then
logger.dbg("Internal link:", link)
table.insert(self.location_stack, self.ui.rolling:getBookLocation())
self:addCurrentLocationToStack()
self.ui:handleEvent(Event:new("GotoXPointer", link))
return true
end