C++: support smart splitting of strings.

If 'enter' is pressed while the cursor is in the middle of a string,
the string is ended at the current cursor position, and a new string
is started on the next line.  This makes it very easy to split a long
string onto multiple lines.

In addition, Shift+Enter insert an escape in the string, to continue the
string at the beginning of next line.

A setting can be used to enable or disable this option.

Change-Id: Ia5f3c6989fc00d40d06bc4fe1182fe8b1318f565
Reviewed-by: Francois Ferrand <thetypz@gmail.com>
Reviewed-by: hjk <hjk121@nokiamail.com>
This commit is contained in:
Francois Ferrand
2014-09-29 18:19:38 +02:00
committed by hjk
parent 82d9cf4146
commit 32b960db47
10 changed files with 162 additions and 63 deletions

View File

@@ -99,6 +99,7 @@ QWidget *CompletionSettingsPage::widget()
m_page->surroundSelectedText->setChecked(settings.m_surroundingAutoBrackets);
m_page->partiallyComplete->setChecked(settings.m_partiallyComplete);
m_page->spaceAfterFunctionName->setChecked(settings.m_spaceAfterFunctionName);
m_page->autoSplitStrings->setChecked(settings.m_autoSplitStrings);
m_page->enableDoxygenCheckBox->setChecked(m_commentsSettings.m_enableDoxygen);
m_page->generateBriefCheckBox->setChecked(m_commentsSettings.m_generateBrief);
m_page->leadingAsterisksCheckBox->setChecked(m_commentsSettings.m_leadingAsterisks);
@@ -118,6 +119,7 @@ void CompletionSettingsPage::apply()
settings.m_surroundingAutoBrackets = m_page->surroundSelectedText->isChecked();
settings.m_partiallyComplete = m_page->partiallyComplete->isChecked();
settings.m_spaceAfterFunctionName = m_page->spaceAfterFunctionName->isChecked();
settings.m_autoSplitStrings = m_page->autoSplitStrings->isChecked();
TextEditor::TextEditorSettings::setCompletionSettings(settings);

View File

@@ -17,6 +17,72 @@
<string>Behavior</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="4" column="0">
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>30</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QCheckBox" name="surroundSelectedText">
<property name="toolTip">
<string>When typing a matching character and there is a text selection, instead of removing the selection, surrounds it with the corresponding characters.</string>
</property>
<property name="text">
<string>Surround &amp;text selections</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</item>
<item row="0" column="2" colspan="2">
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>70</width>
<height>24</height>
</size>
</property>
</spacer>
</item>
<item row="1" column="0">
<widget class="QLabel" name="completionTriggerLabel">
<property name="text">
<string>Activate completion:</string>
</property>
</widget>
</item>
<item row="1" column="3">
<spacer name="horizontalSpacer_3">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>24</height>
</size>
</property>
</spacer>
</item>
<item row="0" column="0">
<widget class="QLabel" name="caseSensitivityLabel">
<property name="text">
@@ -52,23 +118,10 @@
</item>
</widget>
</item>
<item row="0" column="2" colspan="2">
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>70</width>
<height>24</height>
</size>
</property>
</spacer>
</item>
<item row="1" column="0">
<widget class="QLabel" name="completionTriggerLabel">
<item row="6" column="0">
<widget class="QCheckBox" name="autoSplitStrings">
<property name="text">
<string>Activate completion:</string>
<string>Automatically split strings</string>
</property>
</widget>
</item>
@@ -91,19 +144,6 @@
</item>
</widget>
</item>
<item row="1" column="3">
<spacer name="horizontalSpacer_3">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>24</height>
</size>
</property>
</spacer>
</item>
<item row="2" column="0">
<widget class="QCheckBox" name="partiallyComplete">
<property name="toolTip">
@@ -130,40 +170,7 @@
</property>
</widget>
</item>
<item row="4" column="0">
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>30</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QCheckBox" name="surroundSelectedText">
<property name="toolTip">
<string>When typing a matching character and there is a text selection, instead of removing the selection, surrounds it with the corresponding characters.</string>
</property>
<property name="text">
<string>Surround &amp;text selections</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</item>
<item row="5" column="0" colspan="2">
<item row="5" column="0">
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<spacer name="horizontalSpacer_4">