Add common interface for text formats inside syntax highlighter

Change-Id: I87f64446161a57aea0896f68e4eafacef791969b
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
This commit is contained in:
jkobus
2013-08-13 12:57:31 +02:00
committed by Jarek Kobus
parent 760aa0f8bc
commit e8801167aa
69 changed files with 489 additions and 531 deletions

View File

@@ -40,13 +40,13 @@
#include <coreplugin/actionmanager/actionmanager.h>
#include <projectexplorer/projectexplorer.h>
#include <projectexplorer/session.h>
#include <texteditor/fontsettings.h>
#include <texteditor/texteditoractionhandler.h>
#include <texteditor/texteditorconstants.h>
#include <texteditor/texteditorsettings.h>
#include <QFileInfo>
#include <QSharedPointer>
#include <QTextBlock>
using namespace CMakeProjectManager;
using namespace CMakeProjectManager::Internal;
@@ -141,27 +141,6 @@ void CMakeEditorWidget::contextMenuEvent(QContextMenuEvent *e)
showDefaultContextMenu(e, Constants::M_CONTEXT);
}
void CMakeEditorWidget::setFontSettings(const TextEditor::FontSettings &fs)
{
TextEditor::BaseTextEditorWidget::setFontSettings(fs);
CMakeHighlighter *highlighter = qobject_cast<CMakeHighlighter*>(baseTextDocument()->syntaxHighlighter());
if (!highlighter)
return;
static QVector<TextEditor::TextStyle> categories;
if (categories.isEmpty()) {
categories << TextEditor::C_LABEL // variables
<< TextEditor::C_KEYWORD // functions
<< TextEditor::C_COMMENT
<< TextEditor::C_STRING
<< TextEditor::C_VISUAL_WHITESPACE;
}
const QVector<QTextCharFormat> formats = fs.toTextCharFormats(categories);
highlighter->setFormats(formats.constBegin(), formats.constEnd());
highlighter->rehighlight();
}
static bool isValidFileNameChar(const QChar &c)
{
if (c.isLetterOrNumber()