Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ability to speak character when cursor routing #4

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions source/braille.py
Original file line number Diff line number Diff line change
Expand Up @@ -1640,6 +1640,7 @@ def _routeToTextInfo(self, info: textInfos.TextInfo):
pass
return
self._setCursor(info)
_speakOnRouting(info.copy())

def nextLine(self):
dest = self._readingInfo.copy()
Expand Down Expand Up @@ -3679,3 +3680,17 @@ def getDisplayDrivers(
continue
if not filterFunc or filterFunc(display):
yield display


def _speakOnRouting(info: textInfos.TextInfo):
"""Speaks the character at the cursor position after routing.

:param info: The TextInfo at the cursor position after routing.
"""
if not config.conf["braille"]["speakOnRouting"]:
return
# Import late to avoid circular import.
from speech.speech import spellTextInfo

info.expand(textInfos.UNIT_CHARACTER)
spellTextInfo(info)
1 change: 1 addition & 0 deletions source/config/configSpec.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@
unicodeNormalization = featureFlag(optionsEnum="BoolFlag", behaviorOfDefault="disabled")
focusContextPresentation = option("changedContext", "fill", "scroll", default="changedContext")
interruptSpeechWhileScrolling = featureFlag(optionsEnum="BoolFlag", behaviorOfDefault="enabled")
speakOnRouting = boolean(default=false)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

category Functionality

The addition of the 'speakOnRouting' option is a good start for implementing the new feature. However, to ensure full functionality, make sure to implement the corresponding logic in the braille cursor routing code to check this option and speak the character when it's enabled. Also, consider adding documentation for this new option in the user guide.

Chat with Korbit by mentioning @development-korbit-ai-mentor, and give a 👍 or 👎 to help Korbit improve your reviews.

showSelection = featureFlag(optionsEnum="BoolFlag", behaviorOfDefault="enabled")
reportLiveRegions = featureFlag(optionsEnum="BoolFlag", behaviorOfDefault="enabled")
fontFormattingDisplay = featureFlag(optionsEnum="FontFormattingBrailleModeFlag", behaviorOfDefault="LIBLOUIS")
Expand Down
16 changes: 16 additions & 0 deletions source/globalCommands.py
Original file line number Diff line number Diff line change
Expand Up @@ -3593,6 +3593,22 @@ def script_braille_toggleShowCursor(self, gesture):
braille.handler._updateDisplay()
ui.message(state)

@script(
# Translators: Input help mode message for speak on routing command.
description=_("Toggles speaking the character under the cursor when routing cursor in text"),
category=SCRCAT_BRAILLE,
)
@gui.blockAction.when(gui.blockAction.Context.BRAILLE_MODE_SPEECH_OUTPUT)
def script_braille_toggleSpeakOnRouting(self, gesture):
state = config.conf["braille"]["speakOnRouting"] = not config.conf["braille"]["speakOnRouting"]
if state:
# Translators: The message announced when toggling on speaking character when routing.
state = _("Speak character when routing cursor in text on")
else:
# Translators: The message announced when toggling off speaking character when routing.
state = _("Speak character when routing cursor in text off")
ui.message(state)

@script(
# Translators: Input help mode message for cycle braille cursor shape command.
description=_("Cycle through the braille cursor shapes"),
Expand Down
9 changes: 9 additions & 0 deletions source/gui/settingsDialogs.py
Original file line number Diff line number Diff line change
Expand Up @@ -4447,6 +4447,14 @@ def makeSettings(self, settingsSizer):
)
self.bindHelpEvent("BrailleFormattingDisplay", self.formattingDisplayCombo)

# Translators: The label for a setting in braille settings to speak the character under the cursor when cursor routing in text.
speakOnRoutingText = _("Spea&k character when routing cursor in text")
self.speakOnRoutingCheckBox = followCursorGroupHelper.addItem(
wx.CheckBox(self, label=speakOnRoutingText),
)
self.bindHelpEvent("BrailleSettingsSpeakOnRouting", self.speakOnRoutingCheckBox)
self.speakOnRoutingCheckBox.Value = config.conf["braille"]["speakOnRouting"]

self.followCursorGroupBox.Enable(
list(braille.BrailleMode)[self.brailleModes.GetSelection()] is braille.BrailleMode.FOLLOW_CURSORS,
)
Expand Down Expand Up @@ -4514,6 +4522,7 @@ def onSave(self):
config.conf["braille"]["paragraphStartMarker"] = [marker.value for marker in ParagraphStartMarker][
self.paragraphStartMarkersComboBox.GetSelection()
]
config.conf["braille"]["speakOnRouting"] = self.speakOnRoutingCheckBox.Value
config.conf["braille"]["wordWrap"] = self.wordWrapCheckBox.Value
self.unicodeNormalizationCombo.saveCurrentValueToConf()
config.conf["braille"]["focusContextPresentation"] = self.focusContextPresentationValues[
Expand Down
2 changes: 2 additions & 0 deletions user_docs/en/changes.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ The available options are:
* Tags: Uses start and end tags to denote where certain font attributes begin and end. (#16864)
* When the "Read by paragraph" option is enabled, NVDA can now be configured to indicate the start of paragraphs in braille. (#16895, @nvdaes)
* The timeout to perform a multiple keypress is now configurable; this may be especially useful for people with dexterity impairment. (#11929, @CyrilleB79)
* When performing a braille cursor routing action, NVDA can now automatically speak the character ath the cursor. (#8072, @LeonarddeR)
* This option is disabled by default. You can enable "Speak character when routing cursor in text" in NVDA's braille settings.

### Changes

Expand Down
6 changes: 6 additions & 0 deletions user_docs/en/userGuide.md
Original file line number Diff line number Diff line change
Expand Up @@ -2250,6 +2250,12 @@ The following symbols are defined:
| ⠎ ("s")| Start strikethrough |
| ⡎ ("s" with dot 7) | End strikethrough |

##### Speak character when routing cursor in text {#BrailleSettingsSpeakOnRouting}

If this is enabled, NVDA will automatically speak the character at the cursor when routing to it with braille cursor routing keys.

To toggle this option from anywhere, please assign a custom gesture using the [Input Gestures dialog](#InputGestures).

##### Avoid splitting words when possible {#BrailleSettingsWordWrap}

If this is enabled, a word which is too large to fit at the end of the braille display will not be split.
Expand Down