From 257371672c034842b396070c24c2b66d329c9bc6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Golonka?= Date: Fri, 7 Dec 2018 14:00:38 +0100 Subject: [PATCH 1/6] Move the message 'selected' after the text which is selected. --- source/appModules/kindle.py | 2 +- source/globalCommands.py | 2 +- source/speech.py | 8 ++++---- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/source/appModules/kindle.py b/source/appModules/kindle.py index 5c3241663b1..a9e910f384c 100644 --- a/source/appModules/kindle.py +++ b/source/appModules/kindle.py @@ -138,7 +138,7 @@ def script_showSelectionOptions(self, gesture): # we can't just use self.makeTextInfo, as that will use our fake selection. realSel = self.rootNVDAObject.makeTextInfo(textInfos.POSITION_SELECTION) # Translators: Announces selected text. %s is replaced with the text. - speech.speakSelectionMessage(_("selected %s"), realSel.text) + speech.speakSelectionMessage(_("%s selected"), realSel.text) # Remove our virtual selection and move the caret to the active end. fakeSel.innerTextInfo = realSel fakeSel.collapse(end=not self._lastSelectionMovedStart) diff --git a/source/globalCommands.py b/source/globalCommands.py index a83ab2e27d8..2a193630771 100755 --- a/source/globalCommands.py +++ b/source/globalCommands.py @@ -205,7 +205,7 @@ def script_reportCurrentSelection(self,gesture): if not info or info.isCollapsed: speech.speakMessage(_("No selection")) else: - speech.speakMessage(_("Selected %s")%info.text) + speech.speakMessage(_("%s selected")%info.text) # Translators: Input help mode message for report current selection command. script_reportCurrentSelection.__doc__=_("Announces the current selection in edit controls and documents. If there is no selection it says so.") script_reportCurrentSelection.category=SCRCAT_SYSTEMCARET diff --git a/source/speech.py b/source/speech.py index 35d14d8a472..533e1b17166 100755 --- a/source/speech.py +++ b/source/speech.py @@ -406,8 +406,8 @@ def speakObject(obj,reason=controlTypes.REASON_QUERY,index=None): info=obj.makeTextInfo(textInfos.POSITION_SELECTION) if not info.isCollapsed: # if there is selected text, then there is a value and we do not report placeholder - # Translators: This is spoken to indicate what has been selected. for example 'selected hello world' - speakSelectionMessage(_("selected %s"),info.text) + # Translators: This is spoken to indicate what has been selected. for example 'hello world selected' + speakSelectionMessage(_("%s selected"),info.text) else: info.expand(textInfos.UNIT_LINE) _speakPlaceholderIfEmpty(info, obj, reason) @@ -633,8 +633,8 @@ def speakSelectionChange(oldInfo,newInfo,speakSelected=True,speakUnselected=True text=newInfo.text if len(text)==1: text=characterProcessing.processSpeechSymbol(locale,text) - # Translators: This is spoken to indicate what has been selected. for example 'selected hello world' - speakSelectionMessage(_("selected %s"),text) + # Translators: This is spoken to indicate what has been selected. for example 'hello world selected ' + speakSelectionMessage(_("%s selected "),text) if speakUnselected: if not generalize: for text in unselectedTextList: From 3a1a4792fb3f4e963f83f76ecde13d2a2ef8aaff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Golonka?= Date: Fri, 7 Dec 2018 14:44:55 +0100 Subject: [PATCH 2/6] Move selected to the end for all remaining messages, which fixes translation test. --- source/appModules/powerpnt.py | 2 +- source/browseMode.py | 2 +- source/compoundDocuments.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/source/appModules/powerpnt.py b/source/appModules/powerpnt.py index 9d169bc65ff..e2bc7ba1eca 100644 --- a/source/appModules/powerpnt.py +++ b/source/appModules/powerpnt.py @@ -1081,7 +1081,7 @@ def event_treeInterceptor_gainFocus(self): else: info = self.selection if not info.isCollapsed: - speech.speakSelectionMessage(_("selected %s"), info.text) + speech.speakSelectionMessage(_("%s selected"), info.text) else: info.expand(textInfos.UNIT_LINE) speech.speakTextInfo(info, reason=controlTypes.REASON_CARET, unit=textInfos.UNIT_LINE) diff --git a/source/browseMode.py b/source/browseMode.py index c2be2663cbd..77f1ea7f691 100644 --- a/source/browseMode.py +++ b/source/browseMode.py @@ -1177,7 +1177,7 @@ def event_treeInterceptor_gainFocus(self): speech.speakObject(self.rootNVDAObject, reason=controlTypes.REASON_FOCUS) info = self.selection if not info.isCollapsed: - speech.speakSelectionMessage(_("selected %s"), info.text) + speech.speakSelectionMessage(_("%s selected"), info.text) else: info.expand(textInfos.UNIT_LINE) speech.speakTextInfo(info, reason=controlTypes.REASON_CARET, unit=textInfos.UNIT_LINE) diff --git a/source/compoundDocuments.py b/source/compoundDocuments.py index 0f1106fa40f..b401f56753e 100644 --- a/source/compoundDocuments.py +++ b/source/compoundDocuments.py @@ -434,7 +434,7 @@ def event_treeInterceptor_gainFocus(self): info.expand(textInfos.UNIT_LINE) speech.speakTextInfo(info, unit=textInfos.UNIT_LINE, reason=controlTypes.REASON_CARET) else: - speech.speakSelectionMessage(_("selected %s"), info.text) + speech.speakSelectionMessage(_("%s selected"), info.text) braille.handler.handleGainFocus(self) self.initAutoSelectDetection() From 193547b6e67dfe7ea522d6f6f5d881deee192d5e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Golonka?= Date: Fri, 7 Dec 2018 16:15:45 +0100 Subject: [PATCH 3/6] Bump for Appveyor From 96049823196b9e3febe79c88038e42377313f76f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Golonka?= Date: Tue, 21 May 2019 18:40:28 +0200 Subject: [PATCH 4/6] Replace speakMessage with speakSelectionMessage in script for announcing selection. --- source/globalCommands.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/globalCommands.py b/source/globalCommands.py index 498cfbf008f..b66746a66e5 100755 --- a/source/globalCommands.py +++ b/source/globalCommands.py @@ -209,7 +209,7 @@ def script_reportCurrentSelection(self,gesture): if not info or info.isCollapsed: speech.speakMessage(_("No selection")) else: - speech.speakMessage(_("%s selected")%info.text) + speech.speakSelectionMessage(_("%s selected"),info.text) # Translators: Input help mode message for report current selection command. script_reportCurrentSelection.__doc__=_("Announces the current selection in edit controls and documents. If there is no selection it says so.") script_reportCurrentSelection.category=SCRCAT_SYSTEMCARET From f554b1ba29ecdb6c291bdfb278c30d8a88900ca5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Golonka?= Date: Thu, 30 May 2019 12:56:25 +0200 Subject: [PATCH 5/6] Implement new function speakSelectedText which is responsible for announcing selection. This will make future improvements to announcing selection easier. --- source/appModules/kindle.py | 3 +-- source/appModules/powerpnt.py | 2 +- source/browseMode.py | 2 +- source/compoundDocuments.py | 2 +- source/globalCommands.py | 2 +- source/speech.py | 13 +++++++------ 6 files changed, 12 insertions(+), 12 deletions(-) diff --git a/source/appModules/kindle.py b/source/appModules/kindle.py index a9e910f384c..6b9ef327634 100644 --- a/source/appModules/kindle.py +++ b/source/appModules/kindle.py @@ -137,8 +137,7 @@ def script_showSelectionOptions(self, gesture): # so retrieve and report the selection from Kindle. # we can't just use self.makeTextInfo, as that will use our fake selection. realSel = self.rootNVDAObject.makeTextInfo(textInfos.POSITION_SELECTION) - # Translators: Announces selected text. %s is replaced with the text. - speech.speakSelectionMessage(_("%s selected"), realSel.text) + speech.speakSelectedText(realSel.text) # Remove our virtual selection and move the caret to the active end. fakeSel.innerTextInfo = realSel fakeSel.collapse(end=not self._lastSelectionMovedStart) diff --git a/source/appModules/powerpnt.py b/source/appModules/powerpnt.py index e2bc7ba1eca..373148524af 100644 --- a/source/appModules/powerpnt.py +++ b/source/appModules/powerpnt.py @@ -1081,7 +1081,7 @@ def event_treeInterceptor_gainFocus(self): else: info = self.selection if not info.isCollapsed: - speech.speakSelectionMessage(_("%s selected"), info.text) + speech.speakSelectedText(info.text) else: info.expand(textInfos.UNIT_LINE) speech.speakTextInfo(info, reason=controlTypes.REASON_CARET, unit=textInfos.UNIT_LINE) diff --git a/source/browseMode.py b/source/browseMode.py index 7cb1f94a1ee..0d789d21482 100644 --- a/source/browseMode.py +++ b/source/browseMode.py @@ -1221,7 +1221,7 @@ def event_treeInterceptor_gainFocus(self): speech.speakObject(self.rootNVDAObject, reason=controlTypes.REASON_FOCUS) info = self.selection if not info.isCollapsed: - speech.speakSelectionMessage(_("%s selected"), info.text) + speech.speakSelectedText(info.text) else: info.expand(textInfos.UNIT_LINE) speech.speakTextInfo(info, reason=controlTypes.REASON_CARET, unit=textInfos.UNIT_LINE) diff --git a/source/compoundDocuments.py b/source/compoundDocuments.py index 2ad410e07cf..1bceece602b 100644 --- a/source/compoundDocuments.py +++ b/source/compoundDocuments.py @@ -446,7 +446,7 @@ def event_treeInterceptor_gainFocus(self): info.expand(textInfos.UNIT_LINE) speech.speakTextInfo(info, unit=textInfos.UNIT_LINE, reason=controlTypes.REASON_CARET) else: - speech.speakSelectionMessage(_("%s selected"), info.text) + speech.speakSelectedText(info.text) braille.handler.handleGainFocus(self) self.initAutoSelectDetection() diff --git a/source/globalCommands.py b/source/globalCommands.py index 2228b65bbd4..b17d8b9ff0c 100755 --- a/source/globalCommands.py +++ b/source/globalCommands.py @@ -210,7 +210,7 @@ def script_reportCurrentSelection(self,gesture): if not info or info.isCollapsed: speech.speakMessage(_("No selection")) else: - speech.speakSelectionMessage(_("%s selected"),info.text) + speech.speakSelectedText(info.text) # Translators: Input help mode message for report current selection command. script_reportCurrentSelection.__doc__=_("Announces the current selection in edit controls and documents. If there is no selection it says so.") script_reportCurrentSelection.category=SCRCAT_SYSTEMCARET diff --git a/source/speech.py b/source/speech.py index 6232cbddd7c..407d6b99082 100755 --- a/source/speech.py +++ b/source/speech.py @@ -421,8 +421,7 @@ def speakObject(obj,reason=controlTypes.REASON_QUERY,index=None): info=obj.makeTextInfo(textInfos.POSITION_SELECTION) if not info.isCollapsed: # if there is selected text, then there is a value and we do not report placeholder - # Translators: This is spoken to indicate what has been selected. for example 'hello world selected' - speakSelectionMessage(_("%s selected"),info.text) + speakSelectedText(info.text) else: info.expand(textInfos.UNIT_LINE) _speakPlaceholderIfEmpty(info, obj, reason) @@ -587,6 +586,10 @@ def speak(speechSequence,symbolLevel=None): speechSequence[index]+=CHUNK_SEPARATOR getSynth().speak(speechSequence) +def speakSelectedText(text): + # Translators: This is spoken to indicate what has been selected. for example 'hello world selected' + speakSelectionMessage(_("%s selected"),text) + def speakSelectionMessage(message,text): if len(text) < 512: speakMessage(message % text) @@ -644,14 +647,12 @@ def speakSelectionChange(oldInfo,newInfo,speakSelected=True,speakUnselected=True for text in selectedTextList: if len(text)==1: text=characterProcessing.processSpeechSymbol(locale,text) - # Translators: This is spoken while the user is in the process of selecting something, For example: "hello selected" - speakSelectionMessage(_("%s selected"),text) + speakSelectedText(text) elif len(selectedTextList)>0: text=newInfo.text if len(text)==1: text=characterProcessing.processSpeechSymbol(locale,text) - # Translators: This is spoken to indicate what has been selected. for example 'hello world selected ' - speakSelectionMessage(_("%s selected "),text) + speakSelectedText(text) if speakUnselected: if not generalize: for text in unselectedTextList: From cead9d598da8aecbeaed85a8701dc3ad1b864763 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Golonka?= Date: Sat, 1 Jun 2019 17:58:18 +0200 Subject: [PATCH 6/6] add doc string to speakSelectedText --- source/speech.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/source/speech.py b/source/speech.py index 407d6b99082..87a5312b2e2 100755 --- a/source/speech.py +++ b/source/speech.py @@ -587,6 +587,9 @@ def speak(speechSequence,symbolLevel=None): getSynth().speak(speechSequence) def speakSelectedText(text): + """ Helper method to speak the provided text with the word "selected" appended. + Implemented using L{speakSelectionMessage}, which allows for speaking text with an arbitrary attached message. + """ # Translators: This is spoken to indicate what has been selected. for example 'hello world selected' speakSelectionMessage(_("%s selected"),text)