diff options
author | Ivan Donchevskii <ivan.donchevskii@qt.io> | 2019-01-28 08:11:20 +0100 |
---|---|---|
committer | Ivan Donchevskii <ivan.donchevskii@qt.io> | 2019-01-31 10:25:18 +0000 |
commit | 1dee275f58e9f9df2e2719325157cfdec42fe1cf (patch) | |
tree | b5d3480d9484a9d0347de6d3d8219f31d70b602e /src/plugins/glsleditor | |
parent | 80fb0178fdd9ee82acfb22aa512c7514868e89d1 (diff) |
ClangFormat: Add cursor position to the indenter interface
Sometimes it's imnportant where the cursor currently is
to properly format the code without affecting the current line.
Change-Id: I8b1fb11d2303adb5f960c7cb80a0ed2e6e45010f
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
Reviewed-by: Marco Bubke <marco.bubke@qt.io>
Diffstat (limited to 'src/plugins/glsleditor')
-rw-r--r-- | src/plugins/glsleditor/glslindenter.cpp | 14 | ||||
-rw-r--r-- | src/plugins/glsleditor/glslindenter.h | 17 |
2 files changed, 21 insertions, 10 deletions
diff --git a/src/plugins/glsleditor/glslindenter.cpp b/src/plugins/glsleditor/glslindenter.cpp index 87b12f98e9..91229d5a5a 100644 --- a/src/plugins/glsleditor/glslindenter.cpp +++ b/src/plugins/glsleditor/glslindenter.cpp @@ -51,7 +51,8 @@ bool GlslIndenter::isElectricCharacter(const QChar &ch) const void GlslIndenter::indentBlock(const QTextBlock &block, const QChar &typedChar, - const TextEditor::TabSettings &tabSettings) + const TextEditor::TabSettings &tabSettings, + int /*cursorPositionInEditor*/) { // TODO: do something with it CppTools::QtStyleCodeFormatter @@ -78,7 +79,8 @@ void GlslIndenter::indentBlock(const QTextBlock &block, void GlslIndenter::indent(const QTextCursor &cursor, const QChar &typedChar, - const TextEditor::TabSettings &tabSettings) + const TextEditor::TabSettings &tabSettings, + int /*cursorPositionInEditor*/) { if (cursor.hasSelection()) { QTextBlock block = m_doc->findBlock(cursor.selectionStart()); @@ -107,7 +109,9 @@ void GlslIndenter::indent(const QTextCursor &cursor, } } -int GlslIndenter::indentFor(const QTextBlock &block, const TextEditor::TabSettings &tabSettings) +int GlslIndenter::indentFor(const QTextBlock &block, + const TextEditor::TabSettings &tabSettings, + int /*cursorPositionInEditor*/) { CppTools::QtStyleCodeFormatter codeFormatter(tabSettings, @@ -122,7 +126,9 @@ int GlslIndenter::indentFor(const QTextBlock &block, const TextEditor::TabSettin } TextEditor::IndentationForBlock GlslIndenter::indentationForBlocks( - const QVector<QTextBlock> &blocks, const TextEditor::TabSettings &tabSettings) + const QVector<QTextBlock> &blocks, + const TextEditor::TabSettings &tabSettings, + int /*cursorPositionInEditor*/) { CppTools::QtStyleCodeFormatter codeFormatter(tabSettings, diff --git a/src/plugins/glsleditor/glslindenter.h b/src/plugins/glsleditor/glslindenter.h index beb6aaa849..271d2c3ce3 100644 --- a/src/plugins/glsleditor/glslindenter.h +++ b/src/plugins/glsleditor/glslindenter.h @@ -39,15 +39,20 @@ public: bool isElectricCharacter(const QChar &ch) const override; void indentBlock(const QTextBlock &block, const QChar &typedChar, - const TextEditor::TabSettings &tabSettings) override; + const TextEditor::TabSettings &tabSettings, + int cursorPositionInEditor = -1) override; void indent(const QTextCursor &cursor, const QChar &typedChar, - 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; + const TextEditor::TabSettings &tabSettings, + int cursorPositionInEditor = -1) override; + + int indentFor(const QTextBlock &block, + const TextEditor::TabSettings &tabSettings, + int cursorPositionInEditor = -1) override; + TextEditor::IndentationForBlock indentationForBlocks(const QVector<QTextBlock> &blocks, + const TextEditor::TabSettings &tabSettings, + int cursorPositionInEditor = -1) override; }; } // namespace Internal |