Skip to content

Commit

Permalink
Pre-commit auto-fix
Browse files Browse the repository at this point in the history
  • Loading branch information
pre-commit-ci[bot] committed Dec 11, 2024
1 parent ec022e9 commit 4721d55
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 9 deletions.
5 changes: 4 additions & 1 deletion source/NVDAObjects/inputComposition.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,10 @@ def findOverlayClasses(self, clsList):
return clsList

def reportNewText(self, oldString, newString):
if config.conf["keyboard"]["speakTypedCharacters"] > TypingEcho.OFF.value or config.conf["keyboard"]["speakTypedWords"] > TypingEcho.OFF.value:
if (
config.conf["keyboard"]["speakTypedCharacters"] > TypingEcho.OFF.value
or config.conf["keyboard"]["speakTypedWords"] > TypingEcho.OFF.value
):
newText = calculateInsertedChars(oldString.strip("\u3000"), newString.strip("\u3000"))
if newText:
queueHandler.queueFunction(
Expand Down
2 changes: 2 additions & 0 deletions source/config/configFlags.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ def _displayStringLabels(self):
NVDAKey.EXTENDED_INSERT: localizedKeyLabels["insert"],
}


@unique
class TypingEcho(DisplayStringIntEnum):
"""Enumeration containing the possible config values for typing echo (characters and words).
Expand All @@ -67,6 +68,7 @@ def _displayStringLabels(self):
TypingEcho.EDIT_CONTROLS: _("Only in edit controls"),
}


@unique
class ShowMessages(DisplayStringIntEnum):
"""Enumeration containing the possible config values for "Show messages" option in braille settings.
Expand Down
3 changes: 1 addition & 2 deletions source/globalCommands.py
Original file line number Diff line number Diff line change
Expand Up @@ -4221,8 +4221,7 @@ def script_braille_toggleNVDAKeyShift(self, gesture):
@script(
description=_(
# Translators: Input help mode message for a braille command.
"Virtually toggles the control and alt keys to emulate a "
"keyboard shortcut with braille input",
"Virtually toggles the control and alt keys to emulate a " "keyboard shortcut with braille input",
),
category=inputCore.SCRCAT_KBEMU,
bypassInputHelp=True,
Expand Down
2 changes: 1 addition & 1 deletion source/gui/settingsDialogs.py
Original file line number Diff line number Diff line change
Expand Up @@ -3264,6 +3264,7 @@ def isValid(self) -> bool:
return False
return super().isValid()


class AddonStorePanel(SettingsPanel):
# Translators: This is the label for the addon navigation settings panel.
title = _("Add-on Store")
Expand Down Expand Up @@ -5086,7 +5087,6 @@ def onSave(self):
self.initialProviders = vision.handler.getActiveProviderInfos()



class VisionProviderSubPanel_Settings(
AutoSettingsMixin,
SettingsPanel,
Expand Down
20 changes: 16 additions & 4 deletions source/speech/speech.py
Original file line number Diff line number Diff line change
Expand Up @@ -1355,10 +1355,14 @@ def _suppressSpeakTypedCharacters(number: int):
#: i.e. it should have a visual or spatial representation.
FIRST_NONCONTROL_CHAR = " "


def is_editableControl() -> bool:
obj=api.getFocusObject()
obj = api.getFocusObject()
controls = {controlTypes.ROLE_EDITABLETEXT, controlTypes.ROLE_DOCUMENT, controlTypes.ROLE_TERMINAL}
return (obj.role in controls or controlTypes.STATE_EDITABLE in obj.states) and controlTypes.STATE_READONLY not in obj.states
return (
obj.role in controls or controlTypes.STATE_EDITABLE in obj.states
) and controlTypes.STATE_READONLY not in obj.states


def speakTypedCharacters(ch: str):
typingIsProtected = api.isTypingProtected()
Expand All @@ -1381,7 +1385,11 @@ def speakTypedCharacters(ch: str):
log.io("typed word: %s" % typedWord)
typingEchoMode = config.conf["keyboard"]["speakTypedWords"]
if typingEchoMode > TypingEcho.OFF.value and not typingIsProtected:
if typingEchoMode == TypingEcho.EDIT_CONTROLS.value and is_editableControl() or typingEchoMode == TypingEcho.ON.value:
if (
typingEchoMode == TypingEcho.EDIT_CONTROLS.value
and is_editableControl()
or typingEchoMode == TypingEcho.ON.value
):
speakText(typedWord)
if _speechState._suppressSpeakTypedCharactersNumber > 0:
# We primarily suppress based on character count and still have characters to suppress.
Expand All @@ -1397,7 +1405,11 @@ def speakTypedCharacters(ch: str):

typingEchoMode = config.conf["keyboard"]["speakTypedCharacters"]
if not suppress and typingEchoMode > TypingEcho.OFF.value and ch >= FIRST_NONCONTROL_CHAR:
if typingEchoMode == TypingEcho.EDIT_CONTROLS.value and is_editableControl() or typingEchoMode == TypingEcho.ON.value:
if (
typingEchoMode == TypingEcho.EDIT_CONTROLS.value
and is_editableControl()
or typingEchoMode == TypingEcho.ON.value
):
speakSpelling(realChar)


Expand Down
2 changes: 1 addition & 1 deletion user_docs/en/userGuide.md
Original file line number Diff line number Diff line change
Expand Up @@ -2604,7 +2604,7 @@ This combo box controls how NVDA announces characters you type on the keyboard.
* Off: NVDA will not announce any characters you type.
* On: NVDA will announce all characters you type.
* Only in edit controls: NVDA will only announce characters typed in edit controls and other areas where text can be typed.

<!-- KC:setting -->

##### Speak Typed Words {#KeyboardSettingsSpeakTypedWords}
Expand Down

0 comments on commit 4721d55

Please sign in to comment.