forked from qt-creator/qt-creator
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>
This commit is contained in:
@@ -36,26 +36,33 @@ class ClangFormatBaseIndenter : public TextEditor::Indenter
|
||||
public:
|
||||
ClangFormatBaseIndenter(QTextDocument *doc);
|
||||
|
||||
TextEditor::IndentationForBlock indentationForBlocks(
|
||||
const QVector<QTextBlock> &blocks, const TextEditor::TabSettings & /*tabSettings*/) override;
|
||||
TextEditor::IndentationForBlock indentationForBlocks(const QVector<QTextBlock> &blocks,
|
||||
const TextEditor::TabSettings &tabSettings,
|
||||
int cursorPositionInEditor = -1) override;
|
||||
void indent(const QTextCursor &cursor,
|
||||
const QChar &typedChar,
|
||||
const TextEditor::TabSettings & /*tabSettings*/) override;
|
||||
const TextEditor::TabSettings &tabSettings,
|
||||
int cursorPositionInEditor = -1) override;
|
||||
|
||||
void reindent(const QTextCursor &cursor,
|
||||
const TextEditor::TabSettings & /*tabSettings*/) override;
|
||||
const TextEditor::TabSettings &tabSettings,
|
||||
int cursorPositionInEditor = -1) override;
|
||||
|
||||
void formatOrIndent(const QTextCursor &cursor,
|
||||
const TextEditor::TabSettings &tabSettings,
|
||||
int cursorPositionInEditor = -1) override;
|
||||
TextEditor::Replacements format(const QTextCursor &cursor,
|
||||
const TextEditor::TabSettings & /*tabSettings*/) override;
|
||||
const TextEditor::TabSettings &tabSettings,
|
||||
int cursorPositionInEditor = -1) override;
|
||||
|
||||
void indentBlock(const QTextBlock &block,
|
||||
const QChar &typedChar,
|
||||
const TextEditor::TabSettings & /*tabSettings*/) override;
|
||||
const TextEditor::TabSettings &tabSettings,
|
||||
int cursorPositionInEditor = -1) override;
|
||||
|
||||
int indentFor(const QTextBlock &block, const TextEditor::TabSettings & /*tabSettings*/) override;
|
||||
int indentFor(const QTextBlock &block,
|
||||
const TextEditor::TabSettings &tabSettings,
|
||||
int cursorPositionInEditor = -1) override;
|
||||
|
||||
bool isElectricCharacter(const QChar &ch) const override;
|
||||
|
||||
@@ -64,10 +71,10 @@ protected:
|
||||
virtual bool formatCodeInsteadOfIndent() const { return false; }
|
||||
|
||||
private:
|
||||
TextEditor::Replacements format(const QTextCursor &cursor);
|
||||
void indent(const QTextCursor &cursor, const QChar &typedChar);
|
||||
void indentBlock(const QTextBlock &block, const QChar &typedChar);
|
||||
int indentFor(const QTextBlock &block);
|
||||
TextEditor::Replacements format(const QTextCursor &cursor, int cursorPositionInEditor);
|
||||
void indent(const QTextCursor &cursor, const QChar &typedChar, int cursorPositionInEditor);
|
||||
void indentBlock(const QTextBlock &block, const QChar &typedChar, int cursorPositionInEditor);
|
||||
int indentFor(const QTextBlock &block, int cursorPositionInEditor);
|
||||
TextEditor::Replacements replacements(QByteArray buffer,
|
||||
int utf8Offset,
|
||||
int utf8Length,
|
||||
|
||||
Reference in New Issue
Block a user