[pywin32-checkins] pywin32/Pythonwin/pywin/scintilla control.py, 1.20, 1.21
OLD project page for the Python extensions for Windows
Brought to you by:
mhammond
|
From: Mark H. <mha...@us...> - 2009-01-31 03:31:13
|
Update of /cvsroot/pywin32/pywin32/Pythonwin/pywin/scintilla In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv20618/pywin/scintilla Modified Files: control.py Log Message: Allow GetTextRange() to return raw utf8 and SCIInsertText only encodes unicode Index: control.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/Pythonwin/pywin/scintilla/control.py,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -d -r1.20 -r1.21 *** control.py 5 Jan 2009 11:07:24 -0000 1.20 --- control.py 31 Jan 2009 03:31:03 -0000 1.21 *************** *** 73,78 **** self.SendMessage(scintillacon.SCI_ADDSTYLEDTEXT, text.encode(default_scintilla_encoding)) def SCIInsertText(self, text, pos=-1): ! buff=(text+'\0').encode(default_scintilla_encoding) ! self.SendScintilla(scintillacon.SCI_INSERTTEXT, pos, buff) def SCISetSavePoint(self): self.SendScintilla(scintillacon.SCI_SETSAVEPOINT) --- 73,82 ---- self.SendMessage(scintillacon.SCI_ADDSTYLEDTEXT, text.encode(default_scintilla_encoding)) def SCIInsertText(self, text, pos=-1): ! # SCIInsertText allows unicode or bytes - but if they are bytes, ! # the caller must ensure it is encoded correctly. ! if isinstance(text, unicode): ! text = text.encode(default_scintilla_encoding) ! win32api.OutputDebugString("SCI: %r\n" % text) ! self.SendScintilla(scintillacon.SCI_INSERTTEXT, pos, text + null_byte) def SCISetSavePoint(self): self.SendScintilla(scintillacon.SCI_SETSAVEPOINT) *************** *** 343,347 **** return self.SendScintilla(win32con.WM_GETTEXTLENGTH) ! def GetTextRange(self, start = 0, end = -1): if end == -1: end = self.SendScintilla(win32con.WM_GETTEXTLENGTH) assert end>=start, "Negative index requested (%d/%d)" % (start, end) --- 347,351 ---- return self.SendScintilla(win32con.WM_GETTEXTLENGTH) ! def GetTextRange(self, start = 0, end = -1, decode = True): if end == -1: end = self.SendScintilla(win32con.WM_GETTEXTLENGTH) assert end>=start, "Negative index requested (%d/%d)" % (start, end) *************** *** 354,359 **** trBuff = array.array('b', tr) addressTrBuff = trBuff.buffer_info()[0] ! numChars = self.SendScintilla(EM_GETTEXTRANGE, 0, addressTrBuff) ! return buff.tostring()[:numChars].decode(default_scintilla_encoding) def ReplaceSel(self, str): --- 358,366 ---- trBuff = array.array('b', tr) addressTrBuff = trBuff.buffer_info()[0] ! num_bytes = self.SendScintilla(EM_GETTEXTRANGE, 0, addressTrBuff) ! ret = buff.tostring()[:num_bytes] ! if decode: ! ret = ret.decode(default_scintilla_encoding) ! return ret def ReplaceSel(self, str): |