blob: 3bd5ad1c6bd3e50ad67ed8806b9d2faa1c8f2bd1 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
// Copyright (C) Filippo Cucchetto <filippocucchetto@gmail.com>
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0+ OR GPL-3.0 WITH Qt-GPL-exception-1.0
#pragma once
#include <texteditor/textindenter.h>
namespace Nim {
class NimIndenter : public TextEditor::TextIndenter
{
public:
explicit NimIndenter(QTextDocument *doc);
bool isElectricCharacter(const QChar &ch) const override;
void indentBlock(const QTextBlock &block,
const QChar &typedChar,
const TextEditor::TabSettings &settings,
int cursorPositionInEditor = -1) override;
private:
static const QSet<QChar> &electricCharacters();
bool startsBlock(const QString &line, int state) const;
bool endsBlock(const QString &line, int state) const;
int calculateIndentationDiff(const QString &previousLine,
int previousState,
int indentSize) const;
static QString rightTrimmed(const QString &other);
};
} // namespace Nim
|