diff --git a/addon/globalPlugins/placeMarkers/__init__.py b/addon/globalPlugins/placeMarkers/__init__.py index 5d2995ef..221147a7 100644 --- a/addon/globalPlugins/placeMarkers/__init__.py +++ b/addon/globalPlugins/placeMarkers/__init__.py @@ -171,6 +171,9 @@ def getLastSpecificFindText(): def getFileBookmarks(): return getFile("bookmarks", ".pickle") +def getFileTempBookmark(): + return getFile("bookmarks", ".txt") + def getSavedBookmarks(): fileName = getFileBookmarks() try: @@ -836,6 +839,48 @@ def script_copyCurrentBookmarksFile(self, gesture): # Translators: message presented in input mode, when a keystroke of an addon script is pressed. script_copyCurrentBookmarksFile.__doc__ = _("Copies the name of the current file for place markers to the clipboard.") + def script_saveTempBookmark(self, gesture): + obj = api.getFocusObject() + treeInterceptor=obj.treeInterceptor + if hasattr(treeInterceptor,'TextInfo') and not treeInterceptor.passThrough: + obj=treeInterceptor + else: + gesture.send() + return + start = obj.makeTextInfo(textInfos.POSITION_ALL) + try: + end = obj.makeTextInfo(textInfos.POSITION_CARET) + except (NotImplementedError, RuntimeError): + ui.message( + # Translators: message presented when a bookmark cannot be saved. + _("Bookmark cannot be saved")) + return + start.setEndPoint(end, "endToStart") + count = len(start.text) + fileName = getFileTempBookmark() + try: + with codecs.open(fileName, "w", "utf-8") as f: + f.write(str(count)) + # Translators: Message presented when a temporary bookmark is saved. + ui.message(_("Saved temporary bookmark at position %d" % count)) + except Exception as e: + log.debugWarning("Error saving temporary bookmark", exc_info=True) + raise e + # Translators: message presented in input mode, when a keystroke of an addon script is pressed. + script_saveTempBookmark.__doc__ = _("Saves the current position as a temporary bookmark.") + + def script_moveToTempBookmark(self, gesture): + fileName = getFileTempBookmark() + try: + with codecs.open(fileName, "r", "utf-8") as f: + tempBookmark = int(f.read()) + moveToBookmark(tempBookmark) + except: + # Translators: Message presented when a temporary bookmark can't be found. + ui.message("Temporary bookmark not found") + # Translators: Message presented in input help mode. + script_moveToTempBookmark.__doc__ = _("Moves to the temporary bookmark for the current document.") + __gestures = { "kb:control+shift+NVDA+f": "specificFind", "kb:control+shift+NVDA+k": "saveBookmark", diff --git a/addon/readme.md b/addon/readme.md index 6742eec8..b832fb38 100644 --- a/addon/readme.md +++ b/addon/readme.md @@ -17,8 +17,8 @@ This addon is based on SpecificSearch and Bookmark&Search, developed by the same * shift+NVDA+k: Moves to the previous bookmark. * control+shift+k: Copies the file name where the place markers data will be saved to the clipboard, without an extension. * alt+NVDA+k: Opens a dialog with the bookmarks saved for this document. You can write a note for each bookmark; press Save note to save changes. Pressing OK you can move to the selected position. - -Note: Sometimes this doesn't work on browsers like Firefox. If it happens, please refresh the buffer pressing NVDA+f5 and try to use the dialog again, or move to the bookmark from the document using NVDA+k. +* Not assigned: Save a position as a temporary bookmark. +* Not assigned: Moves to the temporary bookmark for the current document. ## Place markers Submenu (NVDA+N) ## @@ -32,6 +32,8 @@ Using the Place markers submenu under NVDA's Preferences menu, you can access: Note: The bookmark position is based on the number of characters; and therefore in dynamic pages it is better to use the specific search, not bookmarks. +## Changes for 9.0 ## +* It's possible to save and move to a temporary bookmark for each document. ## Changes for 8.0 ## * Removed fragment identifiers from bookmark filenames, which can avoid issues in the VitalSource Bookshelf ePUB reader. diff --git a/buildVars.py b/buildVars.py index 964d1855..9139e613 100755 --- a/buildVars.py +++ b/buildVars.py @@ -19,7 +19,7 @@ # Translators: Long description to be shown for this add-on on add-on information from add-ons manager "addon_description" : _("Add-on for setting place markers on specific virtual documents"), # version - "addon_version" : "8.0", + "addon_version" : "9.0-dev", # Author(s) "addon_author" : u"Noelia , Chris ", # URL for the add-on documentation support