void GLSLTextEditorWidget::setFontSettings(const TextEditor::FontSettings &fs) { TextEditor::BaseTextEditorWidget::setFontSettings(fs); Highlighter *highlighter = qobject_cast<Highlighter*>(baseTextDocument()->syntaxHighlighter()); if (!highlighter) return; /* NumberFormat, StringFormat, TypeFormat, KeywordFormat, LabelFormat, CommentFormat, VisualWhitespace, */ static QVector<TextEditor::TextStyle> categories; if (categories.isEmpty()) { categories << TextEditor::C_NUMBER << TextEditor::C_STRING << TextEditor::C_TYPE << TextEditor::C_KEYWORD << TextEditor::C_OPERATOR << TextEditor::C_PREPROCESSOR << TextEditor::C_LABEL << TextEditor::C_COMMENT << TextEditor::C_DOXYGEN_COMMENT << TextEditor::C_DOXYGEN_TAG << TextEditor::C_VISUAL_WHITESPACE << TextEditor::C_REMOVED_LINE; } highlighter->setFormats(fs.toTextCharFormats(categories)); highlighter->rehighlight(); }
void QmlJSSnippetProvider::decorateEditor(TextEditor::SnippetEditorWidget *editor) const { Highlighter *highlighter = new Highlighter; const TextEditor::FontSettings &fs = TextEditor::TextEditorSettings::instance()->fontSettings(); highlighter->setFormats(fs.toTextCharFormats(QmlJSTextEditorWidget::highlighterFormatCategories())); editor->setSyntaxHighlighter(highlighter); editor->setIndenter(new Indenter); editor->setAutoCompleter(new AutoCompleter); }