23 |
23 |
24 def __init__(self, editor, parent=None): |
24 def __init__(self, editor, parent=None): |
25 """ |
25 """ |
26 Constructor |
26 Constructor |
27 |
27 |
28 @param editor reference to the editor object (QScintilla.Editor) |
28 @param editor reference to the editor object |
29 @param parent reference to the parent object (QObject) |
29 @type QScintilla.Editor |
|
30 @param parent reference to the parent object |
|
31 @type QObject |
30 """ |
32 """ |
31 super().__init__(editor, parent) |
33 super().__init__(editor, parent) |
32 |
34 |
33 self.__beginRX = re.compile(r"""^=begin """) |
35 self.__beginRX = re.compile(r"""^=begin """) |
34 self.__beginNlRX = re.compile(r"""^=begin\r?\n""") |
36 self.__beginNlRX = re.compile(r"""^=begin\r?\n""") |
55 |
57 |
56 def charAdded(self, charNumber): |
58 def charAdded(self, charNumber): |
57 """ |
59 """ |
58 Public slot called to handle the user entering a character. |
60 Public slot called to handle the user entering a character. |
59 |
61 |
60 @param charNumber value of the character entered (integer) |
62 @param charNumber value of the character entered |
|
63 @type int |
61 """ |
64 """ |
62 char = chr(charNumber) |
65 char = chr(charNumber) |
63 if char not in ["(", ")", "{", "}", "[", "]", ",", "'", '"', "\n", " "]: |
66 if char not in ["(", ")", "{", "}", "[", "]", ",", "'", '"', "\n", " "]: |
64 return # take the short route |
67 return # take the short route |
65 |
68 |
183 |
186 |
184 def __inComment(self, line, col): |
187 def __inComment(self, line, col): |
185 """ |
188 """ |
186 Private method to check, if the cursor is inside a comment. |
189 Private method to check, if the cursor is inside a comment. |
187 |
190 |
188 @param line current line (integer) |
191 @param line current line |
189 @param col current position within line (integer) |
192 @type int |
190 @return flag indicating, if the cursor is inside a comment (boolean) |
193 @param col current position within line |
|
194 @type int |
|
195 @return flag indicating, if the cursor is inside a comment |
|
196 @rtype bool |
191 """ |
197 """ |
192 txt = self.editor.text(line) |
198 txt = self.editor.text(line) |
193 if col == len(txt): |
199 if col == len(txt): |
194 col -= 1 |
200 col -= 1 |
195 while col >= 0: |
201 while col >= 0: |
202 """ |
208 """ |
203 Private method to check, if the cursor is within a double quoted |
209 Private method to check, if the cursor is within a double quoted |
204 string. |
210 string. |
205 |
211 |
206 @return flag indicating, if the cursor is inside a double |
212 @return flag indicating, if the cursor is inside a double |
207 quoted string (boolean) |
213 quoted string |
|
214 @rtype bool |
208 """ |
215 """ |
209 return self.editor.currentStyle() == QsciLexerRuby.DoubleQuotedString |
216 return self.editor.currentStyle() == QsciLexerRuby.DoubleQuotedString |
210 |
217 |
211 def __inSingleQuotedString(self): |
218 def __inSingleQuotedString(self): |
212 """ |
219 """ |
213 Private method to check, if the cursor is within a single quoted |
220 Private method to check, if the cursor is within a single quoted |
214 string. |
221 string. |
215 |
222 |
216 @return flag indicating, if the cursor is inside a single |
223 @return flag indicating, if the cursor is inside a single |
217 quoted string (boolean) |
224 quoted string |
|
225 @rtype bool |
218 """ |
226 """ |
219 return self.editor.currentStyle() == QsciLexerRuby.SingleQuotedString |
227 return self.editor.currentStyle() == QsciLexerRuby.SingleQuotedString |
220 |
228 |
221 def __inHereDocument(self): |
229 def __inHereDocument(self): |
222 """ |
230 """ |
223 Private method to check, if the cursor is within a here document. |
231 Private method to check, if the cursor is within a here document. |
224 |
232 |
225 @return flag indicating, if the cursor is inside a here document |
233 @return flag indicating, if the cursor is inside a here document |
226 (boolean) |
234 @rtype bool |
227 """ |
235 """ |
228 return self.editor.currentStyle() == QsciLexerRuby.HereDocument |
236 return self.editor.currentStyle() == QsciLexerRuby.HereDocument |
229 |
237 |
230 def __inInlineDocument(self): |
238 def __inInlineDocument(self): |
231 """ |
239 """ |
232 Private method to check, if the cursor is within an inline document. |
240 Private method to check, if the cursor is within an inline document. |
233 |
241 |
234 @return flag indicating, if the cursor is inside an inline document |
242 @return flag indicating, if the cursor is inside an inline document |
235 (boolean) |
243 @rtype bool |
236 """ |
244 """ |
237 return self.editor.currentStyle() == QsciLexerRuby.POD |
245 return self.editor.currentStyle() == QsciLexerRuby.POD |
238 |
246 |
239 |
247 |
240 def createCompleter(editor, parent=None): |
248 def createCompleter(editor, parent=None): |