Skip to content

Commit

Permalink
Merge branch 'master' into stable
Browse files Browse the repository at this point in the history
  • Loading branch information
nvdaes committed Sep 18, 2018
2 parents a43d05d + cc6a1d6 commit 3fd42bf
Show file tree
Hide file tree
Showing 3 changed files with 86 additions and 61 deletions.
140 changes: 80 additions & 60 deletions addon/globalPlugins/placeMarkers/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
import ui
import speech
import sayAllHandler
from scriptHandler import willSayAllResume
from scriptHandler import willSayAllResume, script
from cursorManager import CursorManager
from logHandler import log
from .skipTranslation import translate
Expand Down Expand Up @@ -226,7 +226,7 @@ def __init__(self, parent):
self.searchTextEdit.Bind(wx.EVT_TEXT, self.onSearchEditTextChange)
# Translators: A label for a chekbox in the Specific search dialog.
self.addCheckBox = sHelper.addItem(wx.CheckBox(self, label=_("&Add to history")))
# Translators: Label for a set of radio buttons in the Specific search dialog.
# Translators: Label for a set of radio buttons in the Specific search dialog.
searchActionsLabel = _("Action on s&earch")
searchChoices = (
# Translators: An action in the Search group of the Specific search dialog.
Expand All @@ -250,7 +250,7 @@ def __init__(self, parent):
self.addCheckBox.Disable()
self.searchRadioBox.Disable()
self.caseSensitiveCheckBox.Disable()
self.Center(wx.BOTH | wx.CENTER_ON_SCREEN)
self.CentreOnScreen()

def onSearchEditTextChange(self, evt):
if self.searchTextEdit.Value:
Expand Down Expand Up @@ -369,7 +369,7 @@ def __init__(self, parent, fileName):
self.Sizer = mainSizer
mainSizer.Fit(self)
self.notesListBox.SetFocus()
self.Center(wx.BOTH | wx.CENTER_ON_SCREEN)
self.CentreOnScreen()

def onNotesChange(self, evt):
self.pos = int(self.notesListBox.GetStringSelection().split(" - ")[0])
Expand Down Expand Up @@ -456,7 +456,7 @@ def __init__(self, parent):
mainSizer.Add(sHelper.sizer, border=gui.guiHelper.BORDER_FOR_DIALOGS, flag=wx.ALL)
self.Sizer = mainSizer
mainSizer.Fit(self)
self.Center(wx.BOTH | wx.CENTER_ON_SCREEN)
self.CentreOnScreen()

def onCopy(self, evt):
if not self.copyDirectoryEdit.Value:
Expand Down Expand Up @@ -526,7 +526,7 @@ def __init__(self, parent):
mainSizer.Add(sHelper.sizer, border=gui.guiHelper.BORDER_FOR_DIALOGS, flag=wx.ALL)
self.Sizer = mainSizer
mainSizer.Fit(self)
self.Center(wx.BOTH | wx.CENTER_ON_SCREEN)
self.CentreOnScreen()

def onRestore(self, evt):
if not self.restoreDirectoryEdit.Value:
Expand Down Expand Up @@ -570,7 +570,7 @@ class GlobalPlugin(globalPluginHandler.GlobalPlugin):
scriptCategory = str(ADDON_SUMMARY)

def __init__(self):
super(globalPluginHandler.GlobalPlugin, self).__init__()
super(GlobalPlugin, self).__init__()
self.menu = gui.mainFrame.sysTrayIcon.preferencesMenu
self.BSMenu = wx.Menu()
self.mainItem = self.menu.AppendSubMenu(self.BSMenu,
Expand Down Expand Up @@ -605,54 +605,67 @@ def __init__(self):

def terminate(self):
try:
self.menu.RemoveItem(self.mainItem)
except wx.PyDeadObjectError:
self.menu.Remove(self.mainItem)
except:
pass

def onSpecificSearch(self, evt):
os.startfile(SEARCH_FOLDER)

@script(
# Translators: message presented in input mode, when a keystroke of an addon script is pressed.
description=_("Opens the specific search folder.")
)
def script_openSpecificSearchFolder(self, gesture):
wx.CallAfter(self.onSpecificSearch, None)
# Translators: message presented in input mode, when a keystroke of an addon script is pressed.
script_openSpecificSearchFolder.__doc__ = _("Opens the specific search folder.")

def onBookmarks(self, evt):
os.startfile(BOOKMARKS_FOLDER)

@script(
# Translators: message presented in input mode, when a keystroke of an addon script is pressed.
description=_("Opens the bookmarks folder.")
)
def script_openBookmarksFolder(self, gesture):
wx.CallAfter(self.onBookmarks, None)
# Translators: message presented in input mode, when a keystroke of an addon script is pressed.
script_openBookmarksFolder.__doc__ = _("Opens the bookmarks folder.")

def onCopy(self, evt):
gui.mainFrame.prePopup()
d = CopyDialog(gui.mainFrame)
d.Show()
gui.mainFrame.postPopup()

@script(
# Translators: message presented in input mode, when a keystroke of an addon script is pressed.
description=_("Activates the Copy dialog of %s." % ADDON_SUMMARY)
)
def script_activateCopyDialog(self, gesture):
wx.CallAfter(self.onCopy, None)
# Translators: message presented in input mode, when a keystroke of an addon script is pressed.
script_activateCopyDialog.__doc__ = _("Activates the Copy dialog of %s." % ADDON_SUMMARY)

def onRestore(self, evt):
gui.mainFrame.prePopup()
d = RestoreDialog(gui.mainFrame)
d.Show()
gui.mainFrame.postPopup()

@script(
# Translators: message presented in input mode, when a keystroke of an addon script is pressed.
description=_("Activates the Restore dialog of %s." % ADDON_SUMMARY)
)
def script_activateRestoreDialog(self, gesture):
wx.CallAfter(self.onRestore, None)
# Translators: message presented in input mode, when a keystroke of an addon script is pressed.
script_activateRestoreDialog.__doc__ = _("Activates the Restore dialog of %s." % ADDON_SUMMARY)

def popupSpecificSearchDialog(self):
gui.mainFrame.prePopup()
d = SpecificSearchDialog(gui.mainFrame)
d.Show()
gui.mainFrame.postPopup()

@script(
# Translators: message presented in input mode, when a keystroke of an addon script is pressed.
description=_("finds a text string from the current cursor position for a specific document."),
gesture="kb:NVDA+control+shift+f"
)
def script_specificFind(self,gesture):
obj=api.getFocusObject()
if not controlTypes.STATE_MULTILINE in obj.states:
Expand All @@ -661,8 +674,6 @@ def script_specificFind(self,gesture):
gesture.send()
return
self.popupSpecificSearchDialog()
# Translators: message presented in input mode, when a keystroke of an addon script is pressed.
script_specificFind.__doc__ = _("finds a text string from the current cursor position for a specific document.")

def popupNotesDialog(self):
if getSavedBookmarks() == {}:
Expand All @@ -675,6 +686,11 @@ def popupNotesDialog(self):
d.Show()
gui.mainFrame.postPopup()

@script(
# Translators: message presented in input mode, when a keystroke of an addon script is pressed.
description=_("Show the Notes dialog for a specific document."),
gesture="kb:NVDA+alt+k"
)
def script_activateNotesDialog(self, gesture):
obj=api.getFocusObject()
appName=appModuleHandler.getAppNameFromProcessID(obj.processID,True)
Expand All @@ -686,9 +702,12 @@ def script_activateNotesDialog(self, gesture):
gesture.send()
return
wx.CallAfter(self.popupNotesDialog)
# Translators: message presented in input mode, when a keystroke of an addon script is pressed.
script_activateNotesDialog.__doc__ = _("Show the Notes dialog for a specific document.")

@script(
# Translators: message presented in input mode, when a keystroke of an addon script is pressed.
description=_("Saves the current position as a bookmark."),
gesture="kb:NVDA+control+shift+k"
)
def script_saveBookmark(self, gesture):
obj = api.getFocusObject()
appName=appModuleHandler.getAppNameFromProcessID(obj.processID,True)
Expand All @@ -713,8 +732,7 @@ def script_saveBookmark(self, gesture):
count = len(start.text)
bookmarks = getSavedBookmarks()
noteTitle = obj.makeTextInfo(textInfos.POSITION_SELECTION).text[:100].encode("mbcs")
positions = list(bookmarks.keys())
if count in positions:
if count in bookmarks:
noteBody = bookmarks[count].body
else:
noteBody = ""
Expand All @@ -731,9 +749,12 @@ def script_saveBookmark(self, gesture):
# Translators: message presented when a bookmark cannot be saved.
_("Cannot save bookmark"))
raise e
# Translators: message presented in input mode, when a keystroke of an addon script is pressed.
script_saveBookmark.__doc__ = _("Saves the current position as a bookmark.")

@script(
# Translators: message presented in input mode, when a keystroke of an addon script is pressed.
description=_("Deletes the current bookmark."),
gesture="kb:NVDA+control+shift+delete"
)
def script_deleteBookmark(self, gesture):
obj = api.getFocusObject()
treeInterceptor=obj.treeInterceptor
Expand All @@ -743,8 +764,7 @@ def script_deleteBookmark(self, gesture):
gesture.send()
return
bookmarks = getSavedBookmarks()
positions = list(bookmarks.keys())
if len(positions) == 0:
if bookmarks == {}:
ui.message(
# Translators: message presented when the current document doesn't contain bookmarks.
_("No bookmarks"))
Expand All @@ -759,14 +779,14 @@ def script_deleteBookmark(self, gesture):
return
start.setEndPoint(end, "endToStart")
count = len(start.text)
if count not in positions:
if count not in bookmarks:
ui.message(
# Translators: message presented when the current document has bookmarks, but none is selected.
_("No bookmark selected"))
return
del(bookmarks[count])
fileName = getFileBookmarks()
if len(positions) > 0:
if bookmarks != {}:
try:
pickle.dump(bookmarks, file(fileName, "wb"))
ui.message(
Expand All @@ -778,19 +798,23 @@ def script_deleteBookmark(self, gesture):
else:
try:
os.remove(fileName)
ui.message(_
ui.message(
# Translators: message presented when the current document doesn't contain bookmarks.
("No bookmarks"))
_("No bookmarks"))
return
except WindowsError:
pass
log.debugWarning("Error saving bookmarks", exc_info=True)
ui.message(
# Translators: message presented when cannot delete a bookmark.
_("Cannot delete bookmark"))
# Translators: message presented in input mode, when a keystroke of an addon script is pressed.
script_deleteBookmark.__doc__ = _("Deletes the current bookmark.")

@script(
# Translators: message presented in input mode, when a keystroke of an addon script is pressed.
description=_("Moves to the next bookmark."),
resumeSayAllMode=sayAllHandler.CURSOR_CARET,
gesture="kb:NVDA+k"
)
def script_selectNextBookmark(self, gesture):
obj = api.getFocusObject()
appName=appModuleHandler.getAppNameFromProcessID(obj.processID,True)
Expand All @@ -804,8 +828,7 @@ def script_selectNextBookmark(self, gesture):
gesture.send()
return
bookmarks = getSavedBookmarks()
positions = list(bookmarks.keys())
if len(positions) == 0:
if bookmarks == {}:
ui.message(
# Translators: message presented when trying to select a bookmark, but none is found.
_("No bookmarks found"))
Expand All @@ -820,6 +843,7 @@ def script_selectNextBookmark(self, gesture):
return
start.setEndPoint(end, "endToStart")
count = len(start.text)
positions = list(bookmarks.keys())
positions.sort()
for pos in positions:
if pos > count:
Expand All @@ -835,10 +859,13 @@ def script_selectNextBookmark(self, gesture):
ui.message(
# Translators: message presented when the next bookmark is not found.
_("Next bookmark not found"))
script_selectNextBookmark.resumeSayAllMode=sayAllHandler.CURSOR_CARET
# Translators: message presented in input mode, when a keystroke of an addon script is pressed.
script_selectNextBookmark.__doc__ = _("Moves to the next bookmark.")

@script(
# Translators: message presented in input mode, when a keystroke of an addon script is pressed.
description=_("Moves to the previous bookmark."),
resumeSayAllMode=sayAllHandler.CURSOR_CARET,
gesture="kb:NVDA+shift+k"
)
def script_selectPreviousBookmark(self, gesture):
obj = api.getFocusObject()
appName=appModuleHandler.getAppNameFromProcessID(obj.processID,True)
Expand All @@ -852,8 +879,7 @@ def script_selectPreviousBookmark(self, gesture):
gesture.send()
return
bookmarks = getSavedBookmarks()
positions = list(bookmarks.keys())
if len(positions) == 0:
if bookmarks == {}:
ui.message(
# Translators: message presented when trying to select a bookmark, but none is found.
_("No bookmarks found"))
Expand All @@ -867,6 +893,7 @@ def script_selectPreviousBookmark(self, gesture):
return
start.setEndPoint(end, "endToStart")
count = len(start.text)
positions = list(bookmarks.keys())
positions.sort()
positions.reverse()
for pos in positions:
Expand All @@ -883,10 +910,12 @@ def script_selectPreviousBookmark(self, gesture):
ui.message(
# Translators: message presented when the previous bookmark is not found.
_("Previous bookmark not found"))
script_selectPreviousBookmark.resumeSayAllMode=sayAllHandler.CURSOR_CARET
# Translators: message presented in input mode, when a keystroke of an addon script is pressed.
script_selectPreviousBookmark.__doc__ = _("Moves to the previous bookmark.")

@script(
# Translators: message presented in input mode, when a keystroke of an addon script is pressed.
description=_("Copies the name of the current file for place markers to the clipboard."),
gesture="kb:control+shift+k"
)
def script_copyCurrentBookmarksFile(self, gesture):
obj=api.getFocusObject()
if not controlTypes.STATE_MULTILINE in obj.states:
Expand All @@ -903,9 +932,11 @@ def script_copyCurrentBookmarksFile(self, gesture):
ui.message(
# Translators: message presented when file name for place markers is copied to clipboard.
_("Place markers file name copied to clipboard"))
# 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.")

@script(
# Translators: message presented in input mode, when a keystroke of an addon script is pressed.
description=_("Saves the current position as a temporary bookmark.")
)
def script_saveTempBookmark(self, gesture):
obj = api.getFocusObject()
appName=appModuleHandler.getAppNameFromProcessID(obj.processID,True)
Expand Down Expand Up @@ -937,9 +968,11 @@ def script_saveTempBookmark(self, gesture):
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.")

@script(
# Translators: Message presented in input help mode.
description=_("Moves to the temporary bookmark for the current document.")
)
def script_moveToTempBookmark(self, gesture):
obj = api.getFocusObject()
appName=appModuleHandler.getAppNameFromProcessID(obj.processID,True)
Expand All @@ -958,16 +991,3 @@ def script_moveToTempBookmark(self, gesture):
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",
"kb:control+shift+NVDA+delete": "deleteBookmark",
"kb:NVDA+k": "selectNextBookmark",
"kb:shift+NVDA+k": "selectPreviousBookmark",
"kb:control+shift+k": "copyCurrentBookmarksFile",
"kb:alt+NVDA+k": "activateNotesDialog",
}

2 changes: 1 addition & 1 deletion buildVars.py
Original file line number Diff line number Diff line change
Expand Up @@ -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" : "10.2",
"addon_version" : "11.0",
# Author(s)
"addon_author" : u"Noelia <[email protected]>, Chris <[email protected]>",
# URL for the add-on documentation support
Expand Down
5 changes: 5 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ 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 11.0 ##
* Compatible with NVDA 2018.3 or later (required).
* If needed, you can download the [last version compatible with NVDA 2017.3][3].

## Changes for 10.0 ##
* In Edge, gestures associated with bookmarks selection, such as NVDA+k, NVDA+shift+k or NVDA+alt+k, will be sent to the application instead of trying to move the cursor to bookmarks, to avoid errors, especially in long documents.
* Now specific search is supported in Edge.
Expand Down Expand Up @@ -86,3 +90,4 @@ Note: The bookmark position is based on the number of characters; and therefore
[1]: http://addons.nvda-project.org/files/get.php?file=pm

[2]: http://addons.nvda-project.org/files/get.php?file=pm-dev
[3]: https://github.com/nvdaes/placeMarkers/releases/download/10.2/placeMarkers-10.2.nvda-addon

0 comments on commit 3fd42bf

Please sign in to comment.