mirror of
https://github.com/sqlitebrowser/sqlitebrowser.git
synced 2026-02-09 21:28:30 -06:00
Drop the QTextEdit widget in the Edit Database Cell dock
Use the QScintilla widget for all the text modes of the Edit Database Cell dock. All the features are believed to be preserved. - The plain text mode is materialised removing the lexer. - Null values are indicated now in the margin instead of using a placeholder. The same pattern is also used for the Image and BLOB data cases when the editor is switched to a text mode. In the dark mode, the line number margin matches now the style-sheet and instead of the configurable editor colours. - Read-only state in the editor is hinted by the caret not blinking, but the text is still selectable by keyboard or mouse. Features and fixes added by using this widget: - Find/Replace dialog for the plain text editor. See issue #1746 - The QScintilla widget does not strip CR characters. See issue #1793 - Line numbers and visible caret line in the text mode.
This commit is contained in:
@@ -124,19 +124,27 @@ void ExtendedScintilla::setupSyntaxHighlightingFormat(QsciLexer *lexer, const QS
|
||||
void ExtendedScintilla::setLexer(QsciLexer *lexer)
|
||||
{
|
||||
QsciScintilla::setLexer(lexer);
|
||||
reloadCommonSettings();
|
||||
}
|
||||
|
||||
// Set margins according to settings. setLexer seems to reset these colours.
|
||||
// Use desktop default colors for margins when following desktop style, or the custom colors otherwise.
|
||||
void ExtendedScintilla::reloadCommonSettings()
|
||||
{
|
||||
// Set margins and default text colours according to settings. setLexer seems to reset these colours.
|
||||
|
||||
// Use desktop default colors for margins when following desktop
|
||||
// style, or the colors matching the dark style-sheet, otherwise.
|
||||
switch (Settings::getValue("General", "appStyle").toInt()) {
|
||||
case Settings::FollowDesktopStyle :
|
||||
setMarginsBackgroundColor(QPalette().color(QPalette::Active, QPalette::Window));
|
||||
setMarginsForegroundColor(QPalette().color(QPalette::Active, QPalette::WindowText));
|
||||
break;
|
||||
case Settings::DarkStyle :
|
||||
setMarginsBackgroundColor(QColor(Settings::getValue("syntaxhighlighter","background_colour").toString()));
|
||||
setMarginsForegroundColor(QColor(Settings::getValue("syntaxhighlighter","foreground_colour").toString()));
|
||||
setMarginsBackgroundColor(QColor("#32414B"));
|
||||
setMarginsForegroundColor(QColor("#EFF0F1"));
|
||||
break;
|
||||
}
|
||||
setPaper(Settings::getValue("syntaxhighlighter", "background_colour").toString());
|
||||
setColor(Settings::getValue("syntaxhighlighter", "foreground_colour").toString());
|
||||
}
|
||||
|
||||
void ExtendedScintilla::reloadKeywords()
|
||||
@@ -285,3 +293,18 @@ void ExtendedScintilla::openPrintDialog()
|
||||
|
||||
delete dialog;
|
||||
}
|
||||
|
||||
void ExtendedScintilla::setReadOnly(bool ro)
|
||||
{
|
||||
QsciScintilla::setReadOnly(ro);
|
||||
// Disable or enable caret blinking so it is obvious whether the text can be modified or not. Otherwise there isn't any other hint.
|
||||
SendScintilla(QsciScintillaBase::SCI_SETCARETPERIOD, ro ? 0 : 500);
|
||||
}
|
||||
|
||||
void ExtendedScintilla::setText(const QString& text)
|
||||
{
|
||||
// Reset scroll width, so the scroll bar is readjusted to the new text.
|
||||
// Otherwise, it grows always bigger.
|
||||
setScrollWidth(80);
|
||||
QsciScintilla::setText(text);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user