aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/python/pythonindenter.cpp
diff options
context:
space:
mode:
authorhjk <hjk@qt.io>2023-12-21 17:31:38 +0100
committerhjk <hjk@qt.io>2024-01-12 06:53:40 +0000
commit052ea6d23185943f12cccbf70df0ea52fc0171ba (patch)
tree8011517a3e5e16c34ce14d3c82861ad76e1e3bed /src/plugins/python/pythonindenter.cpp
parent460b1641e0f950f9ba163100763b0fbdc9fb707a (diff)
Python: Move highlighter and indenter class definitions to .cpp
Change-Id: Ib71d520977034ca66bd84c9188ffed5fe74e1ba0 Reviewed-by: <github-actions-qt-creator@cristianadam.eu> Reviewed-by: David Schulz <david.schulz@qt.io>
Diffstat (limited to 'src/plugins/python/pythonindenter.cpp')
-rw-r--r--src/plugins/python/pythonindenter.cpp25
1 files changed, 22 insertions, 3 deletions
diff --git a/src/plugins/python/pythonindenter.cpp b/src/plugins/python/pythonindenter.cpp
index 1ffe095f3a1..b907d0f4531 100644
--- a/src/plugins/python/pythonindenter.cpp
+++ b/src/plugins/python/pythonindenter.cpp
@@ -28,9 +28,23 @@ static QTextBlock previousNonEmptyBlock(const QTextBlock &block)
return result;
}
-PythonIndenter::PythonIndenter(QTextDocument *doc)
- : TextEditor::TextIndenter(doc)
-{}
+class PythonIndenter : public TextEditor::TextIndenter
+{
+public:
+ explicit PythonIndenter(QTextDocument *doc)
+ : TextEditor::TextIndenter(doc)
+ {}
+
+private:
+ bool isElectricCharacter(const QChar &ch) const override;
+ int indentFor(const QTextBlock &block,
+ const TextEditor::TabSettings &tabSettings,
+ int cursorPositionInEditor = -1) override;
+
+ bool isElectricLine(const QString &line) const;
+ int getIndentDiff(const QString &previousLine,
+ const TextEditor::TabSettings &tabSettings) const;
+};
/**
* @brief Does given character change indentation level?
@@ -102,4 +116,9 @@ int PythonIndenter::getIndentDiff(const QString &previousLine,
return 0;
}
+TextEditor::TextIndenter *createPythonIndenter(QTextDocument *doc)
+{
+ return new PythonIndenter(doc);
+}
+
} // namespace Python