Skip to content

Commit 2508c05

Browse files
authored
Merge 7f5daab into 87d5b5a
2 parents 87d5b5a + 7f5daab commit 2508c05

4 files changed

Lines changed: 38 additions & 14 deletions

File tree

source/globalCommands.py

Lines changed: 29 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,8 @@ def script_toggleRightMouseButton(self,gesture):
255255
description=_(
256256
# Translators: Input help mode message for report current selection command.
257257
"Announces the current selection in edit controls and documents. "
258-
"If there is no selection it says so."
258+
"Pressing twice spells this information. "
259+
"Pressing three times spells it using character descriptions."
259260
),
260261
category=SCRCAT_SYSTEMCARET,
261262
gestures=("kb(desktop):NVDA+shift+upArrow", "kb(laptop):NVDA+shift+s")
@@ -272,7 +273,13 @@ def script_reportCurrentSelection(self,gesture):
272273
if not info or info.isCollapsed:
273274
speech.speakMessage(_("No selection"))
274275
else:
275-
speech.speakTextSelected(info.text)
276+
scriptCount = scriptHandler.getLastScriptRepeatCount()
277+
if scriptCount == 0:
278+
speech.speakTextSelected(info.text)
279+
elif len(info.text) < speech.speech.MAX_LENGTH_FOR_SELECTION_REPORTING:
280+
speech.speakSpelling(info.text, useCharacterDescriptions=scriptCount > 1)
281+
else:
282+
speech.speakTextSelected(info.text)
276283

277284
@script(
278285
# Translators: Input help mode message for report date and time command.
@@ -2431,8 +2438,12 @@ def script_reportDetailsSummary(self, gesture: inputCore.InputGesture):
24312438
return
24322439

24332440
@script(
2434-
# Translators: Input help mode message for report current focus command.
2435-
description=_("Reports the object with focus. If pressed twice, spells the information"),
2441+
description=_(
2442+
# Translators: Input help mode message for report current focus command.
2443+
"Reports the object with focus. "
2444+
"If pressed twice, spells the information. "
2445+
"Pressing three times spells it using character descriptions."
2446+
),
24362447
category=SCRCAT_FOCUS,
24372448
gesture="kb:NVDA+tab"
24382449
)
@@ -2452,10 +2463,11 @@ def script_reportCurrentFocus(self, gesture: inputCore.InputGesture):
24522463
ui.message(gui.blockAction.Context.WINDOWS_LOCKED.translatedMessage)
24532464
return
24542465

2455-
if scriptHandler.getLastScriptRepeatCount() == 0:
2466+
repeatCount = scriptHandler.getLastScriptRepeatCount()
2467+
if repeatCount == 0:
24562468
speech.speakObject(focusObject, reason=controlTypes.OutputReason.QUERY)
24572469
else:
2458-
speech.speakSpelling(focusObject.name)
2470+
speech.speakSpelling(focusObject.name, useCharacterDescriptions=repeatCount > 1)
24592471

24602472
@staticmethod
24612473
def _getStatusBarText(setReviewCursor: bool = False) -> Optional[str]:
@@ -3384,8 +3396,12 @@ def script_braille_cycleShowSelection(self, gesture: inputCore.InputGesture) ->
33843396
ui.message(msg)
33853397

33863398
@script(
3387-
# Translators: Input help mode message for report clipboard text command.
3388-
description=_("Reports the text on the Windows clipboard"),
3399+
description=_(
3400+
# Translators: Input help mode message for report clipboard text command.
3401+
"Reports the text on the Windows clipboard. "
3402+
"Pressing twice spells this information. "
3403+
"Pressing three times spells it using character descriptions."
3404+
),
33893405
category=SCRCAT_SYSTEM,
33903406
gesture="kb:NVDA+c"
33913407
)
@@ -3399,7 +3415,11 @@ def script_reportClipboardText(self,gesture):
33993415
ui.message(_("There is no text on the clipboard"))
34003416
return
34013417
if len(text) < 1024:
3402-
ui.message(text)
3418+
repeatCount = scriptHandler.getLastScriptRepeatCount()
3419+
if repeatCount == 0:
3420+
ui.message(text)
3421+
else:
3422+
speech.speakSpelling(text, useCharacterDescriptions=repeatCount > 1)
34033423
else:
34043424
# Translators: If the number of characters on the clipboard is greater than about 1000, it reports this message and gives number of characters on the clipboard.
34053425
# Example output: The clipboard contains a large portion of text. It is 2300 characters long.

source/speech/speech.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1016,17 +1016,21 @@ def speakSelectionMessage(
10161016
speak(seq, symbolLevel=None, priority=priority)
10171017

10181018

1019+
MAX_LENGTH_FOR_SELECTION_REPORTING = 512
1020+
1021+
10191022
def _getSelectionMessageSpeech(
10201023
message: str,
10211024
text: str,
10221025
) -> SpeechSequence:
1023-
if len(text) < 512:
1026+
if len(text) < MAX_LENGTH_FOR_SELECTION_REPORTING:
10241027
return _getSpeakMessageSpeech(message % text)
10251028
# Translators: This is spoken when the user has selected a large portion of text.
10261029
# Example output "1000 characters"
10271030
numCharactersText = _("%d characters") % len(text)
10281031
return _getSpeakMessageSpeech(message % numCharactersText)
10291032

1033+
10301034
# C901 'speakSelectionChange' is too complex
10311035
# Note: when working on speakSelectionChange, look for opportunities to simplify
10321036
# and move logic out into smaller helper functions.

user_docs/en/changes.t2t

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ What's New in NVDA
1212

1313

1414
== Changes ==
15-
15+
- The following commands will now support two and three presses to spell the reported information: report selection, report clipboard text and report focused object. (#15449)
1616

1717
== Bug Fixes ==
1818
- Reporting of object shortcut keys has been improved. (#10807)

user_docs/en/userGuide.t2t

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -213,13 +213,13 @@ The actual commands will not execute while in input help mode.
213213
|| Name | Desktop key | Laptop key | Description |
214214
| Say all | ``NVDA+downArrow`` | ``NVDA+a`` | Starts reading from the current position, moving it along as it goes |
215215
| Read current line | ``NVDA+upArrow`` | ``NVDA+l`` | Reads the line. Pressing twice spells the line. Pressing three times spells the line using character descriptions (Alpha, Bravo, Charlie, etc) |
216-
| Read selection | ``NVDA+shift+upArrow`` | ``NVDA+shift+s`` | Reads any selected text |
217-
| Read clipboard text | ``NVDA+c`` | ``NVDA+c`` | Reads any text on the clipboard |
216+
| Read selection | ``NVDA+shift+upArrow`` | ``NVDA+shift+s`` | Reads any selected text. Pressing twice will spell the information. Pressing three times will spell it using character description |
217+
| Read clipboard text | ``NVDA+c`` | ``NVDA+c`` | Reads any text on the clipboard. Pressing twice will spell the information. Pressing three times will spell it using character description |
218218

219219
+++ Reporting location and other information +++[ReportingLocation]
220220
|| Name | Desktop key | Laptop key | Description |
221221
| Window title | ``NVDA+t`` | ``NVDA+t`` | Reports the title of the currently active window. Pressing twice will spell the information. Pressing three times will copy it to the clipboard |
222-
| Report focus | ``NVDA+tab`` | ``NVDA+tab`` | Reports the current control which has focus. Pressing twice will spell the information |
222+
| Report focus | ``NVDA+tab`` | ``NVDA+tab`` | Reports the current control which has focus. Pressing twice will spell the information. Pressing three times will spell it using character description |
223223
| Read window | ``NVDA+b`` | ``NVDA+b`` | Reads the entire current window (useful for dialogs) |
224224
| Read status bar | ``NVDA+end`` | ``NVDA+shift+end`` | Reports the Status Bar if NVDA finds one. Pressing twice will spell the information. Pressing three times will copy it to the clipboard |
225225
| Read time | ``NVDA+f12`` | ``NVDA+f12`` | Pressing once reports the current time, pressing twice reports the date. The time and date are reported in the format specified in Windows settings for the system tray clock. |

0 commit comments

Comments
 (0)