aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/glsleditor
diff options
context:
space:
mode:
authorDavid Schulz <david.schulz@qt.io>2016-08-25 13:25:45 +0200
committerDavid Schulz <david.schulz@qt.io>2016-08-31 05:33:56 +0000
commit89ff2c1db5ee2068cf763ff1789b17b7f2afa118 (patch)
treee09226f489917c0263745f3e54858be6abaa8868 /src/plugins/glsleditor
parentb97bc4016f90435fe9e82c3c2855804a34ca97de (diff)
Editor: Collect indentation for a list of text blocks
Allows the indenter to reuse code formatter structures. Task-number: QTCREATORBUG-16420 Change-Id: Ie906d7fdcb50798da02ef5b750fb03ae752aadc1 Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
Diffstat (limited to 'src/plugins/glsleditor')
-rw-r--r--src/plugins/glsleditor/glslindenter.cpp19
-rw-r--r--src/plugins/glsleditor/glslindenter.h2
2 files changed, 21 insertions, 0 deletions
diff --git a/src/plugins/glsleditor/glslindenter.cpp b/src/plugins/glsleditor/glslindenter.cpp
index 33aa847064..3b229f0c90 100644
--- a/src/plugins/glsleditor/glslindenter.cpp
+++ b/src/plugins/glsleditor/glslindenter.cpp
@@ -124,5 +124,24 @@ int GlslIndenter::indentFor(const QTextBlock &block, const TextEditor::TabSettin
return indent;
}
+TextEditor::IndentationForBlock
+GlslIndenter::indentationForBlocks(const QVector<QTextBlock> &blocks,
+ const TextEditor::TabSettings &tabSettings)
+{
+ CppTools::QtStyleCodeFormatter codeFormatter(tabSettings,
+ CppTools::CppToolsSettings::instance()->cppCodeStyle()->codeStyleSettings());
+
+ codeFormatter.updateStateUntil(blocks.last());
+
+ TextEditor::IndentationForBlock ret;
+ foreach (QTextBlock block, blocks) {
+ int indent;
+ int padding;
+ codeFormatter.indentFor(block, &indent, &padding);
+ ret.insert(block.blockNumber(), indent);
+ }
+ return ret;
+}
+
} // namespace Internal
} // namespace GlslEditor
diff --git a/src/plugins/glsleditor/glslindenter.h b/src/plugins/glsleditor/glslindenter.h
index e52a024b10..42696f0d99 100644
--- a/src/plugins/glsleditor/glslindenter.h
+++ b/src/plugins/glsleditor/glslindenter.h
@@ -48,6 +48,8 @@ public:
const TextEditor::TabSettings &tabSettings) override;
int indentFor(const QTextBlock &block, const TextEditor::TabSettings &tabSettings) override;
+ TextEditor::IndentationForBlock indentationForBlocks(const QVector<QTextBlock> &blocks,
+ const TextEditor::TabSettings &tabSettings) override;
};
} // namespace Internal