Skip to content

Commit 85dbe7b

Browse files
committed
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.
1 parent a242a58 commit 85dbe7b

File tree

4 files changed

+54
-8
lines changed

4 files changed

+54
-8
lines changed

src/ExtendedScintilla.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,9 @@ ExtendedScintilla::ExtendedScintilla(QWidget* parent) :
4545
// adjusts the scroll width to be narrower.
4646
setScrollWidthTracking(true);
4747

48+
// Visual flags for when wrap lines is enabled
49+
setWrapVisualFlags(QsciScintilla::WrapFlagByBorder);
50+
4851
// Connect signals
4952
connect(this, SIGNAL(linesChanged()), this, SLOT(updateLineNumberAreaWidth()));
5053

@@ -155,6 +158,9 @@ void ExtendedScintilla::reloadLexerSettings(QsciLexer *lexer)
155158
setTabWidth(Settings::getValue("editor", "tabsize").toInt());
156159
lexer->refreshProperties();
157160

161+
// Set wrap lines
162+
setWrapMode(static_cast<QsciScintilla::WrapMode>(Settings::getValue("editor", "wrap_lines").toInt()));
163+
158164
// Check if error indicators are enabled and clear them if they just got disabled
159165
showErrorIndicators = Settings::getValue("editor", "error_indicators").toBool();
160166
if(!showErrorIndicators)

src/PreferencesDialog.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,7 @@ void PreferencesDialog::loadSettings()
167167
ui->spinEditorFontSize->setValue(Settings::getValue("editor", "fontsize").toInt());
168168
ui->spinTabSize->setValue(Settings::getValue("editor", "tabsize").toInt());
169169
ui->spinLogFontSize->setValue(Settings::getValue("log", "fontsize").toInt());
170+
ui->wrapComboBox->setCurrentIndex(Settings::getValue("editor", "wrap_lines").toInt());
170171
ui->checkAutoCompletion->setChecked(Settings::getValue("editor", "auto_completion").toBool());
171172
ui->checkCompleteUpper->setEnabled(Settings::getValue("editor", "auto_completion").toBool());
172173
ui->checkCompleteUpper->setChecked(Settings::getValue("editor", "upper_keywords").toBool());
@@ -221,6 +222,7 @@ void PreferencesDialog::saveSettings()
221222
Settings::setValue("editor", "fontsize", ui->spinEditorFontSize->value());
222223
Settings::setValue("editor", "tabsize", ui->spinTabSize->value());
223224
Settings::setValue("log", "fontsize", ui->spinLogFontSize->value());
225+
Settings::setValue("editor", "wrap_lines", ui->wrapComboBox->currentIndex());
224226
Settings::setValue("editor", "auto_completion", ui->checkAutoCompletion->isChecked());
225227
Settings::setValue("editor", "upper_keywords", ui->checkCompleteUpper->isChecked());
226228
Settings::setValue("editor", "error_indicators", ui->checkErrorIndicators->isChecked());

src/PreferencesDialog.ui

Lines changed: 42 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -990,7 +990,7 @@
990990
<item row="0" column="1">
991991
<widget class="QFontComboBox" name="comboEditorFont"/>
992992
</item>
993-
<item row="4" column="0">
993+
<item row="5" column="0">
994994
<widget class="QLabel" name="label_20">
995995
<property name="text">
996996
<string>Code co&amp;mpletion</string>
@@ -1000,14 +1000,14 @@
10001000
</property>
10011001
</widget>
10021002
</item>
1003-
<item row="4" column="1">
1003+
<item row="5" column="1">
10041004
<widget class="QCheckBox" name="checkAutoCompletion">
10051005
<property name="text">
10061006
<string>enabled</string>
10071007
</property>
10081008
</widget>
10091009
</item>
1010-
<item row="5" column="0">
1010+
<item row="6" column="0">
10111011
<widget class="QLabel" name="label_24">
10121012
<property name="text">
10131013
<string>Keywords in &amp;UPPER CASE</string>
@@ -1017,7 +1017,7 @@
10171017
</property>
10181018
</widget>
10191019
</item>
1020-
<item row="5" column="1">
1020+
<item row="6" column="1">
10211021
<widget class="QCheckBox" name="checkCompleteUpper">
10221022
<property name="toolTip">
10231023
<string>When set, the SQL keywords are completed in UPPER CASE letters.</string>
@@ -1027,7 +1027,7 @@
10271027
</property>
10281028
</widget>
10291029
</item>
1030-
<item row="6" column="0">
1030+
<item row="7" column="0">
10311031
<widget class="QLabel" name="label_15">
10321032
<property name="text">
10331033
<string>Error indicators</string>
@@ -1037,7 +1037,7 @@
10371037
</property>
10381038
</widget>
10391039
</item>
1040-
<item row="6" column="1">
1040+
<item row="7" column="1">
10411041
<widget class="QCheckBox" name="checkErrorIndicators">
10421042
<property name="toolTip">
10431043
<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 @@
10471047
</property>
10481048
</widget>
10491049
</item>
1050-
<item row="7" column="0">
1050+
<item row="8" column="0">
10511051
<widget class="QLabel" name="label_10">
10521052
<property name="text">
10531053
<string>Hori&amp;zontal tiling</string>
@@ -1057,7 +1057,7 @@
10571057
</property>
10581058
</widget>
10591059
</item>
1060-
<item row="7" column="1">
1060+
<item row="8" column="1">
10611061
<widget class="QCheckBox" name="checkHorizontalTiling">
10621062
<property name="toolTip">
10631063
<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 @@
10671067
</property>
10681068
</widget>
10691069
</item>
1070+
<item row="4" column="1">
1071+
<widget class="QComboBox" name="wrapComboBox">
1072+
<item>
1073+
<property name="text">
1074+
<string>Never</string>
1075+
</property>
1076+
</item>
1077+
<item>
1078+
<property name="text">
1079+
<string>At word boundaries</string>
1080+
</property>
1081+
</item>
1082+
<item>
1083+
<property name="text">
1084+
<string>At character boundaries</string>
1085+
</property>
1086+
</item>
1087+
<item>
1088+
<property name="text">
1089+
<string>At whitespace boundaries</string>
1090+
</property>
1091+
</item>
1092+
</widget>
1093+
</item>
1094+
<item row="4" column="0">
1095+
<widget class="QLabel" name="wrapLabel">
1096+
<property name="text">
1097+
<string>Wrap lines</string>
1098+
</property>
1099+
<property name="buddy">
1100+
<cstring>wrapComboBox</cstring>
1101+
</property>
1102+
</widget>
1103+
</item>
10701104
</layout>
10711105
</item>
10721106
</layout>

src/Settings.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,10 @@ QVariant Settings::getDefaultValue(const QString& group, const QString& name)
290290
}
291291
}
292292

293+
// editor/wrap_lines
294+
if(group == "editor" && name == "wrap_lines")
295+
return 0; // QsciScintilla::WrapNone
296+
293297
// editor/auto_completion?
294298
if(group == "editor" && name == "auto_completion")
295299
return true;

0 commit comments

Comments
 (0)