19 QSyntaxHighlighter(parent)
26 QTextCharFormat format;
30 format = QTextCharFormat();
31 format.setForeground(QColor(
"black"));
32 format.setFontWeight(75);
33 pattern =
"\\([^\\)]*\\)";
34 applyFormat(text, format, pattern);
37 format = QTextCharFormat();
38 format.setForeground(QColor(
"blue"));
39 pattern =
"\"[^\"]*\"";
40 applyFormat(text, format, pattern);
43 format = QTextCharFormat();
44 format.setForeground(QColor(
"red"));
45 pattern =
"\\d[\\d|\\.]*";
46 applyFormat(text, format, pattern);
49 format = QTextCharFormat();
50 format.setForeground(QColor(63, 127, 95));
53 applyFormat(text, format, pattern);
56 format = QTextCharFormat();
57 format.setForeground(QColor(
"green"));
58 pattern =
"\\<[^!]\\S*[\\>]?";
59 applyFormat(text, format, pattern);
62 format = QTextCharFormat();
63 format.setForeground(QColor(
"gray"));
64 pattern =
"\\<!--.*--\\>";
65 applyFormat(text, format, pattern);
69 void ElastixSyntaxHighlighter::highlightTimestamp(
const QString &text)
71 QTextCharFormat format;
75 QString stampPattern =
"^\\[?[0-9]{2}:[0-9]{2}:[0-9]{2}( :[0-9]{3})?\\]?";
77 QString headingPattern = stampPattern +
"\\s\\w*\\s--\\s";
78 headingPattern = headingPattern +
"|------->.*";
81 format.setFontWeight(QFont::Bold);
82 format.setForeground(Qt::black);
83 applyFormat(text, format, headingPattern);
86 format.setFontWeight(QFont::Bold);
87 format.setForeground(Qt::darkMagenta);
88 applyFormat(text, format, stampPattern);
91 void ElastixSyntaxHighlighter::applyFormat(
const QString &text,
const QTextCharFormat& format,
const QString pattern)
93 QRegExp expression(pattern);
94 int index = text.indexOf(expression);
97 int length = expression.matchedLength();
99 setFormat(index,
length, format);
100 index = text.indexOf(expression, index +
length);