[Nvda-dev] commit r2028 - trunk/source/NVDAObjects/IAccessible

NVDA Subversion svn at nvda-project.org
Fri May 9 11:43:18 UTC 2008


Author: pvagner
Date: Fri May  9 11:43:17 2008
New Revision: 2028

Log:
* scintilla edit controls: adding support for various encodings. When scintilla is working in ansi it will use locale defaults encoding. Otherwise (when set to utf-8, or utf-16 le or utf_16 be) it will use utf-8 what is used internally by scintilla in all these cases. It means if you have problems reading national characters in applications such as notepad++ you can convert to utf-8 and it should start working. Please report problems if you see them.

Modified:
   trunk/source/NVDAObjects/IAccessible/scintilla.py

Modified: trunk/source/NVDAObjects/IAccessible/scintilla.py
==============================================================================
--- trunk/source/NVDAObjects/IAccessible/scintilla.py	(original)
+++ trunk/source/NVDAObjects/IAccessible/scintilla.py	Fri May  9 11:43:17 2008
@@ -7,6 +7,7 @@
 import controlTypes
 from . import IAccessible 
 from .. import NVDAObjectTextInfo
+import locale
 
 #Window messages
 SCI_POSITIONFROMPOINT=2022
@@ -35,9 +36,12 @@
 SCI_STYLEGETUNDERLINE=2488
 SCI_WORDSTARTPOSITION=2266
 SCI_WORDENDPOSITION=2267
+SCI_GETCODEPAGE=2137
+SCI_POSITIONAFTER=2418
 
 #constants
 STYLE_DEFAULT=32
+SC_CP_UTF8=65001
 
 class CharacterRangeStruct(ctypes.Structure):
 	_fields_=[
@@ -97,8 +101,11 @@
 		buf=ctypes.create_string_buffer(bufLen)
 		winKernel.readProcessMemory(processHandle,internalBuf,buf,bufLen,None)
 		winKernel.virtualFreeEx(processHandle,internalBuf,0,winKernel.MEM_RELEASE)
-		return buf.value
-
+		cp=winUser.sendMessage(self.obj.windowHandle,SCI_GETCODEPAGE,0,0)
+		if cp==SC_CP_UTF8:
+			return unicode(buf.value, errors="replace", encoding="utf-8")
+		else:
+			return unicode(buf.value, errors="replace", encoding=locale.getlocale()[1])
 
 	def _getWordOffsets(self,offset):
 		start=winUser.sendMessage(self.obj.windowHandle,SCI_WORDSTARTPOSITION,offset,0)
@@ -123,6 +130,9 @@
 	def _getParagraphOffsets(self,offset):
 		return super(EditTextInfo,self)._getLineOffsets(offset)
 
+	def _getCharacterOffsets(self,offset):
+		return [offset,winUser.sendMessage(self.obj.windowHandle,SCI_POSITIONAFTER,offset,0)]
+
 #The Scintilla NVDA object, inherists the generic MSAA NVDA object
 class Scintilla(IAccessible):
 



More information about the Nvda-dev mailing list