This action will force synchronization from 陈炳煌/sqlitebrowser, which will overwrite any changes that you have made since you forked the repository, and can not be recovered!!!
Synchronous operation will process in the background and will refresh the page when finishing processing. Please be patient.
#include "sql/ObjectIdentifier.h"#include "sqltextedit.h"#include "Settings.h"#include "SqlUiLexer.h"#include <Qsci/qscicommandset.h>#include <Qsci/qscicommand.h>#include <QShortcut>#include <QRegExp>SqlUiLexer* SqlTextEdit::sqlLexer = nullptr;SqlTextEdit::SqlTextEdit(QWidget* parent) :ExtendedScintilla(parent){// Create lexer object if not done yetif(sqlLexer == nullptr)sqlLexer = new SqlUiLexer(this);// Set the SQL lexersetLexer(sqlLexer);// Set icons for auto completionregisterImage(SqlUiLexer::ApiCompleterIconIdKeyword, QImage(":/icons/keyword"));registerImage(SqlUiLexer::ApiCompleterIconIdFunction, QImage(":/icons/function"));registerImage(SqlUiLexer::ApiCompleterIconIdTable, QImage(":/icons/table"));registerImage(SqlUiLexer::ApiCompleterIconIdColumn, QImage(":/icons/field"));registerImage(SqlUiLexer::ApiCompleterIconIdSchema, QImage(":/icons/database"));// Remove command bindings that would interfere with our shortcutToggleCommentQsciCommand * command = standardCommands()->boundTo(Qt::ControlModifier+Qt::Key_Slash);command->setKey(0);command = standardCommands()->boundTo(Qt::ControlModifier+Qt::ShiftModifier+Qt::Key_Slash);command->setKey(0);// Change command binding for Ctrl+T so it doesn't interfere with "Open tab"command = standardCommands()->boundTo(Qt::ControlModifier+Qt::Key_T);command->setKey(Qt::ControlModifier+Qt::ShiftModifier+Qt::Key_Up);QShortcut* shortcutToggleComment = new QShortcut(QKeySequence(tr("Ctrl+/")), this, nullptr, nullptr, Qt::WidgetShortcut);connect(shortcutToggleComment, &QShortcut::activated, this, &SqlTextEdit::toggleBlockComment);// Do rest of initialisationreloadSettings();}SqlTextEdit::~SqlTextEdit(){}void SqlTextEdit::reloadSettings(){// Enable auto completion if it hasn't been disabledif(Settings::getValue("editor", "auto_completion").toBool()){setAutoCompletionThreshold(3);setAutoCompletionCaseSensitivity(true);setAutoCompletionShowSingle(true);setAutoCompletionSource(QsciScintilla::AcsAPIs);} else {setAutoCompletionThreshold(0);}// Set wrap linessetWrapMode(static_cast<QsciScintilla::WrapMode>(Settings::getValue("editor", "wrap_lines").toInt()));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::SingleQuotedString);// Highlight double quote strings as identifier or as literal string depending on user preferenceswitch(static_cast<sqlb::escapeQuoting>(Settings::getValue("editor", "identifier_quotes").toInt())) {case sqlb::DoubleQuotes:setupSyntaxHighlightingFormat(sqlLexer, "identifier", QsciLexerSQL::DoubleQuotedString);sqlLexer->setQuotedIdentifiers(false);break;case sqlb::GraveAccents:sqlLexer->setQuotedIdentifiers(true);// Fall through, treat quoted string as literal stringcase sqlb::SquareBrackets:setupSyntaxHighlightingFormat(sqlLexer, "string", QsciLexerSQL::DoubleQuotedString);break;}setupSyntaxHighlightingFormat(sqlLexer, "identifier", QsciLexerSQL::Identifier);setupSyntaxHighlightingFormat(sqlLexer, "identifier", QsciLexerSQL::QuotedIdentifier);}void SqlTextEdit::toggleBlockComment(){int lineFrom, indexFrom, lineTo, indexTo;// If there is no selection, select the current lineif (!hasSelectedText()) {getCursorPosition(&lineFrom, &indexFrom);// Windows lines requires an adjustment, otherwise the selection would// end in the next line.indexTo = text(lineFrom).endsWith("\r\n") ? lineLength(lineFrom)-1 : lineLength(lineFrom);setSelection(lineFrom, 0, lineFrom, indexTo);}getSelection(&lineFrom, &indexFrom, &lineTo, &indexTo);bool uncomment = text(lineFrom).contains(QRegExp("^[ \t]*--"));// If the selection ends before the first character of a line, don't// take this line into account for un/commenting.if (indexTo==0)lineTo--;beginUndoAction();// Iterate over the selected lines, get line text, make// replacement depending on whether the first line was commented// or uncommented, and replace the line text. All in a single undo action.for (int line=lineFrom; line<=lineTo; line++) {QString lineText = text(line);if (uncomment)lineText.replace(QRegExp("^([ \t]*)-- ?"), "\\1");elselineText.replace(QRegExp("^"), "-- ");indexTo = lineText.endsWith("\r\n") ? lineLength(line)-1 : lineLength(line);setSelection(line, 0, line, indexTo);replaceSelectedText(lineText);}endUndoAction();}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。