Initial commit. Contains a simple query tool.
This commit is contained in:
commit
edc6df25da
19 changed files with 1245 additions and 0 deletions
60
sqlhighlighter.cpp
Normal file
60
sqlhighlighter.cpp
Normal file
|
|
@ -0,0 +1,60 @@
|
|||
#include "SqlHighlighter.h"
|
||||
|
||||
static const wchar_t *keywords[] = {
|
||||
L"as", L"alter", L"all", L"and", L"any", L"by", L"column", L"create", L"database", L"from", L"full", L"group", L"having",
|
||||
L"in", L"inner", L"join", L"left", L"not", L"or", L"order", L"outer", L"right", L"select", L"table", L"where"
|
||||
};
|
||||
//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 err = R"-(left|right|inner|outer)-";
|
||||
|
||||
static_assert(sizeof(keywords)/4 == 25,
|
||||
"sizeof keywords");
|
||||
|
||||
|
||||
SqlHighlighter::SqlHighlighter(QTextDocument *parent)
|
||||
: QSyntaxHighlighter(parent)
|
||||
{
|
||||
// {
|
||||
// static auto keywords = R"-(as|alter|all|and|any|by|column|create|database|from|group|having|in|not|or|order|select|table|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 err = R"-(left|right|inner|outer)-";
|
||||
|
||||
// QTextCharFormat errFormat;
|
||||
// errFormat.setForeground(QColor(255, 128, 128));
|
||||
// errFormat.setFontWeight(QFont::Bold);
|
||||
// highlightingRules.emplace_back(QRegExp(err, Qt::CaseInsensitive), errFormat);
|
||||
|
||||
// QTextCharFormat keywordFormat;
|
||||
// keywordFormat.setForeground(QColor(128, 128, 255));
|
||||
// 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);
|
||||
|
||||
// }
|
||||
}
|
||||
|
||||
void NextBasicToken(const QString &in, int ofs, int &start, int &length)
|
||||
{
|
||||
// Basically parses for white space and chops based on white space
|
||||
// it does also recognize comments and quoted strings/identifiers
|
||||
|
||||
}
|
||||
|
||||
void SqlHighlighter::highlightBlock(const QString &text)
|
||||
{
|
||||
// foreach (const HighlightingRule &rule, highlightingRules) {
|
||||
// QRegExp expression(rule.pattern);
|
||||
// int index = expression.indexIn(text);
|
||||
// while (index >= 0) {
|
||||
// int length = expression.matchedLength();
|
||||
// setFormat(index, length, rule.format);
|
||||
// index = expression.indexIn(text, index + length);
|
||||
// }
|
||||
// }
|
||||
setCurrentBlockState(0);
|
||||
}
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue