Skip to content

Commit 7c5c398

Browse files
committed
Added inSpeech and inBraille properties to OutputMode, and used them instead of bitwise ands in speech and braille code
1 parent efffb17 commit 7c5c398

File tree

3 files changed

+21
-3
lines changed

3 files changed

+21
-3
lines changed

source/braille.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1148,7 +1148,7 @@ def _setCursor(self, info: textInfos.TextInfo):
11481148

11491149
def _getTypeformFromFormatField(self, field, formatConfig):
11501150
typeform = louis.plain_text
1151-
if not (formatConfig["fontAttributeReporting"] & OutputMode.BRAILLE):
1151+
if not OutputMode(formatConfig["fontAttributeReporting"]).inBraille:
11521152
return typeform
11531153
if field.get("bold", False):
11541154
typeform |= louis.bold

source/config/configFlags.py

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
the default value.
1212
"""
1313

14-
from enum import unique
14+
from enum import unique, property as enum_property
1515
from utils.displayString import (
1616
DisplayStringIntEnum,
1717
DisplayStringStrEnum,
@@ -246,3 +246,21 @@ def _displayStringLabels(self):
246246
# Translators: A label for an option to choose a method of reporting information, e.g. font attributes.
247247
self.SPEECH_AND_BRAILLE: _("Speech and braille"),
248248
}
249+
250+
@enum_property
251+
def inSpeech(self) -> bool:
252+
"""Check if the output mode includes speech.
253+
254+
Returns:
255+
bool: True if the output mode includes speech, False otherwise.
256+
"""
257+
return self & self.SPEECH != 0
258+
259+
@enum_property
260+
def inBraille(self) -> bool:
261+
"""Check if the output mode includes braille.
262+
263+
Returns:
264+
bool: True if the output mode includes braille, False otherwise.
265+
"""
266+
return self & self.BRAILLE != 0

source/speech/speech.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2718,7 +2718,7 @@ def getFormatFieldSpeech( # noqa: C901
27182718
# Translators: Reported when text is no longer marked as emphasised
27192719
else _("not emphasised"))
27202720
textList.append(text)
2721-
if formatConfig["fontAttributeReporting"] & OutputMode.SPEECH:
2721+
if OutputMode(formatConfig["fontAttributeReporting"]).inSpeech:
27222722
bold=attrs.get("bold")
27232723
oldBold=attrsCache.get("bold") if attrsCache is not None else None
27242724
if (bold or oldBold is not None) and bold!=oldBold:

0 commit comments

Comments
 (0)