diff options
Diffstat (limited to 'src/plugins/git/githighlighters.cpp')
-rw-r--r-- | src/plugins/git/githighlighters.cpp | 41 |
1 files changed, 25 insertions, 16 deletions
diff --git a/src/plugins/git/githighlighters.cpp b/src/plugins/git/githighlighters.cpp index f6cea509ec9..fbc72dae950 100644 --- a/src/plugins/git/githighlighters.cpp +++ b/src/plugins/git/githighlighters.cpp @@ -38,9 +38,7 @@ static const char CHANGE_PATTERN[] = "\\b[a-f0-9]{7,40}\\b"; GitSubmitHighlighter::GitSubmitHighlighter(QTextEdit * parent) : TextEditor::SyntaxHighlighter(parent) { - static const QVector<TextEditor::TextStyle> categories({TextEditor::C_COMMENT}); - - setTextFormatCategories(categories); + setDefaultTextFormatCategories(); m_keywordPattern.setPattern("^[\\w-]+:"); m_hashChar = '#'; QTC_CHECK(m_keywordPattern.isValid()); @@ -56,7 +54,7 @@ void GitSubmitHighlighter::highlightBlock(const QString &text) setCurrentBlockState(state); return; } else if (text.startsWith(m_hashChar)) { - setFormat(0, text.size(), formatForCategory(Format_Comment)); + setFormat(0, text.size(), formatForCategory(TextEditor::C_COMMENT)); setCurrentBlockState(state); return; } else if (state == None) { @@ -92,23 +90,34 @@ GitRebaseHighlighter::RebaseAction::RebaseAction(const QString ®exp, { } +static TextEditor::TextStyle styleForFormat(int format) +{ + using namespace TextEditor; + const auto f = Format(format); + switch (f) { + case Format_Comment: return C_COMMENT; + case Format_Change: return C_DOXYGEN_COMMENT; + case Format_Description: return C_STRING; + case Format_Pick: return C_KEYWORD; + case Format_Reword: return C_FIELD; + case Format_Edit: return C_TYPE; + case Format_Squash: return C_ENUMERATION; + case Format_Fixup: return C_NUMBER; + case Format_Exec: return C_LABEL; + case Format_Count: + QTC_CHECK(false); // should never get here + return C_TEXT; + } + QTC_CHECK(false); // should never get here + return C_TEXT; +} + GitRebaseHighlighter::GitRebaseHighlighter(QTextDocument *parent) : TextEditor::SyntaxHighlighter(parent), m_hashChar('#'), m_changeNumberPattern(CHANGE_PATTERN) { - static const QVector<TextEditor::TextStyle> categories({ - TextEditor::C_COMMENT, - TextEditor::C_DOXYGEN_COMMENT, - TextEditor::C_STRING, - TextEditor::C_KEYWORD, - TextEditor::C_FIELD, - TextEditor::C_TYPE, - TextEditor::C_ENUMERATION, - TextEditor::C_NUMBER, - TextEditor::C_LABEL - }); - setTextFormatCategories(categories); + setTextFormatCategories(Format_Count, styleForFormat); m_actions << RebaseAction("^(p|pick)\\b", Format_Pick); m_actions << RebaseAction("^(r|reword)\\b", Format_Reword); |