4343from config .configFlags import (
4444 TetherTo ,
4545 ShowMessages ,
46+ BrailleMode ,
4647)
4748from config .featureFlag import FeatureFlag
4849from config .featureFlagEnums import BoolFlag
122123# (example: when there is no setting for language).
123124NO_SETTINGS_MSG = _ ("No settings" )
124125
126+
125127class GlobalCommands (ScriptableObject ):
126128 """Commands that are available at all times, regardless of the current focus.
127129 """
@@ -3371,6 +3373,7 @@ def script_toggleBrailleViewer(self, gesture: inputCore.InputGesture):
33713373 category = SCRCAT_BRAILLE ,
33723374 gesture = "kb:NVDA+control+t"
33733375 )
3376+ @gui .blockAction .when (gui .blockAction .Context .BRAILLE_MODE_SPEECH_OUTPUT )
33743377 def script_braille_toggleTether (self , gesture ):
33753378 values = [x .value for x in TetherTo ]
33763379 index = values .index (config .conf ["braille" ]["tetherTo" ])
@@ -3388,12 +3391,38 @@ def script_braille_toggleTether(self, gesture):
33883391 # (braille can be tethered automatically or to either focus or review position).
33893392 ui .message (_ ("Braille tethered %s" ) % TetherTo (newTetherChoice ).displayString )
33903393
3394+ @script (
3395+ # Translators: Input help mode message for toggle braille mode command
3396+ description = _ ("Toggles braille mode" ),
3397+ category = SCRCAT_BRAILLE ,
3398+ gesture = "kb:nvda+alt+t"
3399+ )
3400+ def script_toggleBrailleMode (self , gesture : inputCore .InputGesture ):
3401+ curMode = BrailleMode (config .conf ["braille" ]["mode" ])
3402+ modeList = list (BrailleMode )
3403+ index = modeList .index (curMode )
3404+ index = index + 1 if not index == len (modeList ) - 1 else 0
3405+ newMode = modeList [index ]
3406+ config .conf ["braille" ]["mode" ] = newMode .value
3407+ if braille .handler .buffer == braille .handler .messageBuffer :
3408+ braille .handler ._dismissMessage ()
3409+ braille .handler .mainBuffer .clear ()
3410+ # Translators: The message reported when switching braille modes
3411+ ui .message (_ ("Braille mode {brailleMode}" ).format (brailleMode = newMode .displayString ))
3412+ if newMode == BrailleMode .SPEECH_OUTPUT :
3413+ return
3414+ if braille .handler .getTether () == TetherTo .REVIEW .value :
3415+ braille .handler .handleReviewMove (shouldAutoTether = braille .handler .shouldAutoTether )
3416+ return
3417+ braille .handler .handleGainFocus (api .getFocusObject ())
3418+
33913419 @script (
33923420 # Translators: Input help mode message for cycle through
33933421 # braille move system caret when routing review cursor command.
33943422 description = _ ("Cycle through the braille move system caret when routing review cursor states" ),
33953423 category = SCRCAT_BRAILLE
33963424 )
3425+ @gui .blockAction .when (gui .blockAction .Context .BRAILLE_MODE_SPEECH_OUTPUT )
33973426 def script_braille_cycleReviewRoutingMovesSystemCaret (self , gesture : inputCore .InputGesture ) -> None :
33983427 # If braille is not tethered to focus, set next state of
33993428 # braille Move system caret when routing review cursor.
@@ -3429,6 +3458,7 @@ def script_braille_cycleReviewRoutingMovesSystemCaret(self, gesture: inputCore.I
34293458 description = _ ("Toggle the way context information is presented in braille" ),
34303459 category = SCRCAT_BRAILLE
34313460 )
3461+ @gui .blockAction .when (gui .blockAction .Context .BRAILLE_MODE_SPEECH_OUTPUT )
34323462 def script_braille_toggleFocusContextPresentation (self , gesture ):
34333463 values = [x [0 ] for x in braille .focusContextPresentations ]
34343464 labels = [x [1 ] for x in braille .focusContextPresentations ]
@@ -3450,6 +3480,7 @@ def script_braille_toggleFocusContextPresentation(self, gesture):
34503480 description = _ ("Toggle the braille cursor on and off" ),
34513481 category = SCRCAT_BRAILLE
34523482 )
3483+ @gui .blockAction .when (gui .blockAction .Context .BRAILLE_MODE_SPEECH_OUTPUT )
34533484 def script_braille_toggleShowCursor (self , gesture ):
34543485 if config .conf ["braille" ]["showCursor" ]:
34553486 # Translators: The message announced when toggling the braille cursor.
@@ -3468,6 +3499,7 @@ def script_braille_toggleShowCursor(self, gesture):
34683499 description = _ ("Cycle through the braille cursor shapes" ),
34693500 category = SCRCAT_BRAILLE
34703501 )
3502+ @gui .blockAction .when (gui .blockAction .Context .BRAILLE_MODE_SPEECH_OUTPUT )
34713503 def script_braille_cycleCursorShape (self , gesture ):
34723504 if not config .conf ["braille" ]["showCursor" ]:
34733505 # Translators: A message reported when changing the braille cursor shape when the braille cursor is turned off.
@@ -3494,6 +3526,7 @@ def script_braille_cycleCursorShape(self, gesture):
34943526 description = _ ("Cycle through the braille show messages modes" ),
34953527 category = SCRCAT_BRAILLE
34963528 )
3529+ @gui .blockAction .when (gui .blockAction .Context .BRAILLE_MODE_SPEECH_OUTPUT )
34973530 def script_braille_cycleShowMessages (self , gesture : inputCore .InputGesture ) -> None :
34983531 """Set next state of braille show messages and reports it with ui.message."""
34993532 values = [x .value for x in ShowMessages ]
@@ -3511,6 +3544,7 @@ def script_braille_cycleShowMessages(self, gesture: inputCore.InputGesture) -> N
35113544 description = _ ("Cycle through the braille show selection states" ),
35123545 category = SCRCAT_BRAILLE
35133546 )
3547+ @gui .blockAction .when (gui .blockAction .Context .BRAILLE_MODE_SPEECH_OUTPUT )
35143548 def script_braille_cycleShowSelection (self , gesture : inputCore .InputGesture ) -> None :
35153549 """Set next state of braille show selection and reports it with ui.message."""
35163550 featureFlag : FeatureFlag = config .conf ["braille" ]["showSelection" ]
0 commit comments