11# A part of NonVisual Desktop Access (NVDA)
2- # Copyright (C) 2006-2022 NV Access Limited, Babbage B.V.
2+ # Copyright (C) 2006-2022 NV Access Limited, Babbage B.V., Cyrille Bougot
33# This file is covered by the GNU General Public License.
44# See the file COPYING for more details.
55
2222import winKernel
2323import api
2424import winUser
25+ from winAPI .winUser import GetSysColor
26+ from winAPI .winUser .constants import SysColorIndex
2527import textInfos .offsets
2628import controlTypes
2729from controlTypes import TextPosition
@@ -153,6 +155,7 @@ class getTextLengthExStruct(ctypes.Structure):
153155WB_LEFTBREAK = 6
154156WB_RIGHTBREAK = 7
155157
158+
156159class EditTextInfo (textInfos .offsets .OffsetsTextInfo ):
157160
158161 def _getPointFromOffset (self ,offset ):
@@ -274,8 +277,24 @@ def _getFormatFieldAndOffsets(self,offset,formatConfig,calculateOffsets=True):
274277 formatField ["text-position" ] = TextPosition .BASELINE
275278 if formatConfig ["reportColor" ]:
276279 if charFormat is None : charFormat = self ._getCharFormat (offset )
277- formatField ["color" ]= colors .RGB .fromCOLORREF (charFormat .crTextColor ) if not charFormat .dwEffects & CFE_AUTOCOLOR else _ ("default color" )
278- formatField ["background-color" ]= colors .RGB .fromCOLORREF (charFormat .crBackColor ) if not charFormat .dwEffects & CFE_AUTOBACKCOLOR else _ ("default color" )
280+ if charFormat .dwEffects & CFE_AUTOCOLOR :
281+ rgb = GetSysColor (SysColorIndex .WINDOW_TEXT )
282+ # Translators: The text color as reported in Wordpad (Automatic) or NVDA log viewer.
283+ formatField ["color" ] = _ ("{color} (default color)" ).format (
284+ color = colors .RGB .fromCOLORREF (rgb ).name ,
285+ )
286+ else :
287+ rgb = charFormat .crTextColor
288+ formatField ["color" ] = colors .RGB .fromCOLORREF (rgb )
289+ if charFormat .dwEffects & CFE_AUTOBACKCOLOR :
290+ rgb = GetSysColor (SysColorIndex .WINDOW )
291+ # Translators: The background color as reported in Wordpad (Automatic) or NVDA log viewer.
292+ formatField ["background-color" ] = _ ("{color} (default color)" ).format (
293+ color = colors .RGB .fromCOLORREF (rgb ).name ,
294+ )
295+ else :
296+ rgb = charFormat .crBackColor
297+ formatField ["background-color" ] = colors .RGB .fromCOLORREF (rgb )
279298 if formatConfig ["reportLineNumber" ]:
280299 formatField ["line-number" ]= self ._getLineNumFromOffset (offset )+ 1
281300 if formatConfig ["reportLinks" ]:
@@ -529,8 +548,10 @@ def _getFormatFieldAtRange(self, textRange, formatConfig):
529548 fontObj = textRange .font
530549 fgColor = fontObj .foreColor
531550 if fgColor == comInterfaces .tom .tomAutoColor :
532- # Translators: The default color of text when a color has not been set by the author.
533- formatField ['color' ]= _ ("default color" )
551+ # Translators: The text color as reported in Wordpad (Automatic) or NVDA log viewer.
552+ formatField ['color' ] = _ ("{color} (default color)" ).format (
553+ color = colors .RGB .fromCOLORREF (GetSysColor (SysColorIndex .WINDOW_TEXT )).name ,
554+ )
534555 elif fgColor & 0xff000000 :
535556 # The color is a palet index (we don't know the palet)
536557 # Translators: The color of text cannot be detected.
@@ -539,8 +560,10 @@ def _getFormatFieldAtRange(self, textRange, formatConfig):
539560 formatField ["color" ]= colors .RGB .fromCOLORREF (fgColor )
540561 bkColor = fontObj .backColor
541562 if bkColor == comInterfaces .tom .tomAutoColor :
542- # Translators: The default background color when a color has not been set by the author.
543- formatField ['background-color' ]= _ ("default color" )
563+ # Translators: The background color as reported in Wordpad (Automatic) or NVDA log viewer.
564+ formatField ['background-color' ] = _ ("{color} (default color)" ).format (
565+ color = colors .RGB .fromCOLORREF (GetSysColor (SysColorIndex .WINDOW )).name ,
566+ )
544567 elif bkColor & 0xff000000 :
545568 # The color is a palet index (we don't know the palet)
546569 # Translators: The background color cannot be detected.
0 commit comments