[pywin32-checkins] pywin32/Pythonwin/pywin/scintilla formatter.py, 1.17, 1.18
OLD project page for the Python extensions for Windows
Brought to you by:
mhammond
From: Mark H. <mha...@us...> - 2009-01-31 03:52:45
|
Update of /cvsroot/pywin32/pywin32/Pythonwin/pywin/scintilla In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv22805/pywin/scintilla Modified Files: formatter.py Log Message: do syntax coloring on the raw utf8 stream Index: formatter.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/Pythonwin/pywin/scintilla/formatter.py,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** formatter.py 3 Jan 2009 05:52:28 -0000 1.17 --- formatter.py 31 Jan 2009 03:52:39 -0000 1.18 *************** *** 240,244 **** def Colorize(self, start=0, end=-1): scintilla = self.scintilla ! stringVal = scintilla.GetTextRange(start, end) if start > 0: stylenum = scintilla.SCIGetStyleAt(start - 1) --- 240,248 ---- def Colorize(self, start=0, end=-1): scintilla = self.scintilla ! # scintilla's formatting is all done in terms of utf, so ! # we work with utf8 bytes instead of unicode. This magically ! # works as any extended chars found in the utf8 don't change ! # the semantics. ! stringVal = scintilla.GetTextRange(start, end, decode=False) if start > 0: stylenum = scintilla.SCIGetStyleAt(start - 1) *************** *** 359,363 **** def ClassifyWord(self, cdoc, start, end, prevWord): ! word = cdoc[start:end+1] attr = STYLE_IDENTIFIER if prevWord == "class": --- 363,367 ---- def ClassifyWord(self, cdoc, start, end, prevWord): ! word = cdoc[start:end+1].decode('latin-1') attr = STYLE_IDENTIFIER if prevWord == "class": *************** *** 365,369 **** elif prevWord == "def": attr = STYLE_METHOD ! elif cdoc[start] in string.digits: attr = STYLE_NUMBER elif iskeyword(word): --- 369,373 ---- elif prevWord == "def": attr = STYLE_METHOD ! elif word[0] in string.digits: attr = STYLE_NUMBER elif iskeyword(word): *************** *** 383,395 **** state = styleStart chPrev = chPrev2 = chPrev3 = ' ' ! chNext = cdoc[charStart] ! chNext2 = cdoc[charStart] startSeg = i = charStart while i < lengthDoc: ch = chNext chNext = ' ' ! if i+1 < lengthDoc: chNext = cdoc[i+1] chNext2 = ' ' ! if i+2 < lengthDoc: chNext2 = cdoc[i+2] if state == STYLE_DEFAULT: if ch in wordstarts: --- 387,398 ---- state = styleStart chPrev = chPrev2 = chPrev3 = ' ' ! chNext2 = chNext = cdoc[charStart:charStart+1].decode('latin-1') startSeg = i = charStart while i < lengthDoc: ch = chNext chNext = ' ' ! if i+1 < lengthDoc: chNext = cdoc[i+1:i+2].decode('latin-1') chNext2 = ' ' ! if i+2 < lengthDoc: chNext2 = cdoc[i+2:i+3].decode('latin-1') if state == STYLE_DEFAULT: if ch in wordstarts: |