diff --git a/src/dialogs/katedialogs.cpp b/src/dialogs/katedialogs.cpp --- a/src/dialogs/katedialogs.cpp +++ b/src/dialogs/katedialogs.cpp @@ -665,6 +665,7 @@ // connect(textareaUi->gbWordWrap, SIGNAL(toggled(bool)), this, SLOT(slotChanged())); + connect(textareaUi->chkDynWrapAtStaticMarker, SIGNAL(toggled(bool)), this, SLOT(slotChanged())); connect(textareaUi->cmbDynamicWordWrapIndicator, SIGNAL(activated(int)), this, SLOT(slotChanged())); connect(textareaUi->sbDynamicWordWrapDepth, SIGNAL(valueChanged(int)), this, SLOT(slotChanged())); connect(textareaUi->chkShowTabs, SIGNAL(toggled(bool)), this, SLOT(slotChanged())); @@ -711,6 +712,7 @@ KateRendererConfig::global()->configStart(); KateViewConfig::global()->setDynWordWrap(textareaUi->gbWordWrap->isChecked()); + KateViewConfig::global()->setDynWrapAtStaticMarker(textareaUi->chkDynWrapAtStaticMarker->isChecked()); KateViewConfig::global()->setDynWordWrapIndicators(textareaUi->cmbDynamicWordWrapIndicator->currentIndex()); KateViewConfig::global()->setDynWordWrapAlignIndent(textareaUi->sbDynamicWordWrapDepth->value()); KateDocumentConfig::global()->setShowTabs(textareaUi->chkShowTabs->isChecked()); @@ -743,6 +745,7 @@ void KateViewDefaultsConfig::reload() { textareaUi->gbWordWrap->setChecked(KateViewConfig::global()->dynWordWrap()); + textareaUi->chkDynWrapAtStaticMarker->setChecked(KateViewConfig::global()->dynWrapAtStaticMarker()); textareaUi->cmbDynamicWordWrapIndicator->setCurrentIndex(KateViewConfig::global()->dynWordWrapIndicators()); textareaUi->sbDynamicWordWrapDepth->setValue(KateViewConfig::global()->dynWordWrapAlignIndent()); textareaUi->chkShowTabs->setChecked(KateDocumentConfig::global()->showTabs()); diff --git a/src/dialogs/textareaappearanceconfigwidget.ui b/src/dialogs/textareaappearanceconfigwidget.ui --- a/src/dialogs/textareaappearanceconfigwidget.ui +++ b/src/dialogs/textareaappearanceconfigwidget.ui @@ -1,266 +1,339 @@ - TextareaAppearanceConfigWidget - - + TextareaAppearanceConfigWidget + + + + 0 + 0 + 810 + 752 + + + + + + + If this option is checked, the text lines will be wrapped at the view border on the screen. + + + &Dynamic Word Wrap + + + true + + - - - If this option is checked, the text lines will be wrapped at the view border on the screen. - - - &Dynamic Word Wrap - - - true - - - - - - Dynamic &word wrap indicators (if applicable): - - - cmbDynamicWordWrapIndicator - - - - - - - Choose when the Dynamic Word Wrap Indicators should be displayed. - - - - - - - Align dynamically wrapped lines to indentation depth: - - - sbDynamicWordWrapDepth - - - - - - - - 0 - 0 - - - - <p>Enables the start of dynamically wrapped lines to be aligned vertically to the indentation level of the first line. This can help to make code and markup more readable.</p><p>Additionally, this allows you to set a maximum width of the screen, as a percentage, after which dynamically wrapped lines will no longer be vertically aligned. For example, at 50%, lines whose indentation levels are deeper than 50% of the width of the screen will not have vertical alignment applied to subsequent wrapped lines.</p> - - - Disabled - - - % of View Width - - - 80 - - - 10 - - - - - + + + Wrap dynamic at static word wrap marker + + - - - Whitespace Highlighting - - + + + 0 + + + + + - - - The editor will display a symbol to indicate the presence of a tab in the text. - - - &Highlight tabulators - - + + + Qt::Horizontal + + + + 0 + 20 + + + - - - Highlight trailing &spaces - - + + + Dynamic word wrap &indicators (if applicable): + + + cmbDynamicWordWrapIndicator + + - - - 1 - - - - - - Highlight marker size: - - - - - - - Size of the visible highlight marker. - - - Qt::Horizontal - - - 1 - - - 5 - - - 1 - - - - - + + + Choose when the Dynamic Word Wrap Indicators should be displayed. + + - - - - - - - Advanced - - + + + + - - - If this is enabled, the editor will display vertical lines to help identify indent lines. - - - Show i&ndentation lines - - + + + Qt::Horizontal + + + + 0 + 20 + + + - - - If this is enabled, the range between the selected matching brackets will be highlighted. - - - Highlight range between selected brackets - - + + + &Align dynamically wrapped lines to indentation depth: + + + sbDynamicWordWrapDepth + + - - - Flash matching brackets - - - If this is enabled, matching brackets are animated for better visibility. - - - Animate bracket matching - - + + + + 0 + 0 + + + + <p>Enables the start of dynamically wrapped lines to be aligned vertically to the indentation level of the first line. This can help to make code and markup more readable.</p><p>Additionally, this allows you to set a maximum width of the screen, as a percentage, after which dynamically wrapped lines will no longer be vertically aligned. For example, at 50%, lines whose indentation levels are deeper than 50% of the width of the screen will not have vertical alignment applied to subsequent wrapped lines.</p> + + + Disabled + + + % of View Width + + + 80 + + + 10 + + - - - - When this setting is enabled, the editor view automatically folds + + + + + + + + Qt::Horizontal + + + + 0 + 20 + + + + + + + + + + + + + Whitespace Highlighting + + + + + + The editor will display a symbol to indicate the presence of a tab in the text. + + + &Highlight tabulators + + + + + + + Highlight trailing &spaces + + + + + + + true + + + + + + Highlight marker size: + + + + + + + Size of the visible highlight marker. + + + -1 + + + -1 + + + 1 + + + Qt::Horizontal + + + + + + + + + + + + + Advanced + + + + + + If this is enabled, the editor will display vertical lines to help identify indent lines. + + + Show i&ndentation lines + + + + + + + If this is enabled, the range between the selected matching brackets will be highlighted. + + + Highlight range between selected brackets + + + + + + + Flash matching brackets + + + If this is enabled, matching brackets are animated for better visibility. + + + Animate bracket matching + + + + + + + When this setting is enabled, the editor view automatically folds comment blocks that start on the first line of the document. This is helpful to hide license headers which are commonly placed at the beginning of a file. - - - Fold first line - - - - - - - Show/hide word count in status bar - - - Show word count - - - - - - - Show/hide line count in status bar - - - Show line count - - - - - + + + Fold first line + + - - - Qt::Vertical - - - - 0 - 1 - - - + + + Show/hide word count in status bar + + + Show word count + + + + + + + Show/hide line count in status bar + + + Show line count + + - - - - - KComboBox - QComboBox -
kcombobox.h
-
-
- - - - gbWordWrap - toggled(bool) - cmbDynamicWordWrapIndicator - setEnabled(bool) - - - 115 - 7 - - - 340 - 44 - - - - - gbWordWrap - toggled(bool) - sbDynamicWordWrapDepth - setEnabled(bool) - - - 59 - 6 - - - 385 - 72 - - - - + + + + + + + Qt::Vertical + + + + 0 + 1 + + + + + + + + + KComboBox + QComboBox +
kcombobox.h
+
+
+ + + + gbWordWrap + toggled(bool) + cmbDynamicWordWrapIndicator + setEnabled(bool) + + + 115 + 7 + + + 340 + 44 + + + + + gbWordWrap + toggled(bool) + sbDynamicWordWrapDepth + setEnabled(bool) + + + 59 + 6 + + + 385 + 72 + + + +
diff --git a/src/utils/kateconfig.h b/src/utils/kateconfig.h --- a/src/utils/kateconfig.h +++ b/src/utils/kateconfig.h @@ -445,6 +445,9 @@ bool dynWordWrap() const; void setDynWordWrap(bool wrap); + bool dynWrapAtStaticMarker() const; + void setDynWrapAtStaticMarker(bool on); + int dynWordWrapIndicators() const; void setDynWordWrapIndicators(int mode); @@ -583,6 +586,7 @@ private: bool m_dynWordWrap; + bool m_dynWrapAtStaticMarker; int m_dynWordWrapIndicators; int m_dynWordWrapAlignIndent; bool m_lineNumbers; @@ -619,6 +623,7 @@ bool m_backspaceRemoveComposed; bool m_dynWordWrapSet : 1; + bool m_dynWrapAtStaticMarkerSet : 1; bool m_dynWordWrapIndicatorsSet : 1; bool m_dynWordWrapAlignIndentSet : 1; bool m_lineNumbersSet : 1; diff --git a/src/utils/kateconfig.cpp b/src/utils/kateconfig.cpp --- a/src/utils/kateconfig.cpp +++ b/src/utils/kateconfig.cpp @@ -1229,6 +1229,7 @@ : m_dynWordWrapSet(false), + m_dynWrapAtStaticMarkerSet(false), m_dynWordWrapIndicatorsSet(false), m_dynWordWrapAlignIndentSet(false), m_lineNumbersSet(false), @@ -1278,6 +1279,7 @@ m_maxHistorySize(100), m_showWordCount(false), m_dynWordWrapSet(false), + m_dynWrapAtStaticMarkerSet(false), m_dynWordWrapIndicatorsSet(false), m_dynWordWrapAlignIndentSet(false), m_lineNumbersSet(false), @@ -1324,6 +1326,7 @@ { const char KEY_SEARCH_REPLACE_FLAGS[] = "Search/Replace Flags"; const char KEY_DYN_WORD_WRAP[] = "Dynamic Word Wrap"; +const char KEY_DYN_WORD_WRAP_AT_STATIC_MARKER[] = "Dynamic Word Wrap At Static Marker"; const char KEY_DYN_WORD_WRAP_INDICATORS[] = "Dynamic Word Wrap Indicators"; const char KEY_DYN_WORD_WRAP_ALIGN_INDENT[] = "Dynamic Word Wrap Align Indent"; const char KEY_LINE_NUMBERS[] = "Line Numbers"; @@ -1366,6 +1369,7 @@ // default on setDynWordWrap(config.readEntry(KEY_DYN_WORD_WRAP, true)); + setDynWrapAtStaticMarker(config.readEntry(KEY_DYN_WORD_WRAP_AT_STATIC_MARKER, false)); setDynWordWrapIndicators(config.readEntry(KEY_DYN_WORD_WRAP_INDICATORS, 1)); setDynWordWrapAlignIndent(config.readEntry(KEY_DYN_WORD_WRAP_ALIGN_INDENT, 80)); @@ -1429,6 +1433,7 @@ void KateViewConfig::writeConfig(KConfigGroup &config) { config.writeEntry(KEY_DYN_WORD_WRAP, dynWordWrap()); + config.writeEntry(KEY_DYN_WORD_WRAP_AT_STATIC_MARKER, dynWrapAtStaticMarker()); config.writeEntry(KEY_DYN_WORD_WRAP_INDICATORS, dynWordWrapIndicators()); config.writeEntry(KEY_DYN_WORD_WRAP_ALIGN_INDENT, dynWordWrapAlignIndent()); @@ -1531,6 +1536,29 @@ configEnd(); } +bool KateViewConfig::dynWrapAtStaticMarker() const +{ + if (m_dynWrapAtStaticMarkerSet || isGlobal()) { + return m_dynWrapAtStaticMarker; + } + + return s_global->dynWrapAtStaticMarker(); +} + +void KateViewConfig::setDynWrapAtStaticMarker(bool on) +{ + if (m_dynWrapAtStaticMarkerSet && m_dynWrapAtStaticMarker == on) { + return; + } + + configStart(); + + m_dynWrapAtStaticMarkerSet = true; + m_dynWrapAtStaticMarker = on; + + configEnd(); +} + int KateViewConfig::dynWordWrapIndicators() const { if (m_dynWordWrapIndicatorsSet || isGlobal()) { diff --git a/src/view/kateviewinternal.cpp b/src/view/kateviewinternal.cpp --- a/src/view/kateviewinternal.cpp +++ b/src/view/kateviewinternal.cpp @@ -614,8 +614,15 @@ bool blocked = m_lineScroll->blockSignals(true); - if (width() != cache()->viewWidth()) { - cache()->setViewWidth(width()); + int wrapWidth = width(); + if (view()->config()->dynWrapAtStaticMarker() && view()->config()->dynWordWrap()) { + // We need to transform char count to a pixel width, stolen from PrintPainter::updateCache() + QString s; s.fill(QLatin1Char('5'), view()->doc()->config()->wordWrapAt()); + wrapWidth = qMin(width(), static_cast(renderer()->currentFontMetrics().width(s))); + } + + if (wrapWidth != cache()->viewWidth()) { + cache()->setViewWidth(wrapWidth); changed = true; }