Skip to content

Commit 38283b3

Browse files
authored
Merge 13d7841 into 9894c9d
2 parents 9894c9d + 13d7841 commit 38283b3

14 files changed

Lines changed: 198 additions & 92 deletions

File tree

projectDocs/dev/developerGuide/developerGuide.t2t

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -532,6 +532,8 @@ The following keyword arguments can be used when applying the script decorator:
532532
- resumeSayAllMode: The say all mode that should be resumed when active before executing this script.
533533
The constants for say all mode can be found in the CURSOR enum in speech.sayAll.
534534
If resumeSayAllMode is not specified, say all does not resume after this script.
535+
- speakOnDemand: A boolean indicating whether this script should produce speech when called while speech mode is "on-demand".
536+
This option defaults to False.
535537
-
536538

537539
Though the script decorator makes the script definition process a lot easier, there are more ways of binding gestures and setting script properties.

source/NVDAObjects/IAccessible/winword.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -297,6 +297,12 @@ def script_caret_moveByCell(self, gesture: inputCore.InputGesture) -> None:
297297
speech.speakTextInfo(info, reason=controlTypes.OutputReason.FOCUS)
298298
braille.handler.handleCaretMove(self)
299299

300+
@script(
301+
# Translators: a description for a script
302+
description=_("Reports the text of the comment where the system caret is located."),
303+
gesture="kb:NVDA+alt+c",
304+
speakOnDemand=True,
305+
)
300306
def script_reportCurrentComment(self,gesture):
301307
info=self.makeTextInfo(textInfos.POSITION_CARET)
302308
info.expand(textInfos.UNIT_CHARACTER)
@@ -316,8 +322,6 @@ def script_reportCurrentComment(self,gesture):
316322
return
317323
# Translators: a message when there is no comment to report in Microsoft Word
318324
ui.message(_("No comments"))
319-
# Translators: a description for a script
320-
script_reportCurrentComment.__doc__=_("Reports the text of the comment where the System caret is located.")
321325

322326
def _moveInTable(self,row=True,forward=True):
323327
info=self.makeTextInfo(textInfos.POSITION_CARET)
@@ -445,7 +449,6 @@ def focusOnActiveDocument(self, officeChartObject):
445449
"kb:alt+end":"caret_moveByCell",
446450
"kb:alt+pageUp":"caret_moveByCell",
447451
"kb:alt+pageDown":"caret_moveByCell",
448-
"kb:NVDA+alt+c":"reportCurrentComment",
449452
}
450453

451454

source/NVDAObjects/UIA/wordDocument.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -600,7 +600,8 @@ def _caretMoveBySentenceHelper(self, gesture, direction):
600600
@script(
601601
gesture="kb:NVDA+alt+c",
602602
# Translators: a description for a script that reports the comment at the caret.
603-
description=_("Reports the text of the comment where the System caret is located.")
603+
description=_("Reports the text of the comment where the system caret is located."),
604+
speakOnDemand=True,
604605
)
605606
def script_reportCurrentComment(self,gesture):
606607
caretInfo=self.makeTextInfo(textInfos.POSITION_CARET)

source/NVDAObjects/window/excel.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1671,7 +1671,9 @@ def _get_positionInfo(self):
16711671
@script(
16721672
# Translators: the description for a script for Excel
16731673
description=_("Reports the note on the current cell"),
1674-
gesture="kb:NVDA+alt+c")
1674+
gesture="kb:NVDA+alt+c",
1675+
speakOnDemand=True,
1676+
)
16751677
def script_reportComment(self,gesture):
16761678
commentObj=self.excelCellObject.comment
16771679
text=commentObj.text() if commentObj else None

source/appModules/foobar2000.py

Lines changed: 23 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# A part of NonVisual Desktop Access (NVDA)
22
# Copyright (C) 2009-2023 NV Access Limited, Aleksey Sadovoy, James Teh, Joseph Lee, Tuukka Ojala,
3-
# Bram Duvigneau
3+
# Bram Duvigneau, Cyrille Bougot
44
# This file is covered by the GNU General Public License.
55
# See the file COPYING for more details.
66

@@ -19,6 +19,7 @@
1919
from logHandler import log
2020
import ui
2121
from utils.localisation import TimeOutputFormat
22+
from scriptHandler import script
2223

2324
if TYPE_CHECKING:
2425
from inputCore import InputGesture # noqa: F401
@@ -146,6 +147,13 @@ def getElapsedAndTotalIfPlaying(self) -> _StatusBarTimes:
146147
ui.message(_("No track playing"))
147148
return elapsedAndTotalTime
148149

150+
@script(
151+
# Translators: The description of an NVDA command for reading the remaining time of the currently playing
152+
# track in Foobar 2000.
153+
description=_("Reports the remaining time of the currently playing track, if any"),
154+
gesture="kb:control+shift+r",
155+
speakOnDemand=True,
156+
)
149157
def script_reportRemainingTime(self, gesture: "InputGesture"):
150158
elapsedTime, totalTime = self.getElapsedAndTotalIfPlaying()
151159
parsedElapsedTime = None
@@ -163,9 +171,13 @@ def script_reportRemainingTime(self, gesture: "InputGesture"):
163171
# Translators: Reported if the remaining time can not be calculated in Foobar2000
164172
ui.message(_("Remaining time not available"))
165173

166-
# Translators: The description of an NVDA command for reading the remaining time of the currently playing track in Foobar 2000.
167-
script_reportRemainingTime.__doc__ = _("Reports the remaining time of the currently playing track, if any")
168-
174+
@script(
175+
# Translators: The description of an NVDA command for reading the elapsed time of the currently playing
176+
# track in Foobar 2000.
177+
description=_("Reports the elapsed time of the currently playing track, if any"),
178+
gesture="kb:control+shift+e",
179+
speakOnDemand=True,
180+
)
169181
def script_reportElapsedTime(self, gesture: "InputGesture"):
170182
elapsedTime = self.getElapsedAndTotalIfPlaying().elapsed
171183
if elapsedTime:
@@ -177,9 +189,13 @@ def script_reportElapsedTime(self, gesture: "InputGesture"):
177189
# Translators: Reported if the elapsed time is not available in Foobar2000
178190
ui.message(_("Elapsed time not available"))
179191

180-
# Translators: The description of an NVDA command for reading the elapsed time of the currently playing track in Foobar 2000.
181-
script_reportElapsedTime.__doc__ = _("Reports the elapsed time of the currently playing track, if any")
182-
192+
@script(
193+
# Translators: The description of an NVDA command for reading the length of the currently playing track in
194+
# Foobar 2000.
195+
description=_("Reports the length of the currently playing track, if any"),
196+
gesture="kb:control+shift+t",
197+
speakOnDemand=True,
198+
)
183199
def script_reportTotalTime(self, gesture: "InputGesture"):
184200
totalTime = self.getElapsedAndTotalIfPlaying().total
185201
if totalTime:
@@ -190,12 +206,3 @@ def script_reportTotalTime(self, gesture: "InputGesture"):
190206
else:
191207
# Translators: Reported if the total time is not available in Foobar2000
192208
ui.message(_("Total time not available"))
193-
194-
# Translators: The description of an NVDA command for reading the length of the currently playing track in Foobar 2000.
195-
script_reportTotalTime.__doc__ = _("Reports the length of the currently playing track, if any")
196-
197-
__gestures = {
198-
"kb:control+shift+r": "reportRemainingTime",
199-
"kb:control+shift+e": "reportElapsedTime",
200-
"kb:control+shift+t": "reportTotalTime",
201-
}

source/appModules/miranda32.py

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
1-
# -*- coding: UTF-8 -*-
2-
#appModules/miranda32.py
3-
#A part of NonVisual Desktop Access (NVDA)
4-
#Copyright (C) 2006-2019 NV Access Limited, Aleksey Sadovoy, Peter Vágner, Joseph Lee, Bill Dengler
5-
#This file is covered by the GNU General Public License.
6-
#See the file COPYING for more details.
1+
# A part of NonVisual Desktop Access (NVDA)
2+
# Copyright (C) 2006-2023 NV Access Limited, Aleksey Sadovoy, Peter Vágner, Joseph Lee, Bill Dengler,
3+
# Cyrille Bougot
4+
# This file is covered by the GNU General Public License.
5+
# See the file COPYING for more details.
76

87
import ui
98
import config
@@ -16,7 +15,7 @@
1615
import speech
1716
import braille
1817
import controlTypes
19-
from scriptHandler import isScriptWaiting
18+
from scriptHandler import isScriptWaiting, script
2019
import api
2120
import mouseHandler
2221
import oleacc
@@ -110,20 +109,19 @@ def event_NVDAObject_init(self,obj):
110109
elif (obj.windowControlID in ANSILOGS) and (obj.windowClassName=="RichEdit20A"):
111110
obj._isWindowUnicode=False
112111

112+
@script(
113+
# Translators: The description of an NVDA command to view one of the recent messages.
114+
description=_("Displays one of the recent messages"),
115+
gestures=[f"kb:NVDA+control+{n}" for n in range(1, MessageHistoryLength + 1)],
116+
speakOnDemand=True,
117+
)
113118
def script_readMessage(self,gesture):
114119
num=int(gesture.mainKeyName[-1])
115120
if len(self.lastMessages)>num-1:
116121
ui.message(self.lastMessages[num-1])
117122
else:
118123
# Translators: This is presented to inform the user that no instant message has been received.
119124
ui.message(_("No message yet"))
120-
# Translators: The description of an NVDA command to view one of the recent messages.
121-
script_readMessage.__doc__=_("Displays one of the recent messages")
122-
123-
def __init__(self, *args, **kwargs):
124-
super(AppModule, self).__init__(*args, **kwargs)
125-
for n in range(1, self.MessageHistoryLength + 1):
126-
self.bindGesture("kb:NVDA+control+%s" % n, "readMessage")
127125

128126
class mirandaIMContactList(IAccessible):
129127

source/appModules/poedit.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# A part of NonVisual Desktop Access (NVDA)
22
# This file is covered by the GNU General Public License.
33
# See the file COPYING for more details.
4-
# Copyright (C) 2012-2023 Mesar Hameed, NV Access Limited, Leonard de Ruijter, Rui Fontes
4+
# Copyright (C) 2012-2023 Mesar Hameed, NV Access Limited, Leonard de Ruijter, Rui Fontes, Cyrille Bougot
55

66
"""App module for Poedit 3.4+.
77
"""
@@ -146,6 +146,7 @@ def _reportControlScriptHelper(self, obj: Window, description: str):
146146
"Reports any notes for translators. If pressed twice, presents the notes in browse mode",
147147
),
148148
gesture="kb:control+shift+a",
149+
speakOnDemand=True,
149150
)
150151
def script_reportAutoCommentsWindow(self, gesture):
151152
self._reportControlScriptHelper(
@@ -171,6 +172,7 @@ def _get__commentObj(self) -> Window | None:
171172
"If pressed twice, presents the comment in browse mode",
172173
),
173174
gesture="kb:control+shift+c",
175+
speakOnDemand=True,
174176
)
175177
def script_reportCommentsWindow(self, gesture):
176178
self._reportControlScriptHelper(
@@ -195,6 +197,7 @@ def _get__oldSourceTextObj(self) -> Window | None:
195197
"Reports the old source text, if any. If pressed twice, presents the text in browse mode",
196198
),
197199
gesture="kb:control+shift+o",
200+
speakOnDemand=True,
198201
)
199202
def script_reportOldSourceText(self, gesture):
200203
self._reportControlScriptHelper(
@@ -217,6 +220,7 @@ def _get__translationWarningObj(self) -> Window | None:
217220
"Reports a translation warning, if any. If pressed twice, presents the warning in browse mode",
218221
),
219222
gesture="kb:control+shift+w",
223+
speakOnDemand=True,
220224
)
221225
def script_reportTranslationWarning(self, gesture):
222226
self._reportControlScriptHelper(

source/appModules/vipmud.py

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
#appModules/vipmud.py
2-
#A part of NonVisual Desktop Access (NVDA)
3-
#Copyright (C) 2011 Willem Venter and Rynhardt Kruger
4-
#This file is covered by the GNU General Public License.
5-
#See the file COPYING for more details.
1+
# A part of NonVisual Desktop Access (NVDA)
2+
# Copyright (C) 2011-2023 Willem Venter and Rynhardt Kruger, Cyrille Bougot
3+
# This file is covered by the GNU General Public License.
4+
# See the file COPYING for more details.
65

76
from NVDAObjects.window import edit
87
import ui
98
import appModuleHandler
109
import controlTypes
10+
from scriptHandler import script
1111

1212
"""
1313
App module for VIP Mud
@@ -21,17 +21,19 @@ class AppModule(appModuleHandler.AppModule):
2121
def chooseNVDAObjectOverlayClasses(self, obj, clsList):
2222
if controlTypes.State.READONLY in obj.states:
2323
clsList.insert(0, MudText)
24-
def __init__(self, *args, **kwargs):
25-
super(AppModule, self).__init__(*args, **kwargs)
26-
for n in range(1, self.historyLength +1):
27-
self.bindGesture("kb:control+%s" % n, "readMessage")
24+
25+
@script(
26+
# Translators: The description of an NVDA command to view one of the recent messages.
27+
description=_("Displays one of the recent messages"),
28+
gestures=[f"kb:control+{n}" for n in range(1, historyLength + 1)],
29+
speakOnDemand=True,
30+
)
2831
def script_readMessage(self,gesture):
2932
num=int(gesture.mainKeyName[-1])
3033
try:
3134
ui.message(self.msgs[num-1])
3235
except IndexError:
3336
ui.message(_("No message yet"))
34-
script_readMessage.__doc__=_("Displays one of the recent messages")
3537

3638

3739
class MudText(edit.Edit):

source/documentBase.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -512,13 +512,16 @@ def script_sayAllRow(self, gesture):
512512
# Translators: the description for the sayAll row command
513513
"Reads the row horizontally from the current cell rightwards to the last cell in the row."
514514
)
515+
script_sayAllRow.speakOnDemand = True
516+
515517

516518
def script_sayAllColumn(self, gesture):
517519
self._tableSayAll(_Movement.NEXT, _Axis.ROW)
518520
script_sayAllColumn.__doc__ = _(
519521
# Translators: the description for the sayAll row command
520522
"Reads the column vertically from the current cell downwards to the last cell in the column."
521523
)
524+
script_sayAllColumn.speakOnDemand = True
522525

523526
def script_speakRow(self, gesture):
524527
self._tableSayAll(_Movement.FIRST, _Axis.COLUMN, updateCaret=False)
@@ -527,6 +530,7 @@ def script_speakRow(self, gesture):
527530
"Reads the current row horizontally from left to right "
528531
"without moving the system caret."
529532
)
533+
script_speakRow.speakOnDemand = True
530534

531535
def script_speakColumn(self, gesture):
532536
self._tableSayAll(_Movement.FIRST, _Axis.ROW, updateCaret=False)
@@ -535,6 +539,7 @@ def script_speakColumn(self, gesture):
535539
"Reads the current column vertically from top to bottom "
536540
"without moving the system caret."
537541
)
542+
script_speakColumn.speakOnDemand = True
538543

539544
def script_toggleIncludeLayoutTables(self,gesture):
540545
# documentBase is a core module and should not depend on UI, so it is imported at run-time. (#12404)

0 commit comments

Comments
 (0)