Highlighter verbeterd en uitgebreid.
This commit is contained in:
parent
fa9787adfd
commit
2b012b70eb
1 changed files with 13 additions and 7 deletions
|
|
@ -22,8 +22,14 @@ SqlHighlighter::SqlHighlighter(QTextDocument *parent)
|
|||
: QSyntaxHighlighter(parent)
|
||||
{
|
||||
// {
|
||||
static auto keywords = R"-(as|alter|all|and|any|by|column|create|database|delete|from|group|having|in|not|or|order|select|set|table|update|where|(?:(?:inner|(?:left|right|full)(\s+outer)?)\s+)?join)-";
|
||||
// static auto types = R"-(bigint|boolean|char|character varying|date|int[248]|integer|numeric|smallint|time|timestamp(?:tz)?|timestamp(?:\s+with\s+timezone)?|varchar)-";
|
||||
static auto keywords =
|
||||
R"-(\balter\b|\ball\b|\band\b|\bany\b|\bas\b|\bby\b|\bcascade\b|\bcheck\b|\bcolumn\b|\bcopy\b|\bcreate\b|\bdatabase\b|\bdefault\b|\bdelete\b)-"
|
||||
R"-(|\foreign\b|\bfrom\b|\bgroup\b|\bhaving\b|\bin\b|\bindex\b|\bis\b|\bkey\b|\blimit\b|\bnatural\b|\bnot\b|\bnull\b|\boffset\b|\bon\b)-"
|
||||
R"-(|\bor\b|\border\b|\bover\b|\bparition\b|\bprimary\b|\breferences\b|\brestrict\b|\bselect\b|\btable\b|\btruncate\b|\bunique\b|\bupdate\b|\busing\b)-"
|
||||
R"-(|\bwhere\b|\bwith\b|(?:(?:inner|(?:left|right|full)(\s+outer)?)\s+)?join)-";
|
||||
static auto types =
|
||||
R"-(\bbigint\b|\bboolean\b|\bchar\b|\bcharacter varying\b|\bdate\b|\bint[248]\b|\binteger\b|\bnumeric\b|\bsmallint\b)-"
|
||||
R"-(|\btime\b|\btimestamp(?:tz)?\b|\btimestamp(?:\s+with\s+time\s+zone)?\b|\bvarchar\b)-";
|
||||
// static auto err = R"-(left|right|inner|outer)-";
|
||||
|
||||
// QTextCharFormat errFormat;
|
||||
|
|
@ -32,14 +38,14 @@ SqlHighlighter::SqlHighlighter(QTextDocument *parent)
|
|||
// highlightingRules.emplace_back(QRegExp(err, Qt::CaseInsensitive), errFormat);
|
||||
|
||||
QTextCharFormat keywordFormat;
|
||||
keywordFormat.setForeground(QColor(128, 128, 255));
|
||||
keywordFormat.setForeground(QColor(64, 64, 192));
|
||||
keywordFormat.setFontWeight(QFont::Bold);
|
||||
highlightingRules.emplace_back(QRegExp(keywords, Qt::CaseInsensitive), keywordFormat);
|
||||
|
||||
// QTextCharFormat typesFormat;
|
||||
// typesFormat.setForeground(QColor(128, 255, 128));
|
||||
// typesFormat.setFontWeight(QFont::Bold);
|
||||
// highlightingRules.emplace_back(QRegExp(types, Qt::CaseInsensitive), typesFormat);
|
||||
QTextCharFormat typesFormat;
|
||||
typesFormat.setForeground(QColor(64, 192, 64));
|
||||
typesFormat.setFontWeight(QFont::Bold);
|
||||
highlightingRules.emplace_back(QRegExp(types, Qt::CaseInsensitive), typesFormat);
|
||||
|
||||
// }
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue