Setting for line wrap in Scintilla editors

A new setting is added to the 'SQL' tab of the Preferences dialog. It
enables the line wrapping in the editors with none/character/word/
whitespace boundaries.

See comments in issue #1173.
This commit is contained in:
mgrojo
2018-03-28 22:24:48 +02:00
parent a242a581c5
commit 85dbe7b016
4 changed files with 54 additions and 8 deletions

View File

@@ -45,6 +45,9 @@ ExtendedScintilla::ExtendedScintilla(QWidget* parent) :
// adjusts the scroll width to be narrower.
setScrollWidthTracking(true);
// Visual flags for when wrap lines is enabled
setWrapVisualFlags(QsciScintilla::WrapFlagByBorder);
// Connect signals
connect(this, SIGNAL(linesChanged()), this, SLOT(updateLineNumberAreaWidth()));
@@ -155,6 +158,9 @@ void ExtendedScintilla::reloadLexerSettings(QsciLexer *lexer)
setTabWidth(Settings::getValue("editor", "tabsize").toInt());
lexer->refreshProperties();
// Set wrap lines
setWrapMode(static_cast<QsciScintilla::WrapMode>(Settings::getValue("editor", "wrap_lines").toInt()));
// Check if error indicators are enabled and clear them if they just got disabled
showErrorIndicators = Settings::getValue("editor", "error_indicators").toBool();
if(!showErrorIndicators)

View File

@@ -167,6 +167,7 @@ void PreferencesDialog::loadSettings()
ui->spinEditorFontSize->setValue(Settings::getValue("editor", "fontsize").toInt());
ui->spinTabSize->setValue(Settings::getValue("editor", "tabsize").toInt());
ui->spinLogFontSize->setValue(Settings::getValue("log", "fontsize").toInt());
ui->wrapComboBox->setCurrentIndex(Settings::getValue("editor", "wrap_lines").toInt());
ui->checkAutoCompletion->setChecked(Settings::getValue("editor", "auto_completion").toBool());
ui->checkCompleteUpper->setEnabled(Settings::getValue("editor", "auto_completion").toBool());
ui->checkCompleteUpper->setChecked(Settings::getValue("editor", "upper_keywords").toBool());
@@ -221,6 +222,7 @@ void PreferencesDialog::saveSettings()
Settings::setValue("editor", "fontsize", ui->spinEditorFontSize->value());
Settings::setValue("editor", "tabsize", ui->spinTabSize->value());
Settings::setValue("log", "fontsize", ui->spinLogFontSize->value());
Settings::setValue("editor", "wrap_lines", ui->wrapComboBox->currentIndex());
Settings::setValue("editor", "auto_completion", ui->checkAutoCompletion->isChecked());
Settings::setValue("editor", "upper_keywords", ui->checkCompleteUpper->isChecked());
Settings::setValue("editor", "error_indicators", ui->checkErrorIndicators->isChecked());

View File

@@ -990,7 +990,7 @@
<item row="0" column="1">
<widget class="QFontComboBox" name="comboEditorFont"/>
</item>
<item row="4" column="0">
<item row="5" column="0">
<widget class="QLabel" name="label_20">
<property name="text">
<string>Code co&amp;mpletion</string>
@@ -1000,14 +1000,14 @@
</property>
</widget>
</item>
<item row="4" column="1">
<item row="5" column="1">
<widget class="QCheckBox" name="checkAutoCompletion">
<property name="text">
<string>enabled</string>
</property>
</widget>
</item>
<item row="5" column="0">
<item row="6" column="0">
<widget class="QLabel" name="label_24">
<property name="text">
<string>Keywords in &amp;UPPER CASE</string>
@@ -1017,7 +1017,7 @@
</property>
</widget>
</item>
<item row="5" column="1">
<item row="6" column="1">
<widget class="QCheckBox" name="checkCompleteUpper">
<property name="toolTip">
<string>When set, the SQL keywords are completed in UPPER CASE letters.</string>
@@ -1027,7 +1027,7 @@
</property>
</widget>
</item>
<item row="6" column="0">
<item row="7" column="0">
<widget class="QLabel" name="label_15">
<property name="text">
<string>Error indicators</string>
@@ -1037,7 +1037,7 @@
</property>
</widget>
</item>
<item row="6" column="1">
<item row="7" column="1">
<widget class="QCheckBox" name="checkErrorIndicators">
<property name="toolTip">
<string>When set, the SQL code lines that caused errors during the last execution are highlighted and the results frame indicates the error in the background</string>
@@ -1047,7 +1047,7 @@
</property>
</widget>
</item>
<item row="7" column="0">
<item row="8" column="0">
<widget class="QLabel" name="label_10">
<property name="text">
<string>Hori&amp;zontal tiling</string>
@@ -1057,7 +1057,7 @@
</property>
</widget>
</item>
<item row="7" column="1">
<item row="8" column="1">
<widget class="QCheckBox" name="checkHorizontalTiling">
<property name="toolTip">
<string>If enabled the SQL code editor and the result table view are shown side by side instead of one over the other.</string>
@@ -1067,6 +1067,40 @@
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QComboBox" name="wrapComboBox">
<item>
<property name="text">
<string>Never</string>
</property>
</item>
<item>
<property name="text">
<string>At word boundaries</string>
</property>
</item>
<item>
<property name="text">
<string>At character boundaries</string>
</property>
</item>
<item>
<property name="text">
<string>At whitespace boundaries</string>
</property>
</item>
</widget>
</item>
<item row="4" column="0">
<widget class="QLabel" name="wrapLabel">
<property name="text">
<string>Wrap lines</string>
</property>
<property name="buddy">
<cstring>wrapComboBox</cstring>
</property>
</widget>
</item>
</layout>
</item>
</layout>

View File

@@ -290,6 +290,10 @@ QVariant Settings::getDefaultValue(const QString& group, const QString& name)
}
}
// editor/wrap_lines
if(group == "editor" && name == "wrap_lines")
return 0; // QsciScintilla::WrapNone
// editor/auto_completion?
if(group == "editor" && name == "auto_completion")
return true;