Skip to content

Commit 8f1fa7a

Browse files
authored
Merge 112059a into 2f142b3
2 parents 2f142b3 + 112059a commit 8f1fa7a

3 files changed

Lines changed: 34 additions & 2 deletions

File tree

source/mathPres/mathPlayer.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# A part of NonVisual Desktop Access (NVDA)
33
# This file is covered by the GNU General Public License.
44
# See the file COPYING for more details.
5-
# Copyright (C) 2014-2022 NV Access Limited
5+
# Copyright (C) 2014-2023 NV Access Limited, Cyrille Bougot
66

77
"""Support for math presentation using MathPlayer 4.
88
"""
@@ -20,6 +20,7 @@
2020
from keyboardHandler import KeyboardInputGesture
2121
import braille
2222
import mathPres
23+
import config
2324

2425
from speech.commands import (
2526
PitchCommand,
@@ -68,7 +69,10 @@ def _processMpSpeech(text, language):
6869
if m.lastgroup == "break":
6970
out.append(BreakCommand(time=int(m.group("break")) * breakMulti))
7071
elif m.lastgroup == "char":
71-
out.extend((CharacterModeCommand(True), m.group("char"), CharacterModeCommand(False)))
72+
if config.conf["speech"][synth.name]["useSpellingFunctionality"]:
73+
out.extend((CharacterModeCommand(True), m.group("char"), CharacterModeCommand(False)))
74+
else:
75+
out.append(m.group("char"))
7276
elif m.lastgroup == "comma":
7377
out.append(BreakCommand(time=100))
7478
elif m.lastgroup in PROSODY_COMMANDS:

source/speech/shortcutKeys.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111

1212
import characterProcessing
1313
from logHandler import log
14+
from synthDriverHandler import getSynth
15+
import config
1416

1517
from .commands import CharacterModeCommand
1618
from .types import SpeechSequence
@@ -79,6 +81,11 @@ def _getKeyboardShortcutSpeech(keyboardShortcut: str) -> SpeechSequence:
7981
return seq
8082

8183

84+
def shouldUseSpellingFunctionality() -> bool:
85+
synth = getSynth()
86+
return config.conf["speech"][synth.name]["useSpellingFunctionality"]
87+
88+
8289
def _getKeySpeech(key: str) -> SpeechSequence:
8390
"""Gets the speech sequence for a string describing a key.
8491
@param key: the key string.
@@ -91,6 +98,8 @@ def _getKeySpeech(key: str) -> SpeechSequence:
9198
keySymbol = characterProcessing.processSpeechSymbol(locale, key)
9299
if keySymbol != key:
93100
return [keySymbol]
101+
if not shouldUseSpellingFunctionality():
102+
return [key]
94103
return [
95104
CharacterModeCommand(True),
96105
key,

tests/unit/test_speechShortcutKeys.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,19 @@
77
"""
88

99
import unittest
10+
from unittest.mock import patch
1011

1112
from speech.shortcutKeys import (
1213
_getKeyboardShortcutSpeech,
1314
getKeyboardShortcutsSpeech,
1415
)
16+
import speech.shortcutKeys # noqa F401 - Used by unittest.mock.patch
1517
from speech.commands import CharacterModeCommand
1618

1719

1820
class Test_getKeyboardShortcutSpeech(unittest.TestCase):
1921

22+
@patch('speech.shortcutKeys.shouldUseSpellingFunctionality', lambda: True)
2023
def test_simpleLetterKey(self):
2124
"""A shortcut consisting in only one letter."""
2225

@@ -30,6 +33,19 @@ def test_simpleLetterKey(self):
3033
)
3134
self.assertEqual(repr(output), expected)
3235

36+
@patch('speech.shortcutKeys.shouldUseSpellingFunctionality', lambda: False)
37+
def test_simpleLetterKeyWithSpellingFunctionalityDisabled(self):
38+
"""A shortcut consisting in only one letter in the case where "Use spelling functionality" is disabled
39+
(see #15566).
40+
"""
41+
42+
expected = repr(['A',])
43+
output = _getKeyboardShortcutSpeech(
44+
keyboardShortcut='A',
45+
)
46+
self.assertEqual(repr(output), expected)
47+
48+
3349
def test_simpleSymbolKey(self):
3450
"""A shortcut consisting in only one symbol present in symbols.dic."""
3551

@@ -52,6 +68,7 @@ def test_simpleKeyName(self):
5268
)
5369
self.assertEqual(repr(output), expected)
5470

71+
@patch('speech.shortcutKeys.shouldUseSpellingFunctionality', lambda: True)
5572
def test_modifiersAndLetterKey(self):
5673
"""A shortcut consisting in modifiers and a letter key."""
5774

@@ -110,6 +127,7 @@ def test_modifierAndPlusKeyDescription(self):
110127
)
111128
self.assertEqual(repr(output), expected)
112129

130+
@patch('speech.shortcutKeys.shouldUseSpellingFunctionality', lambda: True)
113131
def test_sequentialShortcutCombiningSpacesAndCommas(self):
114132
"""A sequential shortcut found in ribbons (e.g. Word)."""
115133

@@ -136,6 +154,7 @@ def test_sequentialShortcutCombiningSpacesAndCommas(self):
136154

137155
class Test_getKeyboardShortcutsSpeech(unittest.TestCase):
138156

157+
@patch('speech.shortcutKeys.shouldUseSpellingFunctionality', lambda: True)
139158
def test_twoShortcutKeys(self):
140159
"""A shortcut key indication indicating two shortcut keys (a sequential one and a simultaneous one)
141160
as found in ribbons (e.g. Word).

0 commit comments

Comments
 (0)