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 JuliaEditorWidget::setFontSettings(const TextEditor::FontSettings &fs) { using namespace TextEditor; using namespace TextEditor::Internal; BaseTextEditorWidget::setFontSettings(fs); if (baseTextDocument()->syntaxHighlighter()) { Highlighter *highlighter = static_cast<Highlighter *>(baseTextDocument()->syntaxHighlighter()); highlighter->configureFormat(Highlighter::VisualWhitespace, fs.toTextCharFormat(C_VISUAL_WHITESPACE)); highlighter->configureFormat(Highlighter::Keyword, fs.toTextCharFormat(C_KEYWORD)); highlighter->configureFormat(Highlighter::DataType, fs.toTextCharFormat(C_TYPE)); highlighter->configureFormat(Highlighter::Comment, fs.toTextCharFormat(C_COMMENT)); // Using C_NUMBER for all kinds of numbers. highlighter->configureFormat(Highlighter::Decimal, fs.toTextCharFormat(C_NUMBER)); highlighter->configureFormat(Highlighter::BaseN, fs.toTextCharFormat(C_NUMBER)); highlighter->configureFormat(Highlighter::Float, fs.toTextCharFormat(C_NUMBER)); // Using C_STRING for strings and chars. highlighter->configureFormat(Highlighter::Char, fs.toTextCharFormat(C_STRING)); highlighter->configureFormat(Highlighter::String, fs.toTextCharFormat(C_STRING)); highlighter->rehighlight(); } }
void KateHighlighter::setColorStyle(TextEditor::SyntaxHighlighter *h,const ColorStyleScheme *scheme) { Highlighter *highlighter = static_cast<Highlighter*>(h); if (!highlighter) { return; } QTextCharFormat fmt_vw; if (!setTextCharStyle(fmt_vw,"VisualWhitespace",scheme)) { fmt_vw.setForeground(Qt::lightGray); } highlighter->configureFormat(Highlighter::VisualWhitespace, fmt_vw); QTextCharFormat fmt_kw; if (!setTextCharStyle(fmt_kw,"Keyword",scheme)) { fmt_kw.setForeground(Qt::darkBlue); fmt_kw.setFontWeight(QFont::Bold); } highlighter->configureFormat(Highlighter::Keyword, fmt_kw); QTextCharFormat fmt_dt; if (!setTextCharStyle(fmt_dt,"DataType",scheme)) { fmt_dt.setForeground(Qt::darkBlue);//Qt::darkMagenta); } highlighter->configureFormat(Highlighter::DataType, fmt_dt); QTextCharFormat fmt_fn; if (!setTextCharStyle(fmt_fn,"Function",scheme)) { fmt_fn.setForeground(Qt::blue); } highlighter->configureFormat(Highlighter::Function,fmt_fn); QTextCharFormat fmt_cmn; if (!setTextCharStyle(fmt_cmn,"Comment",scheme)) { fmt_cmn.setForeground(Qt::darkGreen); } highlighter->configureFormat(Highlighter::Comment, fmt_cmn); QTextCharFormat fmt_dd; if (!setTextCharStyle(fmt_dd,"Decimal",scheme)) { fmt_dd.setForeground(Qt::darkMagenta); } // Using C_NUMBER for all kinds of numbers. highlighter->configureFormat(Highlighter::Decimal, fmt_dd); QTextCharFormat fmt_db; if (!setTextCharStyle(fmt_db,"BaseN",scheme)) { fmt_db.setForeground(Qt::darkMagenta); } highlighter->configureFormat(Highlighter::BaseN, fmt_db); QTextCharFormat fmt_df; if (!setTextCharStyle(fmt_df,"Float",scheme)) { fmt_df.setForeground(Qt::darkMagenta); } highlighter->configureFormat(Highlighter::Float, fmt_df); QTextCharFormat fmt_ch; if (!setTextCharStyle(fmt_ch,"Char",scheme)) { fmt_ch.setForeground(Qt::darkGreen); } // Using C_STRING for strings and chars. highlighter->configureFormat(Highlighter::Char, fmt_ch); QTextCharFormat fmt_cs; if (!setTextCharStyle(fmt_cs,"String",scheme)) { fmt_cs.setForeground(Qt::darkGreen); } highlighter->configureFormat(Highlighter::String, fmt_cs); QTextCharFormat fmt_rm; if (!setTextCharStyle(fmt_rm,"RegionMarker",scheme)) { fmt_rm.setForeground(Qt::yellow); } highlighter->configureFormat(Highlighter::RegionMarker,fmt_rm); QTextCharFormat fmt_alert; if (!setTextCharStyle(fmt_alert,"Alert",scheme)) { fmt_alert.setForeground(Qt::red); } highlighter->configureFormat(Highlighter::Alert,fmt_alert); QTextCharFormat fmt_err; if (!setTextCharStyle(fmt_err,"Error",scheme)) { fmt_err.setForeground(Qt::red); } highlighter->configureFormat(Highlighter::Error,fmt_err); QTextCharFormat fmt_sym; if (!setTextCharStyle(fmt_sym,"Symbol",scheme)) { fmt_sym.setForeground(Qt::red); } highlighter->configureFormat(Highlighter::Symbol,fmt_sym); QTextCharFormat fmt_bf; if (!setTextCharStyle(fmt_bf,"BuiltinFunc",scheme)) { fmt_bf.setForeground(Qt::blue); } highlighter->configureFormat(Highlighter::BuiltinFunc,fmt_bf); QTextCharFormat fmt_pre; if (!setTextCharStyle(fmt_pre,"Predeclared",scheme)) { fmt_pre.setForeground(Qt::blue); } highlighter->configureFormat(Highlighter::Predeclared,fmt_pre); QTextCharFormat fmt_fc; if (!setTextCharStyle(fmt_fc,"FuncDecl",scheme)) { fmt_fc.setForeground(Qt::blue); } highlighter->configureFormat(Highlighter::FuncDecl,fmt_fc); highlighter->rehighlight(); }