QScintilla/TypingCompleters/CompleterPython.py

branch
Py2 comp.
changeset 3060
5883ce99ee12
parent 3057
10516539f238
parent 3039
8dd0165d805d
child 3145
a9de05d4a22f
equal deleted inserted replaced
3058:0a02c433f52d 3060:5883ce99ee12
236 while ifLine >= 0: 236 while ifLine >= 0:
237 txt = self.editor.text(ifLine) 237 txt = self.editor.text(ifLine)
238 edInd = self.editor.indentation(ifLine) 238 edInd = self.editor.indentation(ifLine)
239 if self.__elseRX.indexIn(txt) == 0 and edInd <= indentation: 239 if self.__elseRX.indexIn(txt) == 0 and edInd <= indentation:
240 indentation = edInd - 1 240 indentation = edInd - 1
241 elif (self.__ifRX.indexIn(txt) == 0 or \ 241 elif (self.__ifRX.indexIn(txt) == 0 or
242 self.__elifRX.indexIn(txt) == 0) and edInd <= indentation: 242 self.__elifRX.indexIn(txt) == 0) and edInd <= indentation:
243 self.editor.cancelList() 243 self.editor.cancelList()
244 self.editor.setIndentation(line, edInd) 244 self.editor.setIndentation(line, edInd)
245 break 245 break
246 ifLine -= 1 246 ifLine -= 1
259 txt = self.editor.text(ifLine) 259 txt = self.editor.text(ifLine)
260 edInd = self.editor.indentation(ifLine) 260 edInd = self.editor.indentation(ifLine)
261 if self.__elseRX.indexIn(txt) == 0 and edInd <= indentation: 261 if self.__elseRX.indexIn(txt) == 0 and edInd <= indentation:
262 indentation = edInd - 1 262 indentation = edInd - 1
263 elif self.__elifRX.indexIn(txt) == 0 and \ 263 elif self.__elifRX.indexIn(txt) == 0 and \
264 edInd == indentation and \ 264 edInd == indentation and \
265 edInd == prevInd: 265 edInd == prevInd:
266 indentation = edInd - 1 266 indentation = edInd - 1
267 elif (self.__ifRX.indexIn(txt) == 0 or \ 267 elif (self.__ifRX.indexIn(txt) == 0 or
268 self.__whileRX.indexIn(txt) == 0 or \ 268 self.__whileRX.indexIn(txt) == 0 or
269 self.__forRX.indexIn(txt) == 0 or \ 269 self.__forRX.indexIn(txt) == 0 or
270 self.__tryRX.indexIn(txt) == 0) and \ 270 self.__tryRX.indexIn(txt) == 0) and \
271 edInd <= indentation: 271 edInd <= indentation:
272 self.editor.cancelList() 272 self.editor.cancelList()
273 self.editor.setIndentation(line, edInd) 273 self.editor.setIndentation(line, edInd)
274 break 274 break
275 ifLine -= 1 275 ifLine -= 1
276 276
285 indentation = self.editor.indentation(line) 285 indentation = self.editor.indentation(line)
286 tryLine = line - 1 286 tryLine = line - 1
287 while tryLine >= 0: 287 while tryLine >= 0:
288 txt = self.editor.text(tryLine) 288 txt = self.editor.text(tryLine)
289 edInd = self.editor.indentation(tryLine) 289 edInd = self.editor.indentation(tryLine)
290 if (self.__exceptcRX.indexIn(txt) == 0 or \ 290 if (self.__exceptcRX.indexIn(txt) == 0 or
291 self.__finallyRX.indexIn(txt) == 0) and edInd <= indentation: 291 self.__finallyRX.indexIn(txt) == 0) and \
292 edInd <= indentation:
292 indentation = edInd - 1 293 indentation = edInd - 1
293 elif (self.__exceptRX.indexIn(txt) == 0 or \ 294 elif (self.__exceptRX.indexIn(txt) == 0 or
294 self.__tryRX.indexIn(txt) == 0) and edInd <= indentation: 295 self.__tryRX.indexIn(txt) == 0) and edInd <= indentation:
295 self.editor.cancelList() 296 self.editor.cancelList()
296 self.editor.setIndentation(line, edInd) 297 self.editor.setIndentation(line, edInd)
297 break 298 break
298 tryLine -= 1 299 tryLine -= 1
307 tryLine = line - 1 308 tryLine = line - 1
308 while tryLine >= 0: 309 while tryLine >= 0:
309 txt = self.editor.text(tryLine) 310 txt = self.editor.text(tryLine)
310 edInd = self.editor.indentation(tryLine) 311 edInd = self.editor.indentation(tryLine)
311 if self.__py24StyleTry: 312 if self.__py24StyleTry:
312 if (self.__exceptcRX.indexIn(txt) == 0 or \ 313 if (self.__exceptcRX.indexIn(txt) == 0 or
313 self.__exceptRX.indexIn(txt) == 0 or \ 314 self.__exceptRX.indexIn(txt) == 0 or
314 self.__finallyRX.indexIn(txt) == 0) and \ 315 self.__finallyRX.indexIn(txt) == 0) and \
315 edInd <= indentation: 316 edInd <= indentation:
316 indentation = edInd - 1 317 indentation = edInd - 1
317 elif self.__tryRX.indexIn(txt) == 0 and edInd <= indentation: 318 elif self.__tryRX.indexIn(txt) == 0 and edInd <= indentation:
318 self.editor.cancelList() 319 self.editor.cancelList()
319 self.editor.setIndentation(line, edInd) 320 self.editor.setIndentation(line, edInd)
320 break 321 break
321 else: 322 else:
322 if self.__finallyRX.indexIn(txt) == 0 and edInd <= indentation: 323 if self.__finallyRX.indexIn(txt) == 0 and edInd <= indentation:
323 indentation = edInd - 1 324 indentation = edInd - 1
324 elif (self.__tryRX.indexIn(txt) == 0 or \ 325 elif (self.__tryRX.indexIn(txt) == 0 or
325 self.__exceptcRX.indexIn(txt) == 0 or \ 326 self.__exceptcRX.indexIn(txt) == 0 or
326 self.__exceptRX.indexIn(txt) == 0) and \ 327 self.__exceptRX.indexIn(txt) == 0) and \
327 edInd <= indentation: 328 edInd <= indentation:
328 self.editor.cancelList() 329 self.editor.cancelList()
329 self.editor.setIndentation(line, edInd) 330 self.editor.setIndentation(line, edInd)
330 break 331 break
362 line, col = self.editor.getCursorPosition() 363 line, col = self.editor.getCursorPosition()
363 indentation = self.editor.indentation(line) 364 indentation = self.editor.indentation(line)
364 curLine = line - 1 365 curLine = line - 1
365 while curLine >= 0: 366 while curLine >= 0:
366 txt = self.editor.text(curLine) 367 txt = self.editor.text(curLine)
367 if (self.__defSelfRX.indexIn(txt) == 0 or \ 368 if (self.__defSelfRX.indexIn(txt) == 0 or
368 self.__defClsRX.indexIn(txt) == 0) and \ 369 self.__defClsRX.indexIn(txt) == 0) and \
369 self.editor.indentation(curLine) == indentation: 370 self.editor.indentation(curLine) == indentation:
370 return True 371 return True
371 elif self.__classRX.indexIn(txt) == 0 and \ 372 elif self.__classRX.indexIn(txt) == 0 and \
372 self.editor.indentation(curLine) < indentation: 373 self.editor.indentation(curLine) < indentation:
373 return True 374 return True
374 elif self.__defRX.indexIn(txt) == 0 and \ 375 elif self.__defRX.indexIn(txt) == 0 and \
375 self.editor.indentation(curLine) <= indentation: 376 self.editor.indentation(curLine) <= indentation:
376 return False 377 return False
377 curLine -= 1 378 curLine -= 1
378 return False 379 return False
379 380
380 def __isClassMethodDef(self): 381 def __isClassMethodDef(self):

eric ide

mercurial