diff options
author | Hugo Holgersson <hugo.holgersson@logikbyran.se> | 2016-07-17 00:29:33 +0200 |
---|---|---|
committer | Hugo Holgersson <hugo.holgersson@logikbyran.se> | 2017-11-28 12:54:29 +0000 |
commit | bf3c67e0d0e2e8daf91e07be6300a3e726cbd08b (patch) | |
tree | 103172f58f9a2167a699dc6be2694eafb7a3ebdd /src/plugins | |
parent | e050622f5544bd578d5559b36d3545f9bca4d730 (diff) | |
download | qt-creator-bf3c67e0d0e2e8daf91e07be6300a3e726cbd08b.tar.gz |
TextEditor: Implement highlighting of function definitions
This allows users to style function names at their definitions.
Once set, the XML-style token "FunctionDefinition" will
highlight all function definitions: the style option is a
mixin to Function and Virtual Function.
TEST=Default themes and locally hacked themes that lack Function,
FunctionDefinition, Declaration-styling look as they did before
this patch.
Requires Clang.
Task-number: QTCREATORBUG-16625
Change-Id: I49d8e401211bdf28ff74699feac16fe98f6d64ce
Reviewed-by: Marco Bubke <marco.bubke@qt.io>
Diffstat (limited to 'src/plugins')
-rw-r--r-- | src/plugins/clangcodemodel/clanghighlightingmarksreporter.cpp | 2 | ||||
-rw-r--r-- | src/plugins/texteditor/colorscheme.h | 4 | ||||
-rw-r--r-- | src/plugins/texteditor/texteditorconstants.cpp | 5 | ||||
-rw-r--r-- | src/plugins/texteditor/texteditorconstants.h | 1 | ||||
-rw-r--r-- | src/plugins/texteditor/texteditorsettings.cpp | 13 |
5 files changed, 20 insertions, 5 deletions
diff --git a/src/plugins/clangcodemodel/clanghighlightingmarksreporter.cpp b/src/plugins/clangcodemodel/clanghighlightingmarksreporter.cpp index 747070a317..d63ed65ff6 100644 --- a/src/plugins/clangcodemodel/clanghighlightingmarksreporter.cpp +++ b/src/plugins/clangcodemodel/clanghighlightingmarksreporter.cpp @@ -63,6 +63,8 @@ TextEditor::TextStyle toTextStyle(ClangBackEnd::HighlightingType type) return TextEditor::C_PREPROCESSOR; case HighlightingType::Declaration: return TextEditor::C_DECLARATION; + case HighlightingType::FunctionDefinition: + return TextEditor::C_FUNCTION_DEFINITION; case HighlightingType::OutputArgument: return TextEditor::C_OUTPUT_ARGUMENT; case HighlightingType::Operator: diff --git a/src/plugins/texteditor/colorscheme.h b/src/plugins/texteditor/colorscheme.h index b91c44bf16..bc9d340b68 100644 --- a/src/plugins/texteditor/colorscheme.h +++ b/src/plugins/texteditor/colorscheme.h @@ -46,6 +46,10 @@ public: Format() = default; Format(const QColor &foreground, const QColor &background); + static Format createMixinFormat() { + return Format(QColor(), QColor()); + } + QColor foreground() const { return m_foreground; } void setForeground(const QColor &foreground); diff --git a/src/plugins/texteditor/texteditorconstants.cpp b/src/plugins/texteditor/texteditorconstants.cpp index a3f4bcade4..0715275be5 100644 --- a/src/plugins/texteditor/texteditorconstants.cpp +++ b/src/plugins/texteditor/texteditorconstants.cpp @@ -101,8 +101,9 @@ const char *nameForStyle(TextStyle style) case C_WARNING: return "Warning"; case C_WARNING_CONTEXT: return "WarningContext"; - case C_DECLARATION: return "Declaration"; - case C_OUTPUT_ARGUMENT: return "OutputArgument"; + case C_DECLARATION: return "Declaration"; + case C_FUNCTION_DEFINITION: return "FunctionDefinition"; + case C_OUTPUT_ARGUMENT: return "OutputArgument"; case C_LAST_STYLE_SENTINEL: return "LastStyleSentinel"; } diff --git a/src/plugins/texteditor/texteditorconstants.h b/src/plugins/texteditor/texteditorconstants.h index 8cf692d022..0fd1c706c9 100644 --- a/src/plugins/texteditor/texteditorconstants.h +++ b/src/plugins/texteditor/texteditorconstants.h @@ -100,6 +100,7 @@ enum TextStyle : quint8 { C_ERROR_CONTEXT, C_DECLARATION, + C_FUNCTION_DEFINITION, C_OUTPUT_ARGUMENT, C_LAST_STYLE_SENTINEL diff --git a/src/plugins/texteditor/texteditorsettings.cpp b/src/plugins/texteditor/texteditorsettings.cpp index 2000f2a361..2b70a70721 100644 --- a/src/plugins/texteditor/texteditorsettings.cpp +++ b/src/plugins/texteditor/texteditorsettings.cpp @@ -288,6 +288,8 @@ TextEditorSettings::TextEditorSettings(QObject *parent) tr("Applied to lines describing changes in VCS log."), Format(QColor(192, 0, 0), QColor())); + + // Mixin categories formatDescr.emplace_back(C_ERROR, tr("Error"), tr("Underline color of error diagnostics."), @@ -312,14 +314,19 @@ TextEditorSettings::TextEditorSettings(QObject *parent) QColor(255, 190, 0), QTextCharFormat::DotLine, FormatDescription::ShowUnderlineControl); - Format declarationFormat; + Format declarationFormat = Format::createMixinFormat(); declarationFormat.setBold(true); formatDescr.emplace_back(C_DECLARATION, tr("Function Declaration"), - tr("Style adjustments to function declarations."), + tr("Style adjustments to (function) declarations."), declarationFormat, FormatDescription::ShowFontUnderlineAndRelativeControls); - Format outputArgumentFormat; + formatDescr.emplace_back(C_FUNCTION_DEFINITION, + tr("Function Definition"), + tr("Name of function at its definition."), + Format::createMixinFormat(), + FormatDescription::ShowFontUnderlineAndRelativeControls); + Format outputArgumentFormat = Format::createMixinFormat(); outputArgumentFormat.setItalic(true); formatDescr.emplace_back(C_OUTPUT_ARGUMENT, tr("Output Argument"), |