Added Python methods to wxStyledTextCtrl that allow to get/set text in

UTF8 in either unicode or ansi builds


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@33678 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Robin Dunn
2005-04-16 19:41:33 +00:00
parent a1d2d6b1e8
commit 1ce1bd84ea
8 changed files with 269 additions and 27 deletions

View File

@@ -2884,6 +2884,90 @@ class StyledTextCtrl(_core.Control):
"""AppendTextRaw(self, char text)"""
return _stc.StyledTextCtrl_AppendTextRaw(*args, **kwargs)
# These functions are inserted as methods in to the Python StyleTextCtrl class
def AddTextUTF8(self, text):
"""Add UTF8 encoded text to the document at the current position."""
if not wx.USE_UNICODE:
u = text.decode('utf-8')
text = u.encode(wx.GetDefaultPyEncoding())
self.AddTextRaw(text)
def InsertTextUTF8(self, pos, text):
"""Insert UTF8 encoded text at a position."""
if not wx.USE_UNICODE:
u = text.decode('utf-8')
text = u.encode(wx.GetDefaultPyEncoding())
self.InsertTextRaw(pos, text)
def GetCurLineUTF8(self):
"""
Retrieve the text of the line containing the caret, and also the
index of the caret on the line.
"""
text, pos = self.GetCurLineRaw()
if not wx.USE_UNICODE:
u = text.decode(wx.GetDefaultPyEncoding())
text = u.encode('utf-8')
return text, pos
def GetLineUTF8(self, line):
"""Retrieve the contents of a line."""
text = self.GetLineRaw(line)
if not wx.USE_UNICODE:
u = text.decode(wx.GetDefaultPyEncoding())
text = u.encode('utf-8')
return text
def GetSelectedTextUTF8(self):
"""Retrieve the selected text."""
text = self.GetSelectedTextRaw()
if not wx.USE_UNICODE:
u = text.decode(wx.GetDefaultPyEncoding())
text = u.encode('utf-8')
return text
def GetTextRangeUTF8(self, startPos, endPos):
"""Retrieve a range of text."""
text = self.GetTextRangeRaw(startPos, endPos)
if not wx.USE_UNICODE:
u = text.decode(wx.GetDefaultPyEncoding())
text = u.encode('utf-8')
return text
def SetTextUTF8(self, text):
"""Replace the contents of the document with the argument text."""
if not wx.USE_UNICODE:
u = text.decode('utf-8')
text = u.encode(wx.GetDefaultPyEncoding())
self.SetTextRaw(text)
def GetTextUTF8(self):
"""Retrieve all the text in the document."""
text = self.GetTextRaw()
if not wx.USE_UNICODE:
u = text.decode(wx.GetDefaultPyEncoding())
text = u.encode('utf-8')
return text
def AppendTextUTF8(self, text):
"""Append a string to the end of the document without changing the selection."""
if not wx.USE_UNICODE:
u = text.decode('utf-8')
text = u.encode(wx.GetDefaultPyEncoding())
self.AppendTextRaw(text)
class StyledTextCtrlPtr(StyledTextCtrl):
def __init__(self, this):