本文整理汇总了C++中Highlighter::rehighlight方法的典型用法代码示例。如果您正苦于以下问题:C++ Highlighter::rehighlight方法的具体用法?C++ Highlighter::rehighlight怎么用?C++ Highlighter::rehighlight使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Highlighter
的用法示例。
在下文中一共展示了Highlighter::rehighlight方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: setFontSettings
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();
}
示例2: setFontSettings
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();
}
}
示例3: setColorStyle
//.........这里部分代码省略.........
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();
}