--- a/QScintilla/Editor.py Wed Nov 13 23:30:59 2013 +0100 +++ b/QScintilla/Editor.py Sat Nov 16 10:06:28 2013 +0100 @@ -1041,16 +1041,16 @@ self.indicMarginMenu.addSeparator() self.marginMenuActs["NextWarningMarker"] = \ self.indicMarginMenu.addAction( - self.trUtf8("Next warning"), self.nextFlakesWarning) + self.trUtf8("Next warning"), self.nextWarning) self.marginMenuActs["PreviousWarningMarker"] = \ self.indicMarginMenu.addAction( - self.trUtf8("Previous warning"), self.previousFlakesWarning) + self.trUtf8("Previous warning"), self.previousWarning) self.marginMenuActs["ShowWarning"] = \ self.indicMarginMenu.addAction( - self.trUtf8('Show warning message'), self.__showFlakesWarning) + self.trUtf8('Show warning message'), self.__showWarning) self.marginMenuActs["ClearWarnings"] = \ self.indicMarginMenu.addAction( - self.trUtf8('Clear warnings'), self.clearFlakesWarnings) + self.trUtf8('Clear warnings'), self.clearWarnings) self.indicMarginMenu.addSeparator() self.marginMenuActs["NextCoverageMarker"] = \ self.indicMarginMenu.addAction( @@ -1098,14 +1098,14 @@ self.trUtf8('Clear syntax error'), self.clearSyntaxError) self.marginMenu.addSeparator() self.marginMenuActs["NextWarningMarker"] = self.marginMenu.addAction( - self.trUtf8("Next warning"), self.nextFlakesWarning) + self.trUtf8("Next warning"), self.nextWarning) self.marginMenuActs["PreviousWarningMarker"] = \ self.marginMenu.addAction( - self.trUtf8("Previous warning"), self.previousFlakesWarning) + self.trUtf8("Previous warning"), self.previousWarning) self.marginMenuActs["ShowWarning"] = self.marginMenu.addAction( - self.trUtf8('Show warning message'), self.__showFlakesWarning) + self.trUtf8('Show warning message'), self.__showWarning) self.marginMenuActs["ClearWarnings"] = self.marginMenu.addAction( - self.trUtf8('Clear warnings'), self.clearFlakesWarnings) + self.trUtf8('Clear warnings'), self.clearWarnings) self.marginMenu.addSeparator() self.marginMenuActs["Breakpoint"] = self.marginMenu.addAction( self.trUtf8('Toggle breakpoint'), self.menuToggleBreakpoint) @@ -3047,7 +3047,7 @@ if self.markersAtLine(line) & (1 << self.syntaxerror): self.__showSyntaxError(line) elif self.markersAtLine(line) & (1 << self.warning): - self.__showFlakesWarning(line) + self.__showWarning(line) else: if self.marginMenuActs["LMBbreakpoints"].isChecked(): self.__toggleBreakpoint(line + 1) @@ -3062,7 +3062,7 @@ if self.markersAtLine(line) & (1 << self.syntaxerror): self.__showSyntaxError(line) elif self.markersAtLine(line) & (1 << self.warning): - self.__showFlakesWarning(line) + self.__showWarning(line) def handleMonospacedEnable(self): """ @@ -4063,6 +4063,8 @@ self.setCaretLineBackgroundColor( Preferences.getEditorColour("CaretLineBackground")) self.setCaretLineVisible(Preferences.getEditor("CaretLineVisible")) + self.setCaretLineAlwaysVisible( + Preferences.getEditor("CaretLineAlwaysVisible")) self.caretWidth = Preferences.getEditor("CaretWidth") self.setCaretWidth(self.caretWidth) self.useMonospaced = Preferences.getEditor("UseMonospacedFont") @@ -4961,8 +4963,8 @@ self.toggleSyntaxError(errorline, errorindex, True, _error) else: for warning in warnings: - self.toggleFlakesWarning( - warning[2], True, warning[3]) + self.toggleWarning( + warning[2], True, warning[3]) def __initOnlineSyntaxCheck(self): """ @@ -5344,17 +5346,16 @@ self.trUtf8("No syntax error message available.")) ########################################################################### - ## Flakes warning handling methods below + ## Warning handling methods below ########################################################################### - def toggleFlakesWarning(self, line, warning, msg="", - warningType=WarningCode): - """ - Public method to toggle a flakes warning indicator. - - Note: This method is used to set code style warnings as well. - - @param line line number of the flakes warning + def toggleWarning(self, line, warning, msg="", warningType=WarningCode): + """ + Public method to toggle a warning indicator. + + Note: This method is used to set pyflakes and code style warnings. + + @param line line number of the warning @param warning flag indicating if the warning marker should be set or deleted (boolean) @param msg warning message (string) @@ -5364,7 +5365,7 @@ line = 1 # hack to show a warning marker, if line is reported to be 0 if warning: - # set/ammend a new warning marker + # set/amend a new warning marker warn = (msg, warningType) markers = self.markersAtLine(line - 1) if not (markers & (1 << self.warning)): @@ -5385,11 +5386,11 @@ self.__setAnnotation(line - 1) - def getFlakesWarnings(self): - """ - Public method to retrieve the flakes warning markers. - - @return sorted list of all lines containing a flakes warning + def getWarnings(self): + """ + Public method to retrieve the warning markers. + + @return sorted list of all lines containing a warning (list of integer) """ fwlist = [] @@ -5399,15 +5400,15 @@ fwlist.sort() return fwlist - def hasFlakesWarnings(self): - """ - Public method to check for the presence of flakes warnings. - - @return flag indicating the presence of flakes warnings (boolean) + def hasWarnings(self): + """ + Public method to check for the presence of warnings. + + @return flag indicating the presence of warnings (boolean) """ return len(self.warnings) > 0 - def nextFlakesWarning(self): + def nextWarning(self): """ Public slot to handle the 'Next warning' context menu action. """ @@ -5424,7 +5425,7 @@ self.setCursorPosition(fwline, 0) self.ensureLineVisible(fwline) - def previousFlakesWarning(self): + def previousWarning(self): """ Public slot to handle the 'Previous warning' context menu action. """ @@ -5444,7 +5445,45 @@ def clearFlakesWarnings(self): """ - Public slot to handle the 'Clear all warnings' context menu action. + Public slot to clear all pyflakes warnings. + """ + self.__clearTypedWarning(Editor.WarningCode) + + def clearStyleWarnings(self): + """ + Public slot to clear all style warnings. + """ + self.__clearTypedWarning(Editor.WarningStyle) + + def __clearTypedWarning(self, warningKind): + """ + Public method to clear warnings of a specific kind. + + @param warningKind kind of warning to clear (Editor.WarningCode, + Editor.WarningStyle) + """ + assert warningKind in [Editor.WarningCode, Editor.WarningStyle] + + for handle in list(self.warnings.keys()): + warnings = [] + for msg, warningType in self.warnings[handle]: + if warningType == warningKind: + continue + + warnings.append((msg, warningType)) + + if warnings: + self.warnings[handle] = warnings + self.__setAnnotation(self.markerLine(handle)) + else: + del self.warnings[handle] + self.__setAnnotation(self.markerLine(handle)) + self.markerDeleteHandle(handle) + self.syntaxerrorToggled.emit(self) + + def clearWarnings(self): + """ + Public slot to clear all warnings. """ for handle in self.warnings: self.warnings[handle] = [] @@ -5453,11 +5492,11 @@ self.warnings = {} self.syntaxerrorToggled.emit(self) - def __showFlakesWarning(self, line=-1): + def __showWarning(self, line=-1): """ Private slot to handle the 'Show warning' context menu action. - @param line line number to show the flakes warning for (integer) + @param line line number to show the warning for (integer) """ if line == -1: line = self.line @@ -5527,7 +5566,7 @@ styleAnnotations = [] # step 1: do warnings - for handle in list(self.warnings.keys()): + for handle in self.warnings.keys(): if self.markerLine(handle) == line: for msg, warningType in self.warnings[handle]: if warningType == self.WarningStyle: @@ -5538,7 +5577,7 @@ self.trUtf8("Warning: {0}").format(msg)) # step 2: do syntax errors - for handle in list(self.syntaxerrors.keys()): + for handle in self.syntaxerrors.keys(): if self.markerLine(handle) == line: for msg, _ in self.syntaxerrors[handle]: errorAnnotations.append( @@ -6029,7 +6068,7 @@ self.clearSyntaxError() # clear flakes warning markers - self.clearFlakesWarnings() + self.clearWarnings() # clear breakpoint markers for handle in list(self.breaks.keys()): @@ -6959,6 +6998,7 @@ @param forward flag indicating the search direction (boolean) """ + self.hideFindIndicator() line, index = self.getCursorPosition() word = self.getCurrentWord() wordStart, wordEnd = self.getCurrentWordBoundaries() @@ -6989,6 +7029,8 @@ match = matches[-1] line, index = self.lineIndexFromPosition(match.start()) self.setSelection(line, index + len(match.group(0)), line, index) + self.showFindIndicator(line, index, + line, index + len(match.group(0))) ####################################################################### ## Sort related methods