Skip to content

Commit b77fcdd

Browse files
Merge 56d97fe into fba5058
2 parents fba5058 + 56d97fe commit b77fcdd

5 files changed

Lines changed: 65 additions & 11 deletions

File tree

source/characterProcessing.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
#characterProcessing.py
2-
#A part of NonVisual Desktop Access (NVDA)
3-
#Copyright (C) 2010-2018 NV Access Limited, World Light Information Limited, Hong Kong Blind Union, Babbage B.V.
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) 2010-2020 NV Access Limited, World Light Information Limited,
3+
# Hong Kong Blind Union, Babbage B.V., Julien Cochuyt
4+
# This file is covered by the GNU General Public License.
5+
# See the file COPYING for more details.
66

77
import time
88
import os
@@ -130,6 +130,7 @@ def getCharacterDescription(locale,character):
130130
SYMLVL_MOST = 200
131131
SYMLVL_ALL = 300
132132
SYMLVL_CHAR = 1000
133+
SYMLVL_UNCHANGED = -1
133134
SPEECH_SYMBOL_LEVEL_LABELS = {
134135
# Translators: The level at which the given symbol will be spoken.
135136
SYMLVL_NONE: pgettext("symbolLevel", "none"),

source/config/configSpec.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# -*- coding: UTF-8 -*-
22
# A part of NonVisual Desktop Access (NVDA)
3-
# Copyright (C) 2006-2020 NV Access Limited, Babbage B.V., Davy Kager, Bill Dengler
3+
# Copyright (C) 2006-2020 NV Access Limited, Babbage B.V., Davy Kager, Bill Dengler, Julien Cochuyt
44
# This file is covered by the GNU General Public License.
55
# See the file COPYING for more details.
66

@@ -31,6 +31,8 @@
3131
# The synthesizer to use
3232
synth = string(default=auto)
3333
symbolLevel = integer(default=100)
34+
# Symbol Level when reviewing by word (unchanged if -1)
35+
symbolLevelWord = integer(default=300)
3436
trustVoiceLanguage = boolean(default=true)
3537
includeCLDR = boolean(default=True)
3638
beepSpeechModePitch = integer(default=10000,min=50,max=11025)

source/globalCommands.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -781,6 +781,26 @@ def script_cycleSpeechSymbolLevel(self,gesture):
781781
script_cycleSpeechSymbolLevel.__doc__=_("Cycles through speech symbol levels which determine what symbols are spoken")
782782
script_cycleSpeechSymbolLevel.category=SCRCAT_SPEECH
783783

784+
@script(
785+
# Translators: Input help mode message for a command.
786+
description=_("Toggle the announce of all punctuations and symbols when reviewing by word"),
787+
category=SCRCAT_SPEECH
788+
)
789+
def script_toggleSpeechSymbolLevelWordAll(self, gesture):
790+
curLevel = config.conf["speech"]["symbolLevelWord"]
791+
if curLevel == characterProcessing.SYMLVL_ALL:
792+
level = characterProcessing.SYMLVL_UNCHANGED
793+
reportedState = _("off")
794+
else:
795+
level = characterProcessing.SYMLVL_ALL
796+
reportedState = _("on")
797+
config.conf["speech"]["symbolLevelWord"] = level
798+
ui.message(
799+
_("Speak all punctuations and symbols when reviewing by word: {state}").format(
800+
state=reportedState
801+
)
802+
)
803+
784804
def script_moveMouseToNavigatorObject(self,gesture):
785805
try:
786806
p=api.getReviewPosition().pointAtStart

source/gui/settingsDialogs.py

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
# A part of NonVisual Desktop Access (NVDA)
33
# Copyright (C) 2006-2020 NV Access Limited, Peter Vágner, Aleksey Sadovoy,
44
# Rui Batista, Joseph Lee, Heiko Folkerts, Zahari Yurukov, Leonard de Ruijter,
5-
# Derek Riemer, Babbage B.V., Davy Kager, Ethan Holliger, Bill Dengler, Thomas Stivers
5+
# Derek Riemer, Babbage B.V., Davy Kager, Ethan Holliger, Bill Dengler, Thomas Stivers,
6+
# Julien Cochuyt
67
# This file is covered by the GNU General Public License.
78
# See the file COPYING for more details.
89
import logging
@@ -1461,6 +1462,21 @@ def makeSettings(self, settingsSizer):
14611462
characterProcessing.CONFIGURABLE_SPEECH_SYMBOL_LEVELS.index(curLevel)
14621463
)
14631464

1465+
self.symbolLevelWord = settingsSizerHelper.addItem(
1466+
wx.CheckBox(
1467+
self,
1468+
# Translators: The label for a setting in the Speech category
1469+
label=_("Speak all punctuations and symbols when reviewing by &word"),
1470+
style=wx.CHK_3STATE
1471+
)
1472+
)
1473+
if config.conf["speech"]["symbolLevelWord"] == characterProcessing.SYMLVL_ALL:
1474+
self.symbolLevelWord.Set3StateValue(wx.CHK_CHECKED)
1475+
elif config.conf["speech"]["symbolLevelWord"] == characterProcessing.SYMLVL_UNCHANGED:
1476+
self.symbolLevelWord.Set3StateValue(wx.CHK_UNCHECKED)
1477+
else:
1478+
self.symbolLevelWord.Set3StateValue(wx.CHK_UNDETERMINED)
1479+
14641480
# Translators: This is the label for a checkbox in the
14651481
# voice settings panel (if checked, text will be read using the voice for the language of the text).
14661482
trustVoiceLanguageText = _("Trust voice's language when processing characters and symbols")
@@ -1548,8 +1564,14 @@ def onSave(self):
15481564

15491565
config.conf["speech"]["autoLanguageSwitching"] = self.autoLanguageSwitchingCheckbox.IsChecked()
15501566
config.conf["speech"]["autoDialectSwitching"] = self.autoDialectSwitchingCheckbox.IsChecked()
1551-
config.conf["speech"]["symbolLevel"]=characterProcessing.CONFIGURABLE_SPEECH_SYMBOL_LEVELS[self.symbolLevelList.GetSelection()]
1552-
config.conf["speech"]["trustVoiceLanguage"]=self.trustVoiceLanguageCheckbox.IsChecked()
1567+
config.conf["speech"]["symbolLevel"] = characterProcessing.CONFIGURABLE_SPEECH_SYMBOL_LEVELS[
1568+
self.symbolLevelList.GetSelection()
1569+
]
1570+
if self.symbolLevelWord.Get3StateValue() == wx.CHK_CHECKED:
1571+
config.conf["speech"]["symbolLevelWord"] = characterProcessing.SYMLVL_ALL
1572+
elif self.symbolLevelWord.Get3StateValue() == wx.CHK_UNCHECKED:
1573+
config.conf["speech"]["symbolLevelWord"] = characterProcessing.SYMLVL_UNCHANGED
1574+
config.conf["speech"]["trustVoiceLanguage"] = self.trustVoiceLanguageCheckbox.IsChecked()
15531575
currentIncludeCLDR = config.conf["speech"]["includeCLDR"]
15541576
config.conf["speech"]["includeCLDR"] = newIncludeCldr = self.includeCLDRCheckbox.IsChecked()
15551577
if currentIncludeCLDR is not newIncludeCldr:

source/speech/__init__.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1084,8 +1084,17 @@ def speakTextInfo(
10841084
return _speakWithoutPauses.speakWithoutPauses(flatSpeechGen)
10851085

10861086
speechGen = GeneratorWithReturn(speechGen)
1087+
symbolLevel = None
1088+
if unit == textInfos.UNIT_CHARACTER:
1089+
symbolLevel = characterProcessing.SYMLVL_ALL
1090+
elif unit == textInfos.UNIT_WORD:
1091+
symbolLevelWord = config.conf["speech"]["symbolLevelWord"]
1092+
if symbolLevelWord != characterProcessing.SYMLVL_UNCHANGED:
1093+
symbolLevel = symbolLevelWord
1094+
else:
1095+
symbolLevel = None
10871096
for seq in speechGen:
1088-
speak(seq, priority=priority)
1097+
speak(seq, symbolLevel=symbolLevel, priority=priority)
10891098
return speechGen.returnValue
10901099

10911100

@@ -1281,7 +1290,7 @@ def isControlEndFieldCommand(x):
12811290
if onlyInitialFields or (
12821291
isWordOrCharUnit
12831292
and len(textWithFields) > 0
1284-
and len(textWithFields[0].strip() if not textWithFields[0].isspace() else textWithFields[0]) == 1
1293+
and len(textWithFields[0]) == 1
12851294
and all(isControlEndFieldCommand(x) for x in itertools.islice(textWithFields, 1, None))
12861295
):
12871296
if not onlyCache:

0 commit comments

Comments
 (0)