R nits / tidy ups

.. highlighter and default script
This commit is contained in:
Mark Liversedge
2016-04-29 19:52:25 +01:00
parent 32657246b4
commit 8a4d261343
2 changed files with 19 additions and 7 deletions

View File

@@ -287,7 +287,13 @@ RChart::RChart(Context *context) : GcChartWindow(context), context(context)
script->setStyleSheet(TabView::ourStyleSheet());
// syntax highlighter
RSyntax syntax(script->document());
setScript("## R script will run on selection.\n"
"##\n"
"## GC.activity()\n"
"## GC.metrics()\n"
"##\n"
"## Get the current ride or date range.\n"
"##\n");
leftsplitter->addWidget(script);
console = new RConsole(context, this);
@@ -376,6 +382,10 @@ RChart::runScript()
canvas->newPage();
}
// if the program expects more we clear it, otherwise
// weird things can happen!
rtool->R->program.clear();
// clear context
rtool->context = NULL;
rtool->canvas = NULL;

View File

@@ -96,17 +96,19 @@ RSyntax::RSyntax(QTextDocument *parent) : QSyntaxHighlighter(parent)
}
// operators
operatorFormat.setForeground(QColor(255,204,000));
//operatorFormat.setForeground(Qt::darkCyan);
//operatorFormat.setFontWeight(QFont::Bold);
//QStringList operatorPatterns;
QStringList operatorPatterns;
//operatorPatterns << "[\\&\\$\\@\\|\\:\\~\\{\\}\\(\\)!]" << "==" << "!=";
operatorPatterns << "[\\&\\@\\|\\:\\~!<>=]" << "==" << "!=";
//foreach (QString pattern, operatorPatterns) {
//rule.pattern = QRegExp(pattern);
//rule.format = operatorFormat;
//highlightingRules.append(rule);
//}
foreach (QString pattern, operatorPatterns) {
rule.pattern = QRegExp(pattern);
rule.format = operatorFormat;
highlightingRules.append(rule);
}
// namespace: anything followed by ::
//namespaceFormat.setForeground(Qt::magenta);