]> git.saurik.com Git - wxWidgets.git/blob - wxPython/contrib/stc/_stc_utf8_methods.py
Applied patch [ 1284335 ] doc update for wxString::operator[]
[wxWidgets.git] / wxPython / contrib / stc / _stc_utf8_methods.py
1
2 def AddTextUTF8(self, text):
3 """
4 Add UTF8 encoded text to the document at the current position.
5 Works 'natively' in a unicode build of wxPython, and will also work
6 in an ansi build if the UTF8 text is compatible with the current
7 encoding.
8 """
9 if not wx.USE_UNICODE:
10 u = text.decode('utf-8')
11 text = u.encode(wx.GetDefaultPyEncoding())
12 self.AddTextRaw(text)
13
14
15 def InsertTextUTF8(self, pos, text):
16 """
17 Insert UTF8 encoded text at a position. Works 'natively' in a
18 unicode build of wxPython, and will also work in an ansi build if
19 the UTF8 text is compatible with the current encoding.
20 """
21 if not wx.USE_UNICODE:
22 u = text.decode('utf-8')
23 text = u.encode(wx.GetDefaultPyEncoding())
24 self.InsertTextRaw(pos, text)
25
26
27 def GetCurLineUTF8(self):
28 """
29 Retrieve the UTF8 text of the line containing the caret, and also
30 the index of the caret on the line. In an ansi build of wxPython
31 the text retrieved from the document is assumed to be in the
32 current default encoding.
33 """
34 text, pos = self.GetCurLineRaw()
35 if not wx.USE_UNICODE:
36 u = text.decode(wx.GetDefaultPyEncoding())
37 text = u.encode('utf-8')
38 return text, pos
39
40
41 def GetLineUTF8(self, line):
42 """
43 Retrieve the contents of a line as UTF8. In an ansi build of wxPython
44 the text retrieved from the document is assumed to be in the
45 current default encoding.
46 """
47 text = self.GetLineRaw(line)
48 if not wx.USE_UNICODE:
49 u = text.decode(wx.GetDefaultPyEncoding())
50 text = u.encode('utf-8')
51 return text
52
53
54 def GetSelectedTextUTF8(self):
55 """
56 Retrieve the selected text as UTF8. In an ansi build of wxPython
57 the text retrieved from the document is assumed to be in the
58 current default encoding.
59 """
60 text = self.GetSelectedTextRaw()
61 if not wx.USE_UNICODE:
62 u = text.decode(wx.GetDefaultPyEncoding())
63 text = u.encode('utf-8')
64 return text
65
66
67 def GetTextRangeUTF8(self, startPos, endPos):
68 """
69 Retrieve a range of text as UTF8. In an ansi build of wxPython
70 the text retrieved from the document is assumed to be in the
71 current default encoding.
72 """
73 text = self.GetTextRangeRaw(startPos, endPos)
74 if not wx.USE_UNICODE:
75 u = text.decode(wx.GetDefaultPyEncoding())
76 text = u.encode('utf-8')
77 return text
78
79
80 def SetTextUTF8(self, text):
81 """
82 Replace the contents of the document with the UTF8 text given.
83 Works 'natively' in a unicode build of wxPython, and will also
84 work in an ansi build if the UTF8 text is compatible with the
85 current encoding.
86 """
87 if not wx.USE_UNICODE:
88 u = text.decode('utf-8')
89 text = u.encode(wx.GetDefaultPyEncoding())
90 self.SetTextRaw(text)
91
92
93 def GetTextUTF8(self):
94 """
95 Retrieve all the text in the document as UTF8. In an ansi build
96 of wxPython the text retrieved from the document is assumed to be
97 in the current default encoding.
98 """
99 text = self.GetTextRaw()
100 if not wx.USE_UNICODE:
101 u = text.decode(wx.GetDefaultPyEncoding())
102 text = u.encode('utf-8')
103 return text
104
105
106 def AppendTextUTF8(self, text):
107 """
108 Append a UTF8 string to the end of the document without changing
109 the selection. Works 'natively' in a unicode build of wxPython,
110 and will also work in an ansi build if the UTF8 text is compatible
111 with the current encoding.
112 """
113 if not wx.USE_UNICODE:
114 u = text.decode('utf-8')
115 text = u.encode(wx.GetDefaultPyEncoding())
116 self.AppendTextRaw(text)
117