From de5c872dcbdfda9deaab942c56fab94fad9160b1 Mon Sep 17 00:00:00 2001 From: yparitcher Date: Thu, 4 May 2023 19:00:28 -0400 Subject: [PATCH] Dispatcher: add `addCurrentLocationToStack` This is useful when i want to reference something a few pages away while keeping track of my current page --- frontend/apps/reader/modules/readerlink.lua | 7 +++++++ frontend/dispatcher.lua | 2 ++ 2 files changed, 9 insertions(+) diff --git a/frontend/apps/reader/modules/readerlink.lua b/frontend/apps/reader/modules/readerlink.lua index ef3a78d87..8f0cb32db 100644 --- a/frontend/apps/reader/modules/readerlink.lua +++ b/frontend/apps/reader/modules/readerlink.lua @@ -702,6 +702,13 @@ function ReaderLink:compareLocationToCurrent(saved_location) return false, current_location end +function ReaderLink:onAddCurrentLocationToStack(show_notification) + self:addCurrentLocationToStack() + if show_notification then + Notification:notify(_("Current location added to history.")) + end +end + -- Remember current location so we can go back to it function ReaderLink:addCurrentLocationToStack(loc) local location = loc and loc or self:getCurrentLocation() diff --git a/frontend/dispatcher.lua b/frontend/dispatcher.lua index e8e4b46ca..95a10c853 100644 --- a/frontend/dispatcher.lua +++ b/frontend/dispatcher.lua @@ -127,6 +127,7 @@ local settingsList = { latest_bookmark = {category="none", event="GoToLatestBookmark", title=_("Go to latest bookmark"), reader=true}, follow_nearest_link = {category="arg", event="GoToPageLink", arg={pos={x=0,y=0}}, title=_("Follow nearest link"), reader=true}, follow_nearest_internal_link = {category="arg", event="GoToInternalPageLink", arg={pos={x=0,y=0}}, title=_("Follow nearest internal link"), reader=true}, + add_location_to_history = {category="none", event="AddCurrentLocationToStack", arg=true, title=_("Add current location to history"), reader=true}, clear_location_history = {category="none", event="ClearLocationStack", arg=true, title=_("Clear location history"), reader=true, separator=true}, toc = {category="none", event="ShowToc", title=_("Table of contents"), reader=true}, book_map = {category="none", event="ShowBookMap", title=_("Book map"), reader=true, condition=Device:isTouchDevice()}, @@ -312,6 +313,7 @@ local dispatcher_menu_order = { "next_location", "follow_nearest_link", "follow_nearest_internal_link", + "add_location_to_history", "clear_location_history", "toc",