From 052ea6d23185943f12cccbf70df0ea52fc0171ba Mon Sep 17 00:00:00 2001 From: hjk Date: Thu, 21 Dec 2023 17:31:38 +0100 Subject: Python: Move highlighter and indenter class definitions to .cpp Change-Id: Ib71d520977034ca66bd84c9188ffed5fe74e1ba0 Reviewed-by: Reviewed-by: David Schulz --- src/plugins/python/pythonindenter.cpp | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) (limited to 'src/plugins/python/pythonindenter.cpp') 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 -- cgit v1.2.3