QScintilla/TypingCompleters/CompleterRuby.py

branch
Py2 comp.
changeset 3057
10516539f238
parent 2525
8b507a9a2d40
parent 3011
18292228c724
child 3145
a9de05d4a22f
equal deleted inserted replaced
3056:9986ec0e559a 3057:10516539f238
63 Public slot called to handle the user entering a character. 63 Public slot called to handle the user entering a character.
64 64
65 @param charNumber value of the character entered (integer) 65 @param charNumber value of the character entered (integer)
66 """ 66 """
67 char = chr(charNumber) 67 char = chr(charNumber)
68 if char not in ['(', ')', '{', '}', '[', ']', ',', "'", '"', '\n', ' ']: 68 if char not in ['(', ')', '{', '}', '[', ']', ',', "'", '"',
69 '\n', ' ']:
69 return # take the short route 70 return # take the short route
70 71
71 line, col = self.editor.getCursorPosition() 72 line, col = self.editor.getCursorPosition()
72 73
73 if self.__inComment(line, col) or \ 74 if self.__inComment(line, col) or \
157 self.editor.insert(' ' * (lastOpenIndex - col + 1)) 158 self.editor.insert(' ' * (lastOpenIndex - col + 1))
158 self.editor.setCursorPosition(line, lastOpenIndex + 1) 159 self.editor.setCursorPosition(line, lastOpenIndex + 1)
159 160
160 def __inComment(self, line, col): 161 def __inComment(self, line, col):
161 """ 162 """
162 Private method to check, if the cursor is inside a comment 163 Private method to check, if the cursor is inside a comment.
163 164
164 @param line current line (integer) 165 @param line current line (integer)
165 @param col current position within line (integer) 166 @param col current position within line (integer)
166 @return flag indicating, if the cursor is inside a comment (boolean) 167 @return flag indicating, if the cursor is inside a comment (boolean)
167 """ 168 """
174 col -= 1 175 col -= 1
175 return False 176 return False
176 177
177 def __inDoubleQuotedString(self): 178 def __inDoubleQuotedString(self):
178 """ 179 """
179 Private method to check, if the cursor is within a double quoted string. 180 Private method to check, if the cursor is within a double quoted
181 string.
180 182
181 @return flag indicating, if the cursor is inside a double 183 @return flag indicating, if the cursor is inside a double
182 quoted string (boolean) 184 quoted string (boolean)
183 """ 185 """
184 return self.editor.currentStyle() == QsciLexerRuby.DoubleQuotedString 186 return self.editor.currentStyle() == QsciLexerRuby.DoubleQuotedString
185 187
186 def __inSingleQuotedString(self): 188 def __inSingleQuotedString(self):
187 """ 189 """
188 Private method to check, if the cursor is within a single quoted string. 190 Private method to check, if the cursor is within a single quoted
191 string.
189 192
190 @return flag indicating, if the cursor is inside a single 193 @return flag indicating, if the cursor is inside a single
191 quoted string (boolean) 194 quoted string (boolean)
192 """ 195 """
193 return self.editor.currentStyle() == QsciLexerRuby.SingleQuotedString 196 return self.editor.currentStyle() == QsciLexerRuby.SingleQuotedString
194 197
195 def __inHereDocument(self): 198 def __inHereDocument(self):
196 """ 199 """
197 Private method to check, if the cursor is within a here document. 200 Private method to check, if the cursor is within a here document.
198 201
199 @return flag indicating, if the cursor is inside a here document (boolean) 202 @return flag indicating, if the cursor is inside a here document
203 (boolean)
200 """ 204 """
201 return self.editor.currentStyle() == QsciLexerRuby.HereDocument 205 return self.editor.currentStyle() == QsciLexerRuby.HereDocument
202 206
203 def __inInlineDocument(self): 207 def __inInlineDocument(self):
204 """ 208 """
205 Private method to check, if the cursor is within an inline document. 209 Private method to check, if the cursor is within an inline document.
206 210
207 @return flag indicating, if the cursor is inside an inline document (boolean) 211 @return flag indicating, if the cursor is inside an inline document
212 (boolean)
208 """ 213 """
209 return self.editor.currentStyle() == QsciLexerRuby.POD 214 return self.editor.currentStyle() == QsciLexerRuby.POD

eric ide

mercurial