Repository navigation
Expand file tree
/
Copy pathsqltextedit.cpp
More file actions
56 lines (47 loc) · 2.07 KB
/
Copy pathsqltextedit.cpp
File metadata and controls
56 lines (47 loc) · 2.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#include "sqltextedit.h"
#include "Settings.h"
#include "SqlUiLexer.h"
SqlUiLexer* SqlTextEdit::sqlLexer = nullptr;
SqlTextEdit::SqlTextEdit(QWidget* parent) :
ExtendedScintilla(parent)
{
// Create lexer object if not done yet
if(sqlLexer == nullptr)
sqlLexer = new SqlUiLexer(this);
// Set the SQL lexer
setLexer(sqlLexer);
// Set icons for auto completion
registerImage(SqlUiLexer::ApiCompleterIconIdKeyword, QImage(":/icons/keyword"));
registerImage(SqlUiLexer::ApiCompleterIconIdFunction, QImage(":/icons/function"));
registerImage(SqlUiLexer::ApiCompleterIconIdTable, QImage(":/icons/table"));
registerImage(SqlUiLexer::ApiCompleterIconIdColumn, QImage(":/icons/field"));
// Do rest of initialisation
reloadSettings();
}
SqlTextEdit::~SqlTextEdit()
{
}
void SqlTextEdit::reloadSettings()
{
// Enable auto completion if it hasn't been disabled
if(Settings::getValue("editor", "auto_completion").toBool())
{
setAutoCompletionThreshold(3);
setAutoCompletionCaseSensitivity(true);
setAutoCompletionShowSingle(true);
setAutoCompletionSource(QsciScintilla::AcsAPIs);
} else {
setAutoCompletionThreshold(0);
}
ExtendedScintilla::reloadSettings();
setupSyntaxHighlightingFormat(sqlLexer, "comment", QsciLexerSQL::Comment);
setupSyntaxHighlightingFormat(sqlLexer, "comment", QsciLexerSQL::CommentLine);
setupSyntaxHighlightingFormat(sqlLexer, "comment", QsciLexerSQL::CommentDoc);
setupSyntaxHighlightingFormat(sqlLexer, "keyword", QsciLexerSQL::Keyword);
setupSyntaxHighlightingFormat(sqlLexer, "table", QsciLexerSQL::KeywordSet6);
setupSyntaxHighlightingFormat(sqlLexer, "function", QsciLexerSQL::KeywordSet7);
setupSyntaxHighlightingFormat(sqlLexer, "string", QsciLexerSQL::DoubleQuotedString);
setupSyntaxHighlightingFormat(sqlLexer, "string", QsciLexerSQL::SingleQuotedString);
setupSyntaxHighlightingFormat(sqlLexer, "identifier", QsciLexerSQL::Identifier);
setupSyntaxHighlightingFormat(sqlLexer, "identifier", QsciLexerSQL::QuotedIdentifier);
}