forked from qt-creator/qt-creator
Texteditor: Add ability to get margin from indenter
And implement it in the clang-format plugin to use the ColumnLimit from the style. This would be quite useful if you're working on different projects with a different ColumnLimit. This way you get an visual representation and do not only have to rely on clang-format. Change-Id: Ib0258e3fba6f45f0f46ce612f806527a47868ad9 Reviewed-by: Leena Miettinen <riitta-leena.miettinen@qt.io> Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
committed by
Björn Schäpers
parent
069efa9483
commit
d9cd74f06d
@@ -1478,6 +1478,7 @@ void TextEditorWidget::openFinishedSuccessfully()
|
||||
moveCursor(QTextCursor::Start);
|
||||
d->updateCannotDecodeInfo();
|
||||
updateTextCodecLabel();
|
||||
updateVisualWrapColumn();
|
||||
}
|
||||
|
||||
TextDocumentPtr TextEditorWidget::textDocumentPtr() const
|
||||
@@ -7438,8 +7439,8 @@ void TextEditorWidget::setDisplaySettings(const DisplaySettings &ds)
|
||||
|
||||
void TextEditorWidget::setMarginSettings(const MarginSettings &ms)
|
||||
{
|
||||
setVisibleWrapColumn(ms.m_showMargin ? ms.m_marginColumn : 0);
|
||||
d->m_marginSettings = ms;
|
||||
updateVisualWrapColumn();
|
||||
|
||||
viewport()->update();
|
||||
extraArea()->update();
|
||||
@@ -8261,6 +8262,24 @@ bool TextEditorWidget::inFindScope(int selectionStart, int selectionEnd)
|
||||
return true;
|
||||
}
|
||||
|
||||
void TextEditorWidget::updateVisualWrapColumn()
|
||||
{
|
||||
auto calcMargin = [this]() {
|
||||
const auto &ms = d->m_marginSettings;
|
||||
|
||||
if (!ms.m_showMargin) {
|
||||
return 0;
|
||||
}
|
||||
if (ms.m_useIndenter) {
|
||||
if (auto margin = d->m_document->indenter()->margin()) {
|
||||
return *margin;
|
||||
}
|
||||
}
|
||||
return ms.m_marginColumn;
|
||||
};
|
||||
setVisibleWrapColumn(calcMargin());
|
||||
}
|
||||
|
||||
void TextEditorWidget::setBlockSelection(bool on)
|
||||
{
|
||||
if (d->m_inBlockSelectionMode == on)
|
||||
|
||||
Reference in New Issue
Block a user