Skip to content

Commit b0f6fb2

Browse files
Merge 00ffe1d into a7f9d47
2 parents a7f9d47 + 00ffe1d commit b0f6fb2

2 files changed

Lines changed: 39 additions & 10 deletions

File tree

source/globalCommands.py

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1732,7 +1732,7 @@ def _reportFormattingHelper(self, info, browseable=False):
17321732
formatField.update(field.field)
17331733

17341734
if not browseable:
1735-
if formatField:
1735+
if formatField: # In which case is this dict expected to be empty?
17361736
sequence = info.getFormatFieldSpeech(formatField, formatConfig=formatConfig)
17371737
textList.extend(sequence)
17381738

@@ -1743,7 +1743,9 @@ def _reportFormattingHelper(self, info, browseable=False):
17431743

17441744
ui.message(" ".join(textList))
17451745
else:
1746-
if formatField:
1746+
if formatField: # In which case is this dict expected to be empty?
1747+
if browseable == "technical":
1748+
formatConfig["technical"] = True
17471749
sequence = info.getFormatFieldSpeech(formatField, formatConfig=formatConfig)
17481750
textList.extend(sequence)
17491751

@@ -1799,6 +1801,18 @@ def script_reportFormattingAtReview(self, gesture):
17991801
def script_showFormattingAtReview(self, gesture):
18001802
self._reportFormattingHelper(api.getReviewPosition(), True)
18011803

1804+
@script(
1805+
# Translators: Input help mode message for show technical formatting at review cursor command.
1806+
description=_(
1807+
"Presents, in browse mode, technical formatting info "
1808+
"for the current review cursor position."
1809+
),
1810+
gesture="NVDA+alt+shif+f",
1811+
category=SCRCAT_TEXTREVIEW
1812+
)
1813+
def script_showTechnicalFormattingAtReview(self, gesture):
1814+
self._reportFormattingHelper(api.getReviewPosition(), browseable="technical")
1815+
18021816
@script(
18031817
description=_(
18041818
# Translators: Input help mode message for report formatting command.

source/speech/__init__.py

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1958,6 +1958,21 @@ def getControlFieldSpeech( # noqa: C901
19581958
return []
19591959

19601960

1961+
def _getColorName(color, withRGB=False):
1962+
"""Helper function that will return the appropriate string presentation of a color,
1963+
based on whether the user wants the RGB value reported or not.
1964+
"""
1965+
if not isinstance(color, colors.RGB):
1966+
return str(color)
1967+
if withRGB:
1968+
return (
1969+
f"{color.name}"
1970+
f" (RGB: {color.red}, {color.green}, {color.blue}"
1971+
f" / #{color.red:02x}{color.green:02x}{color.blue:02x})"
1972+
)
1973+
return color.name
1974+
1975+
19611976
# C901 'getFormatFieldSpeech' is too complex
19621977
# Note: when working on getFormatFieldSpeech, look for opportunities to simplify
19631978
# and move logic out into smaller helper functions.
@@ -1973,6 +1988,7 @@ def getFormatFieldSpeech( # noqa: C901
19731988
if not formatConfig:
19741989
formatConfig=config.conf["documentFormatting"]
19751990
textList=[]
1991+
technical = formatConfig.get("technical", False)
19761992
if formatConfig["reportTables"]:
19771993
tableInfo=attrs.get("table-info")
19781994
oldTableInfo=attrsCache.get("table-info") if attrsCache is not None else None
@@ -2095,35 +2111,34 @@ def getFormatFieldSpeech( # noqa: C901
20952111
textList.append(fontSize)
20962112
if formatConfig["reportColor"]:
20972113
color=attrs.get("color")
2114+
colorName = _getColorName(color, withRGB=technical)
20982115
oldColor=attrsCache.get("color") if attrsCache is not None else None
20992116
backgroundColor=attrs.get("background-color")
21002117
oldBackgroundColor=attrsCache.get("background-color") if attrsCache is not None else None
21012118
backgroundColor2=attrs.get("background-color2")
21022119
oldBackgroundColor2=attrsCache.get("background-color2") if attrsCache is not None else None
21032120
bgColorChanged=backgroundColor!=oldBackgroundColor or backgroundColor2!=oldBackgroundColor2
2104-
bgColorText=backgroundColor.name if isinstance(backgroundColor,colors.RGB) else backgroundColor
2121+
bgColorName = _getColorName(backgroundColor, withRGB=technical)
21052122
if backgroundColor2:
2106-
bg2Name=backgroundColor2.name if isinstance(backgroundColor2,colors.RGB) else backgroundColor2
2123+
bgColor2Name = _getColorName(backgroundColor2, withRGB=technical)
21072124
# Translators: Reported when there are two background colors.
21082125
# This occurs when, for example, a gradient pattern is applied to a spreadsheet cell.
21092126
# {color1} will be replaced with the first background color.
21102127
# {color2} will be replaced with the second background color.
2111-
bgColorText=_("{color1} to {color2}").format(color1=bgColorText,color2=bg2Name)
2128+
bgColorName = _("{color1} to {color2}").format(color1=bgColorName, color2=bgColor2Name)
21122129
if color and backgroundColor and color!=oldColor and bgColorChanged:
21132130
# Translators: Reported when both the text and background colors change.
21142131
# {color} will be replaced with the text color.
21152132
# {backgroundColor} will be replaced with the background color.
2116-
textList.append(_("{color} on {backgroundColor}").format(
2117-
color=color.name if isinstance(color,colors.RGB) else color,
2118-
backgroundColor=bgColorText))
2133+
textList.append(_("{color} on {backgroundColor}").format(color=colorName, backgroundColor=bgColorName))
21192134
elif color and color!=oldColor:
21202135
# Translators: Reported when the text color changes (but not the background color).
21212136
# {color} will be replaced with the text color.
2122-
textList.append(_("{color}").format(color=color.name if isinstance(color,colors.RGB) else color))
2137+
textList.append(_("{color}").format(colorName))
21232138
elif backgroundColor and bgColorChanged:
21242139
# Translators: Reported when the background color changes (but not the text color).
21252140
# {backgroundColor} will be replaced with the background color.
2126-
textList.append(_("{backgroundColor} background").format(backgroundColor=bgColorText))
2141+
textList.append(_("{backgroundColor} background").format(backgroundColor=bgColorName))
21272142
backgroundPattern=attrs.get("background-pattern")
21282143
oldBackgroundPattern=attrsCache.get("background-pattern") if attrsCache is not None else None
21292144
if backgroundPattern and backgroundPattern!=oldBackgroundPattern:

0 commit comments

Comments
 (0)