Skip to content

Commit 9738079

Browse files
authored
Merge b2e7310 into 9ea2566
2 parents 9ea2566 + b2e7310 commit 9738079

File tree

17 files changed

+183
-28
lines changed

17 files changed

+183
-28
lines changed

source/NVDAObjects/UIA/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ def _getFormatFieldAtRange( # noqa: C901
207207
IDs.add(UIAHandler.UIA_FontNameAttributeId)
208208
if formatConfig["reportFontSize"]:
209209
IDs.add(UIAHandler.UIA_FontSizeAttributeId)
210-
if formatConfig["reportFontAttributes"]:
210+
if formatConfig["fontAttributeReporting"]:
211211
IDs.update({
212212
UIAHandler.UIA_FontWeightAttributeId,
213213
UIAHandler.UIA_IsItalicAttributeId,
@@ -247,7 +247,7 @@ def _getFormatFieldAtRange( # noqa: C901
247247
if isinstance(val, numbers.Number):
248248
# Translators: Abbreviation for points, a measurement of font size.
249249
formatField['font-size'] = pgettext("font size", "%s pt") % float(val)
250-
if formatConfig["reportFontAttributes"]:
250+
if formatConfig["fontAttributeReporting"]:
251251
val=fetcher.getValue(UIAHandler.UIA_FontWeightAttributeId,ignoreMixedValues=ignoreMixedValues)
252252
if isinstance(val,int):
253253
formatField['bold']=(val>=700)

source/NVDAObjects/window/edit.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,7 @@ def _getFormatFieldAndOffsets(self, offset, formatConfig, calculateOffsets=True)
267267
fontSize = charFormat.yHeight // 20
268268
# Translators: Abbreviation for points, a measurement of font size.
269269
formatField["font-size"] = pgettext("font size", "%s pt") % fontSize
270-
if formatConfig["reportFontAttributes"]:
270+
if formatConfig["fontAttributeReporting"]:
271271
if charFormat is None: charFormat=self._getCharFormat(offset)
272272
formatField["bold"]=bool(charFormat.dwEffects&CFE_BOLD)
273273
formatField["italic"]=bool(charFormat.dwEffects&CFE_ITALIC)
@@ -543,7 +543,7 @@ def _getFormatFieldAtRange(self, textRange, formatConfig): # noqa: C901
543543
fontObj = textRange.font
544544
# Translators: Abbreviation for points, a measurement of font size.
545545
formatField["font-size"] = pgettext("font size", "%s pt") % fontObj.size
546-
if formatConfig["reportFontAttributes"]:
546+
if formatConfig["fontAttributeReporting"]:
547547
if not fontObj:
548548
fontObj = textRange.font
549549
formatField["bold"]=bool(fontObj.bold)

source/NVDAObjects/window/excel.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1188,7 +1188,7 @@ def _getFormatFieldAndOffsets(self,offset,formatConfig,calculateOffsets=True):
11881188
if formatConfig['reportFontSize']:
11891189
# Translators: Abbreviation for points, a measurement of font size.
11901190
formatField['font-size'] = pgettext("font size", "%s pt") % fontObj.size
1191-
if formatConfig['reportFontAttributes']:
1191+
if formatConfig['fontAttributeReporting']:
11921192
formatField['bold']=fontObj.bold
11931193
formatField['italic']=fontObj.italic
11941194
underline=fontObj.underline

source/NVDAObjects/window/scintilla.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ def _getFormatFieldAndOffsets(self,offset,formatConfig,calculateOffsets=True):
132132
formatField["font-size"] = pgettext("font size", "%s pt") % fontSize
133133
if formatConfig["reportLineNumber"]:
134134
formatField["line-number"]=self._getLineNumFromOffset(offset)+1
135-
if formatConfig["reportFontAttributes"]:
135+
if formatConfig["fontAttributeReporting"]:
136136
formatField["bold"]=bool(watchdog.cancellableSendMessage(self.obj.windowHandle,SCI_STYLEGETBOLD,style,0))
137137
formatField["italic"]=bool(watchdog.cancellableSendMessage(self.obj.windowHandle,SCI_STYLEGETITALIC,style,0))
138138
formatField["underline"]=bool(watchdog.cancellableSendMessage(self.obj.windowHandle,SCI_STYLEGETUNDERLINE,style,0))

source/NVDAObjects/window/winword.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -367,7 +367,7 @@ class WinWordColor(IntEnum):
367367
formatConfigFlagsMap = {
368368
"reportFontName": 0x1,
369369
"reportFontSize": 0x2,
370-
"reportFontAttributes": 0x4,
370+
"fontAttributeReporting": 0x4,
371371
"reportColor": 0x8,
372372
"reportAlignment": 0x10,
373373
"reportStyle": 0x20,

source/appModules/powerpnt.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1006,7 +1006,7 @@ def _getFormatFieldAndOffsets(self,offset,formatConfig,calculateOffsets=True):
10061006
if formatConfig['reportFontSize']:
10071007
# Translators: Abbreviation for points, a measurement of font size.
10081008
formatField['font-size'] = pgettext("font size", "%s pt") % font.size
1009-
if formatConfig['reportFontAttributes']:
1009+
if formatConfig['fontAttributeReporting']:
10101010
formatField['bold']=bool(font.bold)
10111011
formatField['italic']=bool(font.italic)
10121012
formatField['underline']=bool(font.underline)

source/braille.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
TetherTo,
4646
BrailleMode,
4747
ReportTableHeaders,
48+
OutputMode,
4849
)
4950
from config.featureFlagEnums import ReviewRoutingMovesSystemCaretFlag
5051
from logHandler import log
@@ -1148,7 +1149,7 @@ def _setCursor(self, info: textInfos.TextInfo):
11481149

11491150
def _getTypeformFromFormatField(self, field, formatConfig):
11501151
typeform = louis.plain_text
1151-
if not formatConfig["reportFontAttributes"]:
1152+
if not formatConfig["fontAttributeReporting"] & OutputMode.BRAILLE:
11521153
return typeform
11531154
if field.get("bold", False):
11541155
typeform |= louis.bold

source/browseMode.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2210,7 +2210,7 @@ def _extractStyles(
22102210
reportFormattingOptions = (
22112211
"reportFontName",
22122212
"reportFontSize",
2213-
"reportFontAttributes",
2213+
"fontAttributeReporting",
22142214
"reportSuperscriptsAndSubscripts",
22152215
"reportHighlight",
22162216
"reportColor",

source/config/__init__.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
from . import profileUpgrader
3737
from . import aggregatedSection
3838
from .configSpec import confspec
39+
from .configFlags import OutputMode
3940
from .featureFlag import (
4041
_transformSpec_AddFeatureFlagDefault,
4142
_validateConfig_featureFlag,
@@ -1283,6 +1284,22 @@ def __setitem__(
12831284
self.manager._markWriteProfileDirty()
12841285
self._cache[key] = val
12851286

1287+
# Alias [documentFormatting][reportFontAttributes] for backwards compatibility.
1288+
# Todo: Remove in 2025.1.
1289+
if self.path == ("documentFormatting",):
1290+
aliasing = False
1291+
if key == "fontAttributeReporting":
1292+
key = "reportFontAttributes"
1293+
val = bool(val)
1294+
aliasing = True
1295+
elif key == "reportFontAttributes":
1296+
key = "fontAttributeReporting"
1297+
val = OutputMode.SPEECH_AND_BRAILLE if val else OutputMode.OFF
1298+
aliasing = True
1299+
if aliasing:
1300+
self._getUpdateSection()[key] = val
1301+
self._cache[key] = val
1302+
12861303
def _getUpdateSection(self):
12871304
profile = self.profiles[-1]
12881305
if profile is not None:

source/config/configFlags.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,3 +220,23 @@ def _displayStringLabels(self):
220220
# Translators: This is a label for the automatic update behaviour for add-ons.
221221
self.DISABLED: _("Disabled"),
222222
}
223+
224+
@unique
225+
class OutputMode(DisplayStringIntEnum):
226+
OFF = 0
227+
SPEECH = 1
228+
BRAILLE = 2
229+
SPEECH_AND_BRAILLE = 3
230+
231+
@property
232+
def _displayStringLabels(self):
233+
return {
234+
# Translators: This is a way of reporting information.
235+
self.OFF: _("Off"),
236+
# Translators: This is a way of reporting information.
237+
self.SPEECH: _("Speech"),
238+
# Translators: This is a way of reporting information.
239+
self.BRAILLE: _("Braille"),
240+
# Translators: This is a way of reporting information.
241+
self.SPEECH_AND_BRAILLE: _("Speech and braille"),
242+
}

0 commit comments

Comments
 (0)