2022-08-19 15:59:36 +02:00
|
|
|
// Copyright (C) 2016 The Qt Company Ltd.
|
2022-12-21 10:12:09 +01:00
|
|
|
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
2013-01-14 23:11:10 +04:00
|
|
|
|
2016-03-18 07:55:01 +01:00
|
|
|
#pragma once
|
2013-01-14 23:11:10 +04:00
|
|
|
|
2019-01-16 09:37:54 +01:00
|
|
|
#include <texteditor/textindenter.h>
|
2013-01-14 23:11:10 +04:00
|
|
|
|
2019-07-15 12:50:29 +02:00
|
|
|
namespace Python {
|
2013-01-14 23:11:10 +04:00
|
|
|
|
2019-01-16 09:37:54 +01:00
|
|
|
class PythonIndenter : public TextEditor::TextIndenter
|
2013-01-14 23:11:10 +04:00
|
|
|
{
|
2019-01-16 09:37:54 +01:00
|
|
|
public:
|
|
|
|
|
explicit PythonIndenter(QTextDocument *doc);
|
2016-08-03 00:07:44 +02:00
|
|
|
private:
|
2016-01-13 14:32:23 +01:00
|
|
|
bool isElectricCharacter(const QChar &ch) const override;
|
2019-01-28 08:11:20 +01:00
|
|
|
int indentFor(const QTextBlock &block,
|
|
|
|
|
const TextEditor::TabSettings &tabSettings,
|
|
|
|
|
int cursorPositionInEditor = -1) override;
|
2013-01-14 23:11:10 +04:00
|
|
|
|
|
|
|
|
bool isElectricLine(const QString &line) const;
|
2016-01-13 14:32:23 +01:00
|
|
|
int getIndentDiff(const QString &previousLine,
|
|
|
|
|
const TextEditor::TabSettings &tabSettings) const;
|
2013-01-14 23:11:10 +04:00
|
|
|
};
|
|
|
|
|
|
2019-07-15 12:50:29 +02:00
|
|
|
} // namespace Python
|