[pywin32-checkins] pywin32/Pythonwin/pywin/scintilla IDLEenvironment.py, 1.14, 1.15
OLD project page for the Python extensions for Windows
Brought to you by:
mhammond
From: Mark H. <mha...@us...> - 2009-03-30 12:02:54
|
Update of /cvsroot/pywin32/pywin32/Pythonwin/pywin/scintilla In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv8398/pythonwin/pywin/scintilla Modified Files: IDLEenvironment.py Log Message: Fix Pythonwin when backspacing over an extended character (from markt (metolone), via bug 2618277) Index: IDLEenvironment.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/Pythonwin/pywin/scintilla/IDLEenvironment.py,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** IDLEenvironment.py 27 Nov 2008 03:53:25 -0000 1.14 --- IDLEenvironment.py 30 Mar 2009 12:02:43 -0000 1.15 *************** *** 303,307 **** def _getindex(self, off): return TkOffsetToIndex(off, self.edit) ! def _fix_eol_indexes(self, start, end): if start>0 and self.edit.SCIGetCharAt(start)=='\n' and self.edit.SCIGetCharAt(start-1)=='\r': start = start - 1 --- 303,313 ---- def _getindex(self, off): return TkOffsetToIndex(off, self.edit) ! def _fix_indexes(self, start, end): ! # first some magic to handle skipping over utf8 extended chars. ! while start > 0 and ord(self.edit.SCIGetCharAt(start)) & 0xC0 == 0x80: ! start -= 1 ! while end < self.edit.GetTextLength() and ord(self.edit.SCIGetCharAt(end)) & 0xC0 == 0x80: ! end += 1 ! # now handling fixing \r\n->\n disparities... if start>0 and self.edit.SCIGetCharAt(start)=='\n' and self.edit.SCIGetCharAt(start-1)=='\r': start = start - 1 *************** *** 340,344 **** end = max checkEnd = 1 ! start, end = self._fix_eol_indexes(start, end) ret = self.edit.GetTextRange(start, end) # pretend a trailing '\n' exists if necessary. --- 346,350 ---- end = max checkEnd = 1 ! start, end = self._fix_indexes(start, end) ret = self.edit.GetTextRange(start, end) # pretend a trailing '\n' exists if necessary. *************** *** 380,385 **** if start==self.edit.GetTextLength(): return # Nothing to delete. old = self.edit.GetSel()[0] # Lose a selection ! # Hack for partial '\r\n' removal ! start, end = self._fix_eol_indexes(start, end) self.edit.SetSel((start, end)) self.edit.Clear() --- 386,391 ---- if start==self.edit.GetTextLength(): return # Nothing to delete. old = self.edit.GetSel()[0] # Lose a selection ! # Hack for partial '\r\n' and UTF-8 char removal ! start, end = self._fix_indexes(start, end) self.edit.SetSel((start, end)) self.edit.Clear() *************** *** 519,521 **** if __name__=='__main__': ! test() \ No newline at end of file --- 525,528 ---- if __name__=='__main__': ! test() ! |