diff --git a/source/braille.py b/source/braille.py index 1d6ba0ce362..f01ccc54c9c 100644 --- a/source/braille.py +++ b/source/braille.py @@ -965,6 +965,16 @@ def update(self): else: self._brailleInputIndStart = None + def getTextInfoForBraillePos(self, braillePos): + pos = self._rawToContentPos[self.brailleToRawPos[braillePos]] + # pos is relative to the start of the reading unit. + # Therefore, get the start of the reading unit... + dest = self._readingInfo.copy() + dest.collapse() + # and move pos characters from there. + dest.move(textInfos.UNIT_CHARACTER, pos) + return dest + def routeTo(self, braillePos): if self._brailleInputIndStart is not None and self._brailleInputIndStart <= braillePos < self._brailleInputIndEnd: # The user is moving within untranslated braille input. @@ -989,14 +999,7 @@ def routeTo(self, braillePos): except NotImplementedError: pass return - - pos = self._rawToContentPos[self.brailleToRawPos[braillePos]] - # pos is relative to the start of the reading unit. - # Therefore, get the start of the reading unit... - dest = self._readingInfo.copy() - dest.collapse() - # and move pos characters from there. - dest.move(textInfos.UNIT_CHARACTER, pos) + dest = self.getTextInfoForBraillePos(braillePos) self._setCursor(dest) def nextLine(self): @@ -1326,6 +1329,15 @@ def routeTo(self, windowPos): region, pos = self.bufferPosToRegionPos(pos) region.routeTo(pos) + def getTextInfoForWindowPos(self, windowPos): + pos = self.windowStartPos + windowPos + if pos >= self.windowEndPos: + return None + region, pos = self.bufferPosToRegionPos(pos) + if not isinstance(region, TextInfoRegion): + return None + return region.getTextInfoForBraillePos(pos) + def saveWindow(self): """Save the current window so that it can be restored after the buffer is updated. The window start position is saved as a position relative to a region. @@ -1657,6 +1669,11 @@ def routeTo(self, windowPos): if self.buffer is self.messageBuffer: self._dismissMessage() + def getTextInfoForWindowPos(self, windowPos): + if self.buffer is not self.mainBuffer: + return None + return self.buffer.getTextInfoForWindowPos(windowPos) + def message(self, text): """Display a message to the user which times out after a configured interval. The timeout will be reset if the user scrolls the display. diff --git a/source/brailleDisplayDrivers/alva.py b/source/brailleDisplayDrivers/alva.py index 6f379f15fd6..1c26dd6e405 100644 --- a/source/brailleDisplayDrivers/alva.py +++ b/source/brailleDisplayDrivers/alva.py @@ -378,6 +378,7 @@ def script_toggleHidKeyboardInput(self, gesture): "braille_nextLine": ("br(alva):t4",), "braille_scrollForward": ("br(alva):t5","br(alva):etouch3"), "braille_routeTo": ("br(alva):routing",), + "braille_reportFormatting": ("br(alva):secondRouting",), "review_top": ("br(alva):t1+t2",), "review_bottom": ("br(alva):t4+t5",), "braille_toggleTether": ("br(alva):t1+t3",), diff --git a/source/brailleDisplayDrivers/eurobraille.py b/source/brailleDisplayDrivers/eurobraille.py index f36eff7845f..641e8b916ae 100644 --- a/source/brailleDisplayDrivers/eurobraille.py +++ b/source/brailleDisplayDrivers/eurobraille.py @@ -481,7 +481,8 @@ def announceUnavailableMessage(): gestureMap = inputCore.GlobalGestureMap({ "globalCommands.GlobalCommands": { - "braille_routeTo": ("br(eurobraille):routing","br(eurobraille):doubleRouting",), + "braille_routeTo": ("br(eurobraille):routing",), + "braille_reportFormatting": ("br(eurobraille):doubleRouting",), "braille_scrollBack": ( "br(eurobraille):switch1Left", "br(eurobraille):l1", diff --git a/source/brailleDisplayDrivers/papenmeier.py b/source/brailleDisplayDrivers/papenmeier.py index 8d6456f11d7..cdec8bc2a29 100644 --- a/source/brailleDisplayDrivers/papenmeier.py +++ b/source/brailleDisplayDrivers/papenmeier.py @@ -2,9 +2,9 @@ #A part of NonVisual Desktop Access (NVDA) #This file is covered by the GNU General Public License. #See the file COPYING for more details. -#Copyright (C) 2012-2015 Tobias Platen, Halim Sahin, Ali-Riza Ciftcioglu, NV Access Limited +#Copyright (C) 2012-2017 Tobias Platen, Halim Sahin, Ali-Riza Ciftcioglu, NV Access Limited, Davy Kager #Author: Tobias Platen (nvda@lists.thm.de) -#minor changes by Halim Sahin (nvda@lists.thm.de), Ali-Riza Ciftcioglu and James Teh +#minor changes by Halim Sahin (nvda@lists.thm.de), Ali-Riza Ciftcioglu , James Teh and Davy Kager import time import itertools @@ -472,12 +472,6 @@ def _handleKeyPresses(self): if(self._dev!=None): self._dev.close() self._dev=None - def script_upperRouting(self, gesture): - globalCommands.commands.script_braille_routeTo(gesture) - wx.CallLater(50, scriptHandler.executeScript, globalCommands.commands.script_reportFormatting, gesture) - - script_upperRouting.__doc__ = _("Route to and report formatting") - #global gestures gestureMap = inputCore.GlobalGestureMap({ "globalCommands.GlobalCommands": { @@ -486,6 +480,7 @@ def script_upperRouting(self, gesture): "braille_previousLine": ("br(papenmeier):up",), "braille_nextLine": ("br(papenmeier):dn",), "braille_routeTo": ("br(papenmeier):route",), + "braille_reportFormatting": ("br(papenmeier):upperRouting",), "braille_toggleTether": ("br(papenmeier):r2",), "review_currentCharacter": ("br(papenmeier):l1",), @@ -510,10 +505,6 @@ def script_upperRouting(self, gesture): } }) - __gestures = { - "br(papenmeier):upperRouting": "upperRouting", - } - class InputGesture(braille.BrailleDisplayGesture, brailleInput.BrailleInputGesture): """Input gesture for papenmeier displays""" source = BrailleDisplayDriver.name diff --git a/source/brailleDisplayDrivers/papenmeier_serial.py b/source/brailleDisplayDrivers/papenmeier_serial.py index a8a258dc476..b396b03a75d 100644 --- a/source/brailleDisplayDrivers/papenmeier_serial.py +++ b/source/brailleDisplayDrivers/papenmeier_serial.py @@ -2,9 +2,9 @@ #A part of NonVisual Desktop Access (NVDA) #This file is covered by the GNU General Public License. #See the file COPYING for more details. -#Copyright (C) 2012-2013 Tobias Platen, Halim Sahin, Ali-Riza Ciftcioglu, NV Access Limited +#Copyright (C) 2012-2017 Tobias Platen, Halim Sahin, Ali-Riza Ciftcioglu, NV Access Limited, Davy Kager #Author: Tobias Platen (nvda@lists.thm.de) -#minor changes by Halim Sahin (nvda@lists.thm.de), Ali-Riza Ciftcioglu and James Teh +#minor changes by Halim Sahin (nvda@lists.thm.de), Ali-Riza Ciftcioglu , James Teh and Davy Kager #used braille port selection code from braillenote driver from collections import OrderedDict @@ -150,13 +150,6 @@ def __init__(self, port): self._keyCheckTimer = wx.PyTimer(self._handleKeyPresses) self._keyCheckTimer.Start(KEY_CHECK_INTERVAL) - def script_upperRouting(self, gesture): - globalCommands.commands.script_braille_routeTo(gesture) - wx.CallLater(50, scriptHandler.executeScript, globalCommands.commands.script_reportFormatting, gesture) - - # Translators: Describes action of routing buttons on a braille display. - script_upperRouting.__doc__ = _("Route to and report formatting") - def terminate(self): """free resources""" super(BrailleDisplayDriver, self).terminate() @@ -211,6 +204,7 @@ def _handleKeyPresses(self): #called by the keycheck timer "braille_previousLine": ("br(papenmeier_serial):up",), "braille_nextLine": ("br(papenmeier_serial):dn",), "braille_routeTo": ("br(papenmeier_serial):route",), + "braille_reportFormatting": ("br(papenmeier_serial):upperRouting",), "braille_toggleTether": ("br(papenmeier_serial):r2",), "review_currentCharacter": ("br(papenmeier_serial):l1",), @@ -227,10 +221,6 @@ def _handleKeyPresses(self): #called by the keycheck timer } }) - __gestures = { - "br(papenmeier_serial):upperRouting": "upperRouting", - } - def brl_keyname2(keys): """returns keyname for key index on displays with eab""" if(keys & 4 == 4): return 'l1' diff --git a/source/globalCommands.py b/source/globalCommands.py index 733e65cc055..758551ae614 100755 --- a/source/globalCommands.py +++ b/source/globalCommands.py @@ -3,7 +3,7 @@ #A part of NonVisual Desktop Access (NVDA) #This file is covered by the GNU General Public License. #See the file COPYING for more details. -#Copyright (C) 2006-2017 NV Access Limited, Peter Vágner, Aleksey Sadovoy, Rui Batista, Joseph Lee, Leonard de Ruijter, Derek Riemer, Babbage B.V., Ethan Holliger +#Copyright (C) 2006-2017 NV Access Limited, Peter Vágner, Aleksey Sadovoy, Rui Batista, Joseph Lee, Leonard de Ruijter, Derek Riemer, Babbage B.V., Davy Kager, Ethan Holliger import time import itertools @@ -1279,7 +1279,7 @@ def script_sayAll(self,gesture): script_sayAll.__doc__ = _("Reads from the system caret up to the end of the text, moving the caret as it goes") script_sayAll.category=SCRCAT_SYSTEMCARET - def script_reportFormatting(self,gesture): + def _reportFormattingHelper(self, info, browseable=False): formatConfig={ "detectFormatAfterCursor":False, "reportFontName":True,"reportFontSize":True,"reportFontAttributes":True,"reportColor":True,"reportRevisions":False,"reportEmphasis":False, @@ -1290,7 +1290,6 @@ def script_reportFormatting(self,gesture): "reportBorderStyle":True,"reportBorderColor":True, } textList=[] - info=api.getReviewPosition() # First, fetch indentation. line=info.copy() @@ -1299,14 +1298,14 @@ def script_reportFormatting(self,gesture): if indentation: textList.append(speech.getIndentationSpeech(indentation, formatConfig)) + info=info.copy() info.expand(textInfos.UNIT_CHARACTER) formatField=textInfos.FormatField() for field in info.getTextWithFields(formatConfig): if isinstance(field,textInfos.FieldCommand) and isinstance(field.field,textInfos.FormatField): formatField.update(field.field) - repeats=scriptHandler.getLastScriptRepeatCount() - if repeats==0: + if not browseable: text=info.getFormatFieldSpeech(formatField,formatConfig=formatConfig) if formatField else None if text: textList.append(text) @@ -1317,7 +1316,7 @@ def script_reportFormatting(self,gesture): return ui.message(" ".join(textList)) - elif repeats==1: + else: text=info.getFormatFieldSpeech(formatField,formatConfig=formatConfig , separator="\n") if formatField else None if text: textList.append(text) @@ -1328,7 +1327,15 @@ def script_reportFormatting(self,gesture): return # Translators: title for formatting information dialog. - ui.browseableMessage(("\n".join(textList) ) , _("Formatting")) + ui.browseableMessage("\n".join(textList), _("Formatting")) + + def script_reportFormatting(self,gesture): + info=api.getReviewPosition() + repeats=scriptHandler.getLastScriptRepeatCount() + if repeats==0: + self._reportFormattingHelper(info,False) + elif repeats==1: + self._reportFormattingHelper(info,True) # Translators: Input help mode message for report formatting command. script_reportFormatting.__doc__ = _("Reports formatting info for the current review cursor position within a document. If pressed twice, presents the information in browse mode") script_reportFormatting.category=SCRCAT_TEXTREVIEW @@ -1907,6 +1914,17 @@ def script_braille_routeTo(self, gesture): script_braille_routeTo.__doc__ = _("Routes the cursor to or activates the object under this braille cell") script_braille_routeTo.category=SCRCAT_BRAILLE + def script_braille_reportFormatting(self, gesture): + info = braille.handler.getTextInfoForWindowPos(gesture.routingIndex) + if info is None: + # Translators: Reported when trying to obtain formatting information (such as font name, indentation and so on) but there is no formatting information for the text under cursor. + ui.message(_("No formatting information")) + return + self._reportFormattingHelper(info, False) + # Translators: Input help mode message for Braille report formatting command. + script_braille_reportFormatting.__doc__ = _("Reports formatting info for the text under this braille cell") + script_braille_reportFormatting.category=SCRCAT_BRAILLE + def script_braille_previousLine(self, gesture): if braille.handler.buffer.regions: braille.handler.buffer.regions[-1].previousLine(start=True) diff --git a/source/ui.py b/source/ui.py index 12c697da63f..eab3dc45070 100644 --- a/source/ui.py +++ b/source/ui.py @@ -32,7 +32,7 @@ HTMLDLG_PRINT_TEMPLATE = 0x0080 HTMLDLG_VERIFY = 0x0100 -def browseableMessage(message,title=None , isHtml=False): +def browseableMessage(message,title=None,isHtml=False): """Present a message to the user that can be read in browse mode. The message will be presented in an HTML document. @param message: The message in either html or text. diff --git a/user_docs/en/userGuide.t2t b/user_docs/en/userGuide.t2t index b70597c7e85..2080f4f633a 100644 --- a/user_docs/en/userGuide.t2t +++ b/user_docs/en/userGuide.t2t @@ -1919,6 +1919,7 @@ Please see the display's documentation for descriptions of where these keys can | Move braille display to next line | t4 | | Scroll braille display forward | t5 or etouch3 | | Route to braille cell | routing | +| Report text formatting under braille cell | secondary routing | | Toggle HID keyboard simulation | t1+spEnter | | Move to top line in review | t1+t2 | | Move to bottom line in review | t4+t5 | @@ -2252,7 +2253,7 @@ Following are the Papenmeier command assignments for NVDA: | Move to first contained object | dn2 | | Move to previous object | left2 | | Move to next object | right2 | -| Report text formatting | upper routing row | +| Report text formatting under braille cell | upper routing row | %kc:endInclude The Trio model has four additional keys which are in front of the braille keyboard. @@ -2326,7 +2327,7 @@ Devices with EAB: | Move to first contained object | dn2 | | Move to next object | right2 | | Move to previous object | left2 | -| Report text formatting | Upper routing strip | +| Report text formatting under braille cell | upper routing strip | BRAILLEX Tiny: || Name | Key | @@ -2341,7 +2342,7 @@ BRAILLEX Tiny: | Move to first contained object | r1+dn | | Move to previous object | r1+left | | Move to next object | r1+right | -| Report text formatting | reportf | +| Report text formatting under braille cell | upper routing strip | | Report title | l1+up | | Report status bar | l2+down | @@ -2350,7 +2351,7 @@ BRAILLEX 2D Screen: | Report current character in review | l1 | | Activate current navigator object | l2 | | Toggle braille tethered to | r2 | -| Report text formatting | reportf | +| Report text formatting under braille cell | upper routing strip | | Move braille display to previous line | up | | Scroll braille display back | left | | Scroll braille display forward | right | @@ -2471,7 +2472,8 @@ Please see the display's documentation for descriptions of where these keys can | Scroll braille display back | switch1-6left, l1 | | Scroll braille display forward | switch1-6Right, l8 | | Move to current focus | switch1-6Left+switch1-6Right, l1+l8 | -| Route to braille cell | routing, doubleRouting| +| Route to braille cell | routing | +| Report text formatting under braille cell | doubleRouting | | Move to previous line in review | joystick1Up | | Move to next line in review | joystick1Down | | Move to previous character in review | joystick1Left |