3331 Preferences.getEditorColour("SpellingMarkers")) |
3331 Preferences.getEditorColour("SpellingMarkers")) |
3332 self.__setSpelling() |
3332 self.__setSpelling() |
3333 |
3333 |
3334 self.setCursorFlashTime(QApplication.cursorFlashTime()) |
3334 self.setCursorFlashTime(QApplication.cursorFlashTime()) |
3335 |
3335 |
|
3336 try: |
|
3337 if Preferences.getEditor("AnnotationsEnabled"): |
|
3338 self.setAnnotationDisplay(QsciScintilla.AnnotationBoxed) |
|
3339 else: |
|
3340 self.setAnnotationDisplay(QsciScintilla.AnnotationHidden) |
|
3341 except AttributeError: |
|
3342 pass |
|
3343 |
3336 def __setEolMode(self): |
3344 def __setEolMode(self): |
3337 """ |
3345 """ |
3338 Private method to configure the eol mode of the editor. |
3346 Private method to configure the eol mode of the editor. |
3339 """ |
3347 """ |
3340 if self.fileName and \ |
3348 if self.fileName and \ |
4355 if self.markerLine(handle) == line - 1: |
4363 if self.markerLine(handle) == line - 1: |
4356 del self.syntaxerrors[handle] |
4364 del self.syntaxerrors[handle] |
4357 self.markerDeleteHandle(handle) |
4365 self.markerDeleteHandle(handle) |
4358 self.syntaxerrorToggled.emit(self) |
4366 self.syntaxerrorToggled.emit(self) |
4359 |
4367 |
|
4368 self.__setAnnotation(line - 1) |
|
4369 |
4360 def getSyntaxErrors(self): |
4370 def getSyntaxErrors(self): |
4361 """ |
4371 """ |
4362 Public method to retrieve the syntax error markers. |
4372 Public method to retrieve the syntax error markers. |
4363 |
4373 |
4364 @return sorted list of all lines containing a syntax error |
4374 @return sorted list of all lines containing a syntax error |
4448 for handle in list(self.warnings.keys()): |
4458 for handle in list(self.warnings.keys()): |
4449 if self.markerLine(handle) == line - 1: |
4459 if self.markerLine(handle) == line - 1: |
4450 del self.warnings[handle] |
4460 del self.warnings[handle] |
4451 self.markerDeleteHandle(handle) |
4461 self.markerDeleteHandle(handle) |
4452 self.syntaxerrorToggled.emit(self) |
4462 self.syntaxerrorToggled.emit(self) |
|
4463 |
|
4464 self.__setAnnotation(line - 1) |
4453 |
4465 |
4454 def getFlakesWarnings(self): |
4466 def getFlakesWarnings(self): |
4455 """ |
4467 """ |
4456 Public method to retrieve the flakes warning markers. |
4468 Public method to retrieve the flakes warning markers. |
4457 |
4469 |
4510 def clearFlakesWarnings(self): |
4522 def clearFlakesWarnings(self): |
4511 """ |
4523 """ |
4512 Public slot to handle the 'Clear all warnings' context menu action. |
4524 Public slot to handle the 'Clear all warnings' context menu action. |
4513 """ |
4525 """ |
4514 for handle in self.warnings: |
4526 for handle in self.warnings: |
|
4527 self.warnings[handle] = [] |
|
4528 self.__setAnnotation(self.markerLine(handle)) |
4515 self.markerDeleteHandle(handle) |
4529 self.markerDeleteHandle(handle) |
4516 self.warnings = {} |
4530 self.warnings = {} |
4517 self.syntaxerrorToggled.emit(self) |
4531 self.syntaxerrorToggled.emit(self) |
4518 |
4532 |
4519 def __showFlakesWarning(self, line = -1): |
4533 def __showFlakesWarning(self, line = -1): |
4533 break |
4547 break |
4534 else: |
4548 else: |
4535 E5MessageBox.warning(self, |
4549 E5MessageBox.warning(self, |
4536 self.trUtf8("py3flakes Warning"), |
4550 self.trUtf8("py3flakes Warning"), |
4537 self.trUtf8("No py3flakes warning message available.")) |
4551 self.trUtf8("No py3flakes warning message available.")) |
|
4552 |
|
4553 ############################################################################ |
|
4554 ## Annotation handling methods below |
|
4555 ############################################################################ |
|
4556 |
|
4557 def __setAnnotation(self, line): |
|
4558 """ |
|
4559 Private method to set the annotations for the given line. |
|
4560 |
|
4561 @param line number of the line that needs annotation (integer) |
|
4562 """ |
|
4563 if hasattr(QsciScintilla, "annotate"): |
|
4564 annotations = [] |
|
4565 |
|
4566 # step 1: do py3flakes warnings |
|
4567 for handle in list(self.warnings.keys()): |
|
4568 if self.markerLine(handle) == line: |
|
4569 annotations.extend(self.warnings[handle]) |
|
4570 |
|
4571 # step 2: do syntax errors |
|
4572 for handle in list(self.syntaxerrors.keys()): |
|
4573 if self.markerLine(handle) == line: |
|
4574 annotations.append(self.syntaxerrors[handle]) |
|
4575 |
|
4576 if annotations: |
|
4577 # TODO: convert to list of styled text |
|
4578 self.annotate(line, "\n".join(annotations), 0) |
|
4579 else: |
|
4580 self.clearAnnotations(line) |
4538 |
4581 |
4539 ################################################################# |
4582 ################################################################# |
4540 ## Macro handling methods |
4583 ## Macro handling methods |
4541 ################################################################# |
4584 ################################################################# |
4542 |
4585 |