OSDN Git Service

Added support for color announcement in NVDA. For any text where NVDA can retreave...
authorMichael Curran <mick@kulgan.net>
Wed, 15 Sep 2010 06:11:19 +0000 (16:11 +1000)
committerMichael Curran <mick@kulgan.net>
Wed, 15 Sep 2010 06:11:19 +0000 (16:11 +1000)
source/NVDAObjects/IAccessible/__init__.py
source/appModules/_default.py
source/config/__init__.py
source/gui/settingsDialogs.py
source/speech.py

index 148bf55..c55479f 100644 (file)
@@ -14,6 +14,8 @@ import time
 import displayModel\r
 import IAccessibleHandler\r
 import oleacc\r
+import re\r
+import colors\r
 import JABHandler\r
 import winUser\r
 import globalVars\r
@@ -136,6 +138,8 @@ class IA2TextTextInfo(textInfos.offsets.OffsetsTextInfo):
                except:\r
                        return ""\r
 \r
+       re_IA2RGB=re.compile(r'rgb\((\d+),\s(\d+),\s(\d+)\)')\r
+\r
        def _getFormatFieldAndOffsets(self,offset,formatConfig,calculateOffsets=True):\r
                try:\r
                        startOffset,endOffset,attribsString=self.obj.IAccessibleTextObject.attributes(offset)\r
@@ -184,6 +188,16 @@ class IA2TextTextInfo(textInfos.offsets.OffsetsTextInfo):
                        invalid=None\r
                if invalid and invalid.lower()=="spelling":\r
                        formatField["invalid-spelling"]=True\r
+               color=formatField.get('color')\r
+               if color:\r
+                       m=self.re_IA2RGB.match(color)\r
+                       if m:\r
+                               formatField['color']=colors.RGB(int(m.group(1)),int(m.group(2)),int(m.group(3)))\r
+               backgroundColor=formatField.get('background-color')\r
+               if backgroundColor:\r
+                       m=self.re_IA2RGB.match(backgroundColor)\r
+                       if m:\r
+                               formatField['background-color']=colors.RGB(int(m.group(1)),int(m.group(2)),int(m.group(3)))\r
                return formatField,(startOffset,endOffset)\r
 \r
        def _getCharacterOffsets(self,offset):\r
index 0443a24..dcfd2e9 100755 (executable)
@@ -624,7 +624,7 @@ class AppModule(appModuleHandler.AppModule):
        def script_reportFormatting(self,keyPress):\r
                formatConfig={\r
                        "detectFormatAfterCursor":False,\r
-                       "reportFontName":True,"reportFontSize":True,"reportFontAttributes":True,\r
+                       "reportFontName":True,"reportFontSize":True,"reportFontAttributes":True,"reportColor":True,\r
                        "reportStyle":True,"reportAlignment":True,"reportSpellingErrors":True,\r
                        "reportPage":False,"reportLineNumber":False,"reportTables":False,\r
                        "reportLinks":False,"reportHeadings":False,"reportLists":False,\r
index c50f1b3..3078f75 100644 (file)
@@ -131,6 +131,7 @@ outputDevice = string(default=default)
        reportFontName = boolean(default=false)\r
        reportFontSize = boolean(default=false)\r
        reportFontAttributes = boolean(default=false)\r
+       reportColor = boolean(default=False)\r
        reportAlignment = boolean(default=false)\r
        reportStyle = boolean(default=false)\r
        reportSpellingErrors = boolean(default=true)\r
index e4ce65a..f441404 100644 (file)
@@ -654,6 +654,9 @@ class DocumentFormattingDialog(SettingsDialog):
                self.alignmentCheckBox=wx.CheckBox(self,wx.NewId(),label=_("Report &alignment"))\r
                self.alignmentCheckBox.SetValue(config.conf["documentFormatting"]["reportAlignment"])\r
                settingsSizer.Add(self.alignmentCheckBox,border=10,flag=wx.BOTTOM)\r
+               self.colorCheckBox=wx.CheckBox(self,wx.NewId(),label=_("Report &colors"))\r
+               self.colorCheckBox.SetValue(config.conf["documentFormatting"]["reportColor"])\r
+               settingsSizer.Add(self.colorCheckBox,border=10,flag=wx.BOTTOM)\r
                self.styleCheckBox=wx.CheckBox(self,wx.NewId(),label=_("Report st&yle"))\r
                self.styleCheckBox.SetValue(config.conf["documentFormatting"]["reportStyle"])\r
                settingsSizer.Add(self.styleCheckBox,border=10,flag=wx.BOTTOM)\r
@@ -696,6 +699,7 @@ class DocumentFormattingDialog(SettingsDialog):
                config.conf["documentFormatting"]["reportFontName"]=self.fontNameCheckBox.IsChecked()\r
                config.conf["documentFormatting"]["reportFontSize"]=self.fontSizeCheckBox.IsChecked()\r
                config.conf["documentFormatting"]["reportFontAttributes"]=self.fontAttrsCheckBox.IsChecked()\r
+               config.conf["documentFormatting"]["reportColor"]=self.colorCheckBox.IsChecked()\r
                config.conf["documentFormatting"]["reportAlignment"]=self.alignmentCheckBox.IsChecked()\r
                config.conf["documentFormatting"]["reportStyle"]=self.styleCheckBox.IsChecked()\r
                config.conf["documentFormatting"]["reportSpellingErrors"]=self.spellingErrorsCheckBox.IsChecked()\r
index 7b3ff2a..85a5702 100755 (executable)
@@ -9,6 +9,7 @@
 @type speechMode: boolean\r
 """ \r
 \r
+import colors\r
 import XMLFormatting\r
 import globalVars\r
 from logHandler import log\r
@@ -889,6 +890,15 @@ def getFormatFieldSpeech(attrs,attrsCache=None,formatConfig=None,unit=None,extra
                oldFontSize=attrsCache.get("font-size") if attrsCache is not None else None\r
                if fontSize and fontSize!=oldFontSize:\r
                        textList.append(fontSize)\r
+       if  formatConfig["reportColor"]:\r
+               color=attrs.get("color")\r
+               oldColor=attrsCache.get("color") if attrsCache is not None else None\r
+               if color and color!=oldColor:\r
+                       textList.append(colors.findColorName(color))\r
+               backgroundColor=attrs.get("background-color")\r
+               oldBackgroundColor=attrsCache.get("background-color") if attrsCache is not None else None\r
+               if backgroundColor and backgroundColor!=oldBackgroundColor:\r
+                       textList.append(_("on {backgroundColor}").format(backgroundColor=colors.findColorName(backgroundColor)))\r
        if  formatConfig["reportLineNumber"]:\r
                lineNumber=attrs.get("line-number")\r
                oldLineNumber=attrsCache.get("line-number") if attrsCache is not None else None\r