Wed, 11 Sep 2013 19:17:57 +0200
Added capability to have different warning styles to the editor.
--- a/APIs/Python3/eric5.api Tue Sep 10 19:45:37 2013 +0200 +++ b/APIs/Python3/eric5.api Wed Sep 11 19:17:57 2013 +0200 @@ -5814,6 +5814,8 @@ eric5.Preferences.ConfigurationPages.EditorSpellCheckingPage.create?4(dlg) eric5.Preferences.ConfigurationPages.EditorStylesPage.EditorStylesPage.on_annotationsErrorBgButton_clicked?4() eric5.Preferences.ConfigurationPages.EditorStylesPage.EditorStylesPage.on_annotationsErrorFgButton_clicked?4() +eric5.Preferences.ConfigurationPages.EditorStylesPage.EditorStylesPage.on_annotationsStyleWarningBgButton_clicked?4() +eric5.Preferences.ConfigurationPages.EditorStylesPage.EditorStylesPage.on_annotationsStyleWarningFgButton_clicked?4() eric5.Preferences.ConfigurationPages.EditorStylesPage.EditorStylesPage.on_annotationsWarningBgButton_clicked?4() eric5.Preferences.ConfigurationPages.EditorStylesPage.EditorStylesPage.on_annotationsWarningFgButton_clicked?4() eric5.Preferences.ConfigurationPages.EditorStylesPage.EditorStylesPage.on_defaultFontButton_clicked?4() @@ -6631,6 +6633,8 @@ eric5.QScintilla.Editor.Editor.StartEditToken?7 eric5.QScintilla.Editor.Editor.SyncToken?7 eric5.QScintilla.Editor.Editor.TemplateImageID?7 +eric5.QScintilla.Editor.Editor.WarningCode?7 +eric5.QScintilla.Editor.Editor.WarningStyle?7 eric5.QScintilla.Editor.Editor.addClone?4(editor) eric5.QScintilla.Editor.Editor.addedToProject?4() eric5.QScintilla.Editor.Editor.autoComplete?4(auto=False, context=True) @@ -6804,7 +6808,7 @@ eric5.QScintilla.Editor.Editor.taskMarkersUpdated?7 eric5.QScintilla.Editor.Editor.toggleBookmark?4(line) eric5.QScintilla.Editor.Editor.toggleCommentBlock?4() -eric5.QScintilla.Editor.Editor.toggleFlakesWarning?4(line, warning, msg="") +eric5.QScintilla.Editor.Editor.toggleFlakesWarning?4(line, warning, msg="", warningType=WarningCode) eric5.QScintilla.Editor.Editor.toggleSyntaxError?4(line, index, error, msg="", show=False) eric5.QScintilla.Editor.Editor.uncommentLine?4() eric5.QScintilla.Editor.Editor.uncommentLineOrSelection?4()
--- a/Documentation/Help/source.qhp Tue Sep 10 19:45:37 2013 +0200 +++ b/Documentation/Help/source.qhp Wed Sep 11 19:17:57 2013 +0200 @@ -4430,6 +4430,8 @@ <keyword name="EditorStylesPage (Module)" id="EditorStylesPage (Module)" ref="eric5.Preferences.ConfigurationPages.EditorStylesPage.html" /> <keyword name="EditorStylesPage.on_annotationsErrorBgButton_clicked" id="EditorStylesPage.on_annotationsErrorBgButton_clicked" ref="eric5.Preferences.ConfigurationPages.EditorStylesPage.html#EditorStylesPage.on_annotationsErrorBgButton_clicked" /> <keyword name="EditorStylesPage.on_annotationsErrorFgButton_clicked" id="EditorStylesPage.on_annotationsErrorFgButton_clicked" ref="eric5.Preferences.ConfigurationPages.EditorStylesPage.html#EditorStylesPage.on_annotationsErrorFgButton_clicked" /> + <keyword name="EditorStylesPage.on_annotationsStyleWarningBgButton_clicked" id="EditorStylesPage.on_annotationsStyleWarningBgButton_clicked" ref="eric5.Preferences.ConfigurationPages.EditorStylesPage.html#EditorStylesPage.on_annotationsStyleWarningBgButton_clicked" /> + <keyword name="EditorStylesPage.on_annotationsStyleWarningFgButton_clicked" id="EditorStylesPage.on_annotationsStyleWarningFgButton_clicked" ref="eric5.Preferences.ConfigurationPages.EditorStylesPage.html#EditorStylesPage.on_annotationsStyleWarningFgButton_clicked" /> <keyword name="EditorStylesPage.on_annotationsWarningBgButton_clicked" id="EditorStylesPage.on_annotationsWarningBgButton_clicked" ref="eric5.Preferences.ConfigurationPages.EditorStylesPage.html#EditorStylesPage.on_annotationsWarningBgButton_clicked" /> <keyword name="EditorStylesPage.on_annotationsWarningFgButton_clicked" id="EditorStylesPage.on_annotationsWarningFgButton_clicked" ref="eric5.Preferences.ConfigurationPages.EditorStylesPage.html#EditorStylesPage.on_annotationsWarningFgButton_clicked" /> <keyword name="EditorStylesPage.on_defaultFontButton_clicked" id="EditorStylesPage.on_defaultFontButton_clicked" ref="eric5.Preferences.ConfigurationPages.EditorStylesPage.html#EditorStylesPage.on_defaultFontButton_clicked" />
--- a/Documentation/Source/eric5.Preferences.ConfigurationPages.EditorStylesPage.html Tue Sep 10 19:45:37 2013 +0200 +++ b/Documentation/Source/eric5.Preferences.ConfigurationPages.EditorStylesPage.html Wed Sep 11 19:17:57 2013 +0200 @@ -69,6 +69,12 @@ <td><a href="#EditorStylesPage.on_annotationsErrorFgButton_clicked">on_annotationsErrorFgButton_clicked</a></td> <td>Private slot to set the foreground colour of the error annotations.</td> </tr><tr> +<td><a href="#EditorStylesPage.on_annotationsStyleWarningBgButton_clicked">on_annotationsStyleWarningBgButton_clicked</a></td> +<td>Private slot to set the background colour of the style annotations.</td> +</tr><tr> +<td><a href="#EditorStylesPage.on_annotationsStyleWarningFgButton_clicked">on_annotationsStyleWarningFgButton_clicked</a></td> +<td>Private slot to set the foreground colour of the style annotations.</td> +</tr><tr> <td><a href="#EditorStylesPage.on_annotationsWarningBgButton_clicked">on_annotationsWarningBgButton_clicked</a></td> <td>Private slot to set the background colour of the warning annotations.</td> </tr><tr> @@ -110,6 +116,16 @@ <b>on_annotationsErrorFgButton_clicked</b>(<i></i>) <p> Private slot to set the foreground colour of the error annotations. +</p><a NAME="EditorStylesPage.on_annotationsStyleWarningBgButton_clicked" ID="EditorStylesPage.on_annotationsStyleWarningBgButton_clicked"></a> +<h4>EditorStylesPage.on_annotationsStyleWarningBgButton_clicked</h4> +<b>on_annotationsStyleWarningBgButton_clicked</b>(<i></i>) +<p> + Private slot to set the background colour of the style annotations. +</p><a NAME="EditorStylesPage.on_annotationsStyleWarningFgButton_clicked" ID="EditorStylesPage.on_annotationsStyleWarningFgButton_clicked"></a> +<h4>EditorStylesPage.on_annotationsStyleWarningFgButton_clicked</h4> +<b>on_annotationsStyleWarningFgButton_clicked</b>(<i></i>) +<p> + Private slot to set the foreground colour of the style annotations. </p><a NAME="EditorStylesPage.on_annotationsWarningBgButton_clicked" ID="EditorStylesPage.on_annotationsWarningBgButton_clicked"></a> <h4>EditorStylesPage.on_annotationsWarningBgButton_clicked</h4> <b>on_annotationsWarningBgButton_clicked</b>(<i></i>) @@ -134,7 +150,8 @@ <h4>EditorStylesPage.on_monospacedFontButton_clicked</h4> <b>on_monospacedFontButton_clicked</b>(<i></i>) <p> - Private method used to select the font to be used as the monospaced font. + Private method used to select the font to be used as the monospaced + font. </p><a NAME="EditorStylesPage.polishPage" ID="EditorStylesPage.polishPage"></a> <h4>EditorStylesPage.polishPage</h4> <b>polishPage</b>(<i></i>)
--- a/Documentation/Source/eric5.QScintilla.Editor.html Tue Sep 10 19:45:37 2013 +0200 +++ b/Documentation/Source/eric5.QScintilla.Editor.html Wed Sep 11 19:17:57 2013 +0200 @@ -131,7 +131,7 @@ QsciScintillaCompat <h3>Class Attributes</h3> <table> -<tr><td>AttributeID</td></tr><tr><td>AttributePrivateID</td></tr><tr><td>AttributeProtectedID</td></tr><tr><td>CancelEditToken</td></tr><tr><td>ClassID</td></tr><tr><td>ClassPrivateID</td></tr><tr><td>ClassProtectedID</td></tr><tr><td>EndEditToken</td></tr><tr><td>EnumID</td></tr><tr><td>FromDocumentID</td></tr><tr><td>MethodID</td></tr><tr><td>MethodPrivateID</td></tr><tr><td>MethodProtectedID</td></tr><tr><td>RequestSyncToken</td></tr><tr><td>Separator</td></tr><tr><td>StartEditToken</td></tr><tr><td>SyncToken</td></tr><tr><td>TemplateImageID</td></tr> +<tr><td>AttributeID</td></tr><tr><td>AttributePrivateID</td></tr><tr><td>AttributeProtectedID</td></tr><tr><td>CancelEditToken</td></tr><tr><td>ClassID</td></tr><tr><td>ClassPrivateID</td></tr><tr><td>ClassProtectedID</td></tr><tr><td>EndEditToken</td></tr><tr><td>EnumID</td></tr><tr><td>FromDocumentID</td></tr><tr><td>MethodID</td></tr><tr><td>MethodPrivateID</td></tr><tr><td>MethodProtectedID</td></tr><tr><td>RequestSyncToken</td></tr><tr><td>Separator</td></tr><tr><td>StartEditToken</td></tr><tr><td>SyncToken</td></tr><tr><td>TemplateImageID</td></tr><tr><td>WarningCode</td></tr><tr><td>WarningStyle</td></tr> </table> <h3>Class Methods</h3> <table> @@ -3611,7 +3611,7 @@ The later works independent of the current selection. </p><a NAME="Editor.toggleFlakesWarning" ID="Editor.toggleFlakesWarning"></a> <h4>Editor.toggleFlakesWarning</h4> -<b>toggleFlakesWarning</b>(<i>line, warning, msg=""</i>) +<b>toggleFlakesWarning</b>(<i>line, warning, msg="", warningType=WarningCode</i>) <p> Public method to toggle a flakes warning indicator. </p><p> @@ -3627,6 +3627,9 @@ </dd><dt><i>msg</i></dt> <dd> warning message (string) +</dd><dt><i>warningType=</i></dt> +<dd> +type of warning message (integer) </dd> </dl><a NAME="Editor.toggleSyntaxError" ID="Editor.toggleSyntaxError"></a> <h4>Editor.toggleSyntaxError</h4>
--- a/Plugins/CheckerPlugins/Pep8/Pep8Dialog.py Tue Sep 10 19:45:37 2013 +0200 +++ b/Plugins/CheckerPlugins/Pep8/Pep8Dialog.py Wed Sep 11 19:17:57 2013 +0200 @@ -599,7 +599,8 @@ if code == "E901": editor.toggleSyntaxError(lineno, 0, True, message, True) else: - editor.toggleFlakesWarning(lineno, True, message) + editor.toggleFlakesWarning( + lineno, True, message, warningType=editor.WarningStyle) @pyqtSlot() def on_resultList_itemSelectionChanged(self):
--- a/Plugins/CheckerPlugins/Pep8/Pep8NamingChecker.py Tue Sep 10 19:45:37 2013 +0200 +++ b/Plugins/CheckerPlugins/Pep8/Pep8NamingChecker.py Wed Sep 11 19:17:57 2013 +0200 @@ -15,7 +15,6 @@ from PyQt4.QtCore import QT_TRANSLATE_NOOP, QCoreApplication -# TODO: port this to Py2 class Pep8NamingChecker(object): """ Class implementing a checker for PEP-8 naming conventions.
--- a/Preferences/ConfigurationPages/EditorStylesPage.py Tue Sep 10 19:45:37 2013 +0200 +++ b/Preferences/ConfigurationPages/EditorStylesPage.py Wed Sep 11 19:17:57 2013 +0200 @@ -29,7 +29,8 @@ self.setupUi(self) self.setObjectName("EditorStylesPage") - from QScintilla.QsciScintillaCompat import QsciScintillaCompat, QSCINTILLA_VERSION + from QScintilla.QsciScintillaCompat import ( + QsciScintillaCompat, QSCINTILLA_VERSION) self.foldStyles = [ QsciScintilla.PlainFoldStyle, QsciScintilla.CircledFoldStyle, @@ -46,18 +47,18 @@ QsciScintilla.EdgeBackground ] - self.wrapModeComboBox.addItem(self.trUtf8("Disabled"), - QsciScintilla.WrapNone) - self.wrapModeComboBox.addItem(self.trUtf8("Word Boundary"), - QsciScintilla.WrapWord) - self.wrapModeComboBox.addItem(self.trUtf8("Character Boundary"), - QsciScintilla.WrapCharacter) - self.wrapVisualComboBox.addItem(self.trUtf8("No Indicator"), - QsciScintilla.WrapFlagNone) - self.wrapVisualComboBox.addItem(self.trUtf8("Indicator by Text"), - QsciScintilla.WrapFlagByText) - self.wrapVisualComboBox.addItem(self.trUtf8("Indicator by Margin"), - QsciScintilla.WrapFlagByBorder) + self.wrapModeComboBox.addItem( + self.trUtf8("Disabled"), QsciScintilla.WrapNone) + self.wrapModeComboBox.addItem( + self.trUtf8("Word Boundary"), QsciScintilla.WrapWord) + self.wrapModeComboBox.addItem( + self.trUtf8("Character Boundary"), QsciScintilla.WrapCharacter) + self.wrapVisualComboBox.addItem( + self.trUtf8("No Indicator"), QsciScintilla.WrapFlagNone) + self.wrapVisualComboBox.addItem( + self.trUtf8("Indicator by Text"), QsciScintilla.WrapFlagByText) + self.wrapVisualComboBox.addItem( + self.trUtf8("Indicator by Margin"), QsciScintilla.WrapFlagByBorder) if QSCINTILLA_VERSION() >= 0x020700: self.wrapVisualComboBox.addItem( self.trUtf8("Indicator in Line Number Margin"), @@ -96,27 +97,30 @@ Preferences.getEditor("ExtendSelectionToEol")) self.initColour("CaretForeground", self.caretForegroundButton, - Preferences.getEditorColour) + Preferences.getEditorColour) self.initColour("CaretLineBackground", self.caretlineBackgroundButton, - Preferences.getEditorColour, hasAlpha=True) + Preferences.getEditorColour, hasAlpha=True) self.initColour("SelectionForeground", self.selectionForegroundButton, - Preferences.getEditorColour) + Preferences.getEditorColour) self.initColour("SelectionBackground", self.selectionBackgroundButton, - Preferences.getEditorColour, hasAlpha=True) + Preferences.getEditorColour, hasAlpha=True) self.initColour("CurrentMarker", self.currentLineMarkerButton, - Preferences.getEditorColour, hasAlpha=True) + Preferences.getEditorColour, hasAlpha=True) self.initColour("ErrorMarker", self.errorMarkerButton, - Preferences.getEditorColour, hasAlpha=True) + Preferences.getEditorColour, hasAlpha=True) self.initColour("MarginsForeground", self.marginsForegroundButton, - Preferences.getEditorColour) + Preferences.getEditorColour) self.initColour("MarginsBackground", self.marginsBackgroundButton, - Preferences.getEditorColour) - self.initColour("FoldmarginBackground", self.foldmarginBackgroundButton, - Preferences.getEditorColour) - self.initColour("FoldMarkersForeground", self.foldmarkersForegroundButton, - Preferences.getEditorColour) - self.initColour("FoldMarkersBackground", self.foldmarkersBackgroundButton, - Preferences.getEditorColour) + Preferences.getEditorColour) + self.initColour("FoldmarginBackground", + self.foldmarginBackgroundButton, + Preferences.getEditorColour) + self.initColour("FoldMarkersForeground", + self.foldmarkersForegroundButton, + Preferences.getEditorColour) + self.initColour("FoldMarkersBackground", + self.foldmarkersBackgroundButton, + Preferences.getEditorColour) self.editorColours = {} self.editorColours["AnnotationsWarningForeground"] = \ @@ -127,30 +131,37 @@ QColor(Preferences.getEditorColour("AnnotationsErrorForeground")) self.editorColours["AnnotationsErrorBackground"] = \ QColor(Preferences.getEditorColour("AnnotationsErrorBackground")) + self.editorColours["AnnotationsStyleForeground"] = \ + QColor(Preferences.getEditorColour("AnnotationsStyleForeground")) + self.editorColours["AnnotationsStyleBackground"] = \ + QColor(Preferences.getEditorColour("AnnotationsStyleBackground")) self.eolCheckBox.setChecked(Preferences.getEditor("ShowEOL")) self.wrapModeComboBox.setCurrentIndex(self.wrapModeComboBox.findData( Preferences.getEditor("WrapLongLinesMode"))) - self.wrapVisualComboBox.setCurrentIndex(self.wrapVisualComboBox.findData( - Preferences.getEditor("WrapVisualFlag"))) + self.wrapVisualComboBox.setCurrentIndex( + self.wrapVisualComboBox.findData( + Preferences.getEditor("WrapVisualFlag"))) self.edgeModeCombo.setCurrentIndex( self.edgeModes.index(Preferences.getEditor("EdgeMode"))) self.edgeLineColumnSlider.setValue( Preferences.getEditor("EdgeColumn")) - self.initColour("Edge", self.edgeBackgroundColorButton, + self.initColour( + "Edge", self.edgeBackgroundColorButton, Preferences.getEditorColour) self.bracehighlightingCheckBox.setChecked( Preferences.getEditor("BraceHighlighting")) self.initColour("MatchingBrace", self.matchingBracesButton, - Preferences.getEditorColour) + Preferences.getEditorColour) self.initColour("MatchingBraceBack", self.matchingBracesBackButton, - Preferences.getEditorColour) + Preferences.getEditorColour) self.initColour("NonmatchingBrace", self.nonmatchingBracesButton, - Preferences.getEditorColour) - self.initColour("NonmatchingBraceBack", self.nonmatchingBracesBackButton, - Preferences.getEditorColour) + Preferences.getEditorColour) + self.initColour("NonmatchingBraceBack", + self.nonmatchingBracesBackButton, + Preferences.getEditorColour) self.zoomfactorSlider.setValue( Preferences.getEditor("ZoomFactor")) @@ -159,10 +170,12 @@ Preferences.getEditor("ShowWhitespace")) self.whitespaceSizeSpinBox.setValue( Preferences.getEditor("WhitespaceSize")) - self.initColour("WhitespaceForeground", self.whitespaceForegroundButton, - Preferences.getEditorColour) - self.initColour("WhitespaceBackground", self.whitespaceBackgroundButton, - Preferences.getEditorColour) + self.initColour("WhitespaceForeground", + self.whitespaceForegroundButton, + Preferences.getEditorColour) + self.initColour("WhitespaceBackground", + self.whitespaceBackgroundButton, + Preferences.getEditorColour) if not hasattr(QsciScintilla, "setWhitespaceForegroundColor"): self.whitespaceSizeSpinBox.setEnabled(False) self.whitespaceForegroundButton.setEnabled(False) @@ -176,9 +189,11 @@ self.editAreaOverrideCheckBox.setChecked( Preferences.getEditor("OverrideEditAreaColours")) - self.initColour("EditAreaForeground", self.editAreaForegroundButton, + self.initColour( + "EditAreaForeground", self.editAreaForegroundButton, Preferences.getEditorColour) - self.initColour("EditAreaBackground", self.editAreaBackgroundButton, + self.initColour( + "EditAreaBackground", self.editAreaBackgroundButton, Preferences.getEditorColour) self.enableChangeTraceCheckBox.setChecked( @@ -186,77 +201,85 @@ self.changeTraceTimeoutSpinBox.setValue( Preferences.getEditor("OnlineChangeTraceInterval")) self.initColour("OnlineChangeTraceMarkerUnsaved", - self.changeMarkerUnsavedColorButton, - Preferences.getEditorColour) + self.changeMarkerUnsavedColorButton, + Preferences.getEditorColour) self.initColour("OnlineChangeTraceMarkerSaved", - self.changeMarkerSavedColorButton, - Preferences.getEditorColour) + self.changeMarkerSavedColorButton, + Preferences.getEditorColour) def save(self): """ Public slot to save the Editor Styles configuration. """ - Preferences.setEditor("FoldingStyle", + Preferences.setEditor( + "FoldingStyle", self.foldStyles[self.foldingStyleComboBox.currentIndex()]) - Preferences.setEditorOtherFonts("MarginsFont", self.marginsFont) - Preferences.setEditorOtherFonts("DefaultFont", self.defaultFont) - Preferences.setEditorOtherFonts("MonospacedFont", self.monospacedFont) - Preferences.setEditor("UseMonospacedFont", - self.monospacedCheckBox.isChecked()) + Preferences.setEditorOtherFonts( + "MarginsFont", self.marginsFont) + Preferences.setEditorOtherFonts( + "DefaultFont", self.defaultFont) + Preferences.setEditorOtherFonts( + "MonospacedFont", self.monospacedFont) + Preferences.setEditor( + "UseMonospacedFont", self.monospacedCheckBox.isChecked()) - Preferences.setEditor("LinenoMargin", - self.linenoCheckBox.isChecked()) - Preferences.setEditor("FoldingMargin", - self.foldingCheckBox.isChecked()) - Preferences.setEditor("UnifiedMargins", - self.unifiedMarginsCheckBox.isChecked()) + Preferences.setEditor( + "LinenoMargin", self.linenoCheckBox.isChecked()) + Preferences.setEditor( + "FoldingMargin", self.foldingCheckBox.isChecked()) + Preferences.setEditor( + "UnifiedMargins", self.unifiedMarginsCheckBox.isChecked()) - Preferences.setEditor("CaretLineVisible", - self.caretlineVisibleCheckBox.isChecked()) - Preferences.setEditor("ColourizeSelText", - self.colourizeSelTextCheckBox.isChecked()) - Preferences.setEditor("CustomSelectionColours", - self.customSelColourCheckBox.isChecked()) - Preferences.setEditor("ExtendSelectionToEol", - self.extentSelEolCheckBox.isChecked()) + Preferences.setEditor( + "CaretLineVisible", self.caretlineVisibleCheckBox.isChecked()) + Preferences.setEditor( + "ColourizeSelText", self.colourizeSelTextCheckBox.isChecked()) + Preferences.setEditor( + "CustomSelectionColours", self.customSelColourCheckBox.isChecked()) + Preferences.setEditor( + "ExtendSelectionToEol", self.extentSelEolCheckBox.isChecked()) - Preferences.setEditor("CaretWidth", - self.caretWidthSpinBox.value()) + Preferences.setEditor( + "CaretWidth", self.caretWidthSpinBox.value()) - Preferences.setEditor("ShowEOL", - self.eolCheckBox.isChecked()) - Preferences.setEditor("WrapLongLinesMode", - self.wrapModeComboBox.itemData(self.wrapModeComboBox.currentIndex())) - Preferences.setEditor("WrapVisualFlag", - self.wrapVisualComboBox.itemData(self.wrapVisualComboBox.currentIndex())) - Preferences.setEditor("EdgeMode", - self.edgeModes[self.edgeModeCombo.currentIndex()]) - Preferences.setEditor("EdgeColumn", - self.edgeLineColumnSlider.value()) + Preferences.setEditor( + "ShowEOL", self.eolCheckBox.isChecked()) + Preferences.setEditor( + "WrapLongLinesMode", self.wrapModeComboBox.itemData( + self.wrapModeComboBox.currentIndex())) + Preferences.setEditor( + "WrapVisualFlag", self.wrapVisualComboBox.itemData( + self.wrapVisualComboBox.currentIndex())) + Preferences.setEditor( + "EdgeMode", self.edgeModes[self.edgeModeCombo.currentIndex()]) + Preferences.setEditor( + "EdgeColumn", self.edgeLineColumnSlider.value()) - Preferences.setEditor("BraceHighlighting", - self.bracehighlightingCheckBox.isChecked()) + Preferences.setEditor( + "BraceHighlighting", self.bracehighlightingCheckBox.isChecked()) - Preferences.setEditor("ZoomFactor", - self.zoomfactorSlider.value()) + Preferences.setEditor( + "ZoomFactor", self.zoomfactorSlider.value()) - Preferences.setEditor("ShowWhitespace", - self.whitespaceCheckBox.isChecked()) - Preferences.setEditor("WhitespaceSize", - self.whitespaceSizeSpinBox.value()) + Preferences.setEditor( + "ShowWhitespace", self.whitespaceCheckBox.isChecked()) + Preferences.setEditor( + "WhitespaceSize", self.whitespaceSizeSpinBox.value()) - Preferences.setEditor("MiniContextMenu", - self.miniMenuCheckBox.isChecked()) + Preferences.setEditor( + "MiniContextMenu", self.miniMenuCheckBox.isChecked()) - Preferences.setEditor("AnnotationsEnabled", - self.enableAnnotationsCheckBox.isChecked()) + Preferences.setEditor( + "AnnotationsEnabled", self.enableAnnotationsCheckBox.isChecked()) - Preferences.setEditor("OverrideEditAreaColours", + Preferences.setEditor( + "OverrideEditAreaColours", self.editAreaOverrideCheckBox.isChecked()) - Preferences.setEditor("OnlineChangeTrace", - self.enableChangeTraceCheckBox.isChecked()) - Preferences.setEditor("OnlineChangeTraceInterval", + Preferences.setEditor( + "OnlineChangeTrace", self.enableChangeTraceCheckBox.isChecked()) + Preferences.setEditor( + "OnlineChangeTraceInterval", self.changeTraceTimeoutSpinBox.value()) self.saveColours(Preferences.setEditorColour) @@ -268,22 +291,25 @@ """ Private method used to select the font for the editor margins. """ - self.marginsFont = self.selectFont(self.marginsFontSample, self.marginsFont) + self.marginsFont = self.selectFont( + self.marginsFontSample, self.marginsFont) @pyqtSlot() def on_defaultFontButton_clicked(self): """ Private method used to select the default font for the editor. """ - self.defaultFont = self.selectFont(self.defaultFontSample, self.defaultFont) + self.defaultFont = self.selectFont( + self.defaultFontSample, self.defaultFont) @pyqtSlot() def on_monospacedFontButton_clicked(self): """ - Private method used to select the font to be used as the monospaced font. + Private method used to select the font to be used as the monospaced + font. """ - self.monospacedFont = \ - self.selectFont(self.monospacedFontSample, self.monospacedFont) + self.monospacedFont = self.selectFont( + self.monospacedFontSample, self.monospacedFont) def polishPage(self): """ @@ -294,23 +320,36 @@ self.monospacedFontSample.setFont(self.monospacedFont) pl = self.annotationsWarningSample.palette() - pl.setColor(QPalette.Text, self.editorColours["AnnotationsWarningForeground"]) - pl.setColor(QPalette.Base, self.editorColours["AnnotationsWarningBackground"]) + pl.setColor(QPalette.Text, + self.editorColours["AnnotationsWarningForeground"]) + pl.setColor(QPalette.Base, + self.editorColours["AnnotationsWarningBackground"]) self.annotationsWarningSample.setPalette(pl) self.annotationsWarningSample.repaint() pl = self.annotationsErrorSample.palette() - pl.setColor(QPalette.Text, self.editorColours["AnnotationsErrorForeground"]) - pl.setColor(QPalette.Base, self.editorColours["AnnotationsErrorBackground"]) + pl.setColor(QPalette.Text, + self.editorColours["AnnotationsErrorForeground"]) + pl.setColor(QPalette.Base, + self.editorColours["AnnotationsErrorBackground"]) self.annotationsErrorSample.setPalette(pl) self.annotationsErrorSample.repaint() + + pl = self.annotationsStyleWarningSample.palette() + pl.setColor(QPalette.Text, + self.editorColours["AnnotationsStyleForeground"]) + pl.setColor(QPalette.Base, + self.editorColours["AnnotationsStyleBackground"]) + self.annotationsStyleWarningSample.setPalette(pl) + self.annotationsStyleWarningSample.repaint() @pyqtSlot() def on_annotationsWarningFgButton_clicked(self): """ Private slot to set the foreground colour of the warning annotations. """ - colour = QColorDialog.getColor(self.editorColours["AnnotationsWarningForeground"]) + colour = QColorDialog.getColor( + self.editorColours["AnnotationsWarningForeground"]) if colour.isValid(): pl = self.annotationsWarningSample.palette() pl.setColor(QPalette.Text, colour) @@ -323,7 +362,8 @@ """ Private slot to set the background colour of the warning annotations. """ - colour = QColorDialog.getColor(self.editorColours["AnnotationsWarningBackground"]) + colour = QColorDialog.getColor( + self.editorColours["AnnotationsWarningBackground"]) if colour.isValid(): pl = self.annotationsWarningSample.palette() pl.setColor(QPalette.Base, colour) @@ -336,7 +376,8 @@ """ Private slot to set the foreground colour of the error annotations. """ - colour = QColorDialog.getColor(self.editorColours["AnnotationsErrorForeground"]) + colour = QColorDialog.getColor( + self.editorColours["AnnotationsErrorForeground"]) if colour.isValid(): pl = self.annotationsErrorSample.palette() pl.setColor(QPalette.Text, colour) @@ -349,13 +390,42 @@ """ Private slot to set the background colour of the error annotations. """ - colour = QColorDialog.getColor(self.editorColours["AnnotationsErrorBackground"]) + colour = QColorDialog.getColor( + self.editorColours["AnnotationsErrorBackground"]) if colour.isValid(): pl = self.annotationsErrorSample.palette() pl.setColor(QPalette.Base, colour) self.annotationsErrorSample.setPalette(pl) self.annotationsErrorSample.repaint() self.editorColours["AnnotationsErrorBackground"] = colour + + @pyqtSlot() + def on_annotationsStyleWarningFgButton_clicked(self): + """ + Private slot to set the foreground colour of the style annotations. + """ + colour = QColorDialog.getColor( + self.editorColours["AnnotationsStyleForeground"]) + if colour.isValid(): + pl = self.annotationsStyleWarningSample.palette() + pl.setColor(QPalette.Text, colour) + self.annotationsStyleWarningSample.setPalette(pl) + self.annotationsStyleWarningSample.repaint() + self.editorColours["AnnotationsStyleForeground"] = colour + + @pyqtSlot() + def on_annotationsStyleWarningBgButton_clicked(self): + """ + Private slot to set the background colour of the style annotations. + """ + colour = QColorDialog.getColor( + self.editorColours["AnnotationsStyleBackground"]) + if colour.isValid(): + pl = self.annotationsStyleWarningSample.palette() + pl.setColor(QPalette.Base, colour) + self.annotationsStyleWarningSample.setPalette(pl) + self.annotationsStyleWarningSample.repaint() + self.editorColours["AnnotationsStyleackground"] = colour def create(dlg):
--- a/Preferences/ConfigurationPages/EditorStylesPage.ui Tue Sep 10 19:45:37 2013 +0200 +++ b/Preferences/ConfigurationPages/EditorStylesPage.ui Wed Sep 11 19:17:57 2013 +0200 @@ -1130,7 +1130,7 @@ <property name="title"> <string>Annotations</string> </property> - <layout class="QGridLayout" name="gridLayout_5"> + <layout class="QGridLayout" name="gridLayout_8"> <item row="0" column="0" colspan="2"> <widget class="QCheckBox" name="enableAnnotationsCheckBox"> <property name="statusTip"> @@ -1173,7 +1173,7 @@ <enum>Qt::NoFocus</enum> </property> <property name="text"> - <string>Warning: There might be an error.</string> + <string>Warning: There might be an issue.</string> </property> <property name="alignment"> <set>Qt::AlignHCenter</set> @@ -1218,7 +1218,52 @@ <enum>Qt::NoFocus</enum> </property> <property name="text"> - <string>Error: There is an error.</string> + <string>Error: There is an issue.</string> + </property> + <property name="alignment"> + <set>Qt::AlignHCenter</set> + </property> + <property name="readOnly"> + <bool>true</bool> + </property> + </widget> + </item> + </layout> + </widget> + </item> + <item row="2" column="0"> + <widget class="QGroupBox" name="annotationsStyleWarningGroup"> + <property name="title"> + <string>Style</string> + </property> + <layout class="QGridLayout" name="gridLayout_5"> + <item row="0" column="0"> + <widget class="QPushButton" name="annotationsStyleWarningFgButton"> + <property name="toolTip"> + <string>Press to select the foreground colour</string> + </property> + <property name="text"> + <string>Foreground</string> + </property> + </widget> + </item> + <item row="0" column="1"> + <widget class="QPushButton" name="annotationsStyleWarningBgButton"> + <property name="toolTip"> + <string>Press to select the background colour</string> + </property> + <property name="text"> + <string>Background</string> + </property> + </widget> + </item> + <item row="1" column="0" colspan="2"> + <widget class="QLineEdit" name="annotationsStyleWarningSample"> + <property name="focusPolicy"> + <enum>Qt::NoFocus</enum> + </property> + <property name="text"> + <string>Style: There is a style issue.</string> </property> <property name="alignment"> <set>Qt::AlignHCenter</set> @@ -1543,6 +1588,8 @@ <tabstop>annotationsWarningBgButton</tabstop> <tabstop>annotationsErrorFgButton</tabstop> <tabstop>annotationsErrorBgButton</tabstop> + <tabstop>annotationsStyleWarningFgButton</tabstop> + <tabstop>annotationsStyleWarningBgButton</tabstop> <tabstop>enableChangeTraceCheckBox</tabstop> <tabstop>changeTraceTimeoutSpinBox</tabstop> <tabstop>changeMarkerUnsavedColorButton</tabstop>
--- a/Preferences/__init__.py Tue Sep 10 19:45:37 2013 +0200 +++ b/Preferences/__init__.py Wed Sep 11 19:17:57 2013 +0200 @@ -509,6 +509,8 @@ "AnnotationsWarningBackground": QColor("#ffffd0"), "AnnotationsErrorForeground": QColor("#600000"), "AnnotationsErrorBackground": QColor("#ffd0d0"), + "AnnotationsStyleForeground": QColor("#000060"), + "AnnotationsStyleBackground": QColor("#d0d0ff"), "WhitespaceForeground": QColor(Qt.darkGray), "WhitespaceBackground": QColor(Qt.white), "OnlineChangeTraceMarkerUnsaved": QColor("#ff8888"),
--- a/QScintilla/Editor.py Tue Sep 10 19:45:37 2013 +0200 +++ b/QScintilla/Editor.py Wed Sep 11 19:17:57 2013 +0200 @@ -95,6 +95,9 @@ lastEditPositionAvailable = pyqtSignal() refreshed = pyqtSignal() + WarningCode = 1 + WarningStyle = 2 + # Autocompletion icon definitions ClassID = 1 ClassProtectedID = 2 @@ -152,15 +155,19 @@ self.lastErrorMarker = None # remember the last error line self.lastCurrMarker = None # remember the last current line - self.breaks = {} # key: marker handle, - # value: (lineno, condition, temporary, - # enabled, ignorecount) - self.bookmarks = [] # bookmarks are just a list of handles to the - # bookmark markers - self.syntaxerrors = {} # key: marker handle - # value: list of (error message, error index) - self.warnings = {} # key: marker handle - # value: list of warning messages + self.breaks = {} + # key: marker handle, + # value: (lineno, condition, temporary, + # enabled, ignorecount) + self.bookmarks = [] + # bookmarks are just a list of handles to the + # bookmark markers + self.syntaxerrors = {} + # key: marker handle + # value: list of (error message, error index) + self.warnings = {} + # key: marker handle + # value: list of (warning message, warning type) self.notcoveredMarkers = [] # just a list of marker handles self.showingNotcoveredMarkers = False @@ -174,13 +181,20 @@ self.line = -1 self.inReopenPrompt = False # true if the prompt to reload a changed source is present - self.inFileRenamed = False # true if we are propagating a rename action - self.inLanguageChanged = False # true if we are propagating a language change - self.inEolChanged = False # true if we are propagating an eol change - self.inEncodingChanged = False # true if we are propagating an encoding change - self.inDragDrop = False # true if we are in drop mode - self.inLinesChanged = False # true if we are propagating a lines changed event - self.__hasTaskMarkers = False # no task markers present + self.inFileRenamed = False + # true if we are propagating a rename action + self.inLanguageChanged = False + # true if we are propagating a language change + self.inEolChanged = False + # true if we are propagating an eol change + self.inEncodingChanged = False + # true if we are propagating an encoding change + self.inDragDrop = False + # true if we are in drop mode + self.inLinesChanged = False + # true if we are propagating a lines changed event + self.__hasTaskMarkers = False + # no task markers present self.macros = {} # list of defined macros self.curMacro = None @@ -5199,8 +5213,8 @@ ## Flakes warning handling methods below ############################################################################ - # TODO: add flag for PEP-8 messages and record this flag in self.warnings - def toggleFlakesWarning(self, line, warning, msg=""): + def toggleFlakesWarning(self, line, warning, msg="", + warningType=WarningCode): """ Public method to toggle a flakes warning indicator. @@ -5210,22 +5224,24 @@ @param warning flag indicating if the warning marker should be set or deleted (boolean) @param msg warning message (string) + @keyparam warningType type of warning message (integer) """ if line == 0: line = 1 # hack to show a warning marker, if line is reported to be 0 if warning: # set/ammend a new warning marker + warn = (msg, warningType) markers = self.markersAtLine(line - 1) if not (markers & (1 << self.warning)): handle = self.markerAdd(line - 1, self.warning) - self.warnings[handle] = [msg] + self.warnings[handle] = [warn] self.syntaxerrorToggled.emit(self) else: for handle in list(self.warnings.keys()): if self.markerLine(handle) == line - 1 and \ - msg not in self.warnings[handle]: - self.warnings[handle].append(msg) + warn not in self.warnings[handle]: + self.warnings[handle].append(warn) else: for handle in list(self.warnings.keys()): if self.markerLine(handle) == line - 1: @@ -5314,19 +5330,18 @@ for handle in list(self.warnings.keys()): if self.markerLine(handle) == line: E5MessageBox.warning(self, - self.trUtf8("py3flakes Warning"), + self.trUtf8("Warning"), '\n'.join(self.warnings[handle])) break else: E5MessageBox.warning(self, - self.trUtf8("py3flakes Warning"), - self.trUtf8("No py3flakes warning message available.")) + self.trUtf8("Warning"), + self.trUtf8("No warning messages available.")) ############################################################################ ## Annotation handling methods below ############################################################################ - # TODO: add additional annotations style (green) for PEP-8 warnings def __setAnnotationStyles(self): """ Private slot to define the style used by inline annotations. @@ -5347,8 +5362,15 @@ self.SendScintilla(QsciScintilla.SCI_STYLESETBACK, self.annotationErrorStyle, Preferences.getEditorColour("AnnotationsErrorBackground")) - - # TODO: show pep-8 warnings in a different color (green) with prefix 'Style:' + + self.annotationStyleStyle = self.annotationErrorStyle + 1 + self.SendScintilla(QsciScintilla.SCI_STYLESETFORE, + self.annotationStyleStyle, + Preferences.getEditorColour("AnnotationsStyleForeground")) + self.SendScintilla(QsciScintilla.SCI_STYLESETBACK, + self.annotationStyleStyle, + Preferences.getEditorColour("AnnotationsStyleBackground")) + def __setAnnotation(self, line): """ Private method to set the annotations for the given line. @@ -5358,13 +5380,18 @@ if hasattr(QsciScintilla, "annotate"): warningAnnotations = [] errorAnnotations = [] + styleAnnotations = [] - # step 1: do py3flakes warnings + # step 1: do warnings for handle in list(self.warnings.keys()): if self.markerLine(handle) == line: - for msg in self.warnings[handle]: - warningAnnotations.append( - self.trUtf8("Warning: {0}").format(msg)) + for msg, warningType in self.warnings[handle]: + if warningType == self.WarningStyle: + styleAnnotations.append( + self.trUtf8("Style: {0}").format(msg)) + else: + warningAnnotations.append( + self.trUtf8("Warning: {0}").format(msg)) # step 2: do syntax errors for handle in list(self.syntaxerrors.keys()): @@ -5375,8 +5402,16 @@ wLen = len(warningAnnotations) eLen = len(errorAnnotations) + sLen = len(styleAnnotations) annotations = [] + if sLen: + annotationStyleTxt = "\n".join(styleAnnotations) + if wLen: + annotationStyleTxt += "\n" + annotations.append(QsciStyledText(annotationStyleTxt, + self.annotationStyleStyle)) + if wLen: annotationWarningTxt = "\n".join(warningAnnotations) if eLen: