1 | /* |
2 | SPDX-FileCopyrightText: 2008 Paul Giannaros <paul@giannaros.org> |
3 | SPDX-FileCopyrightText: 2009-2018 Dominik Haumann <dhaumann@kde.org> |
4 | |
5 | SPDX-License-Identifier: LGPL-2.0-or-later |
6 | */ |
7 | |
8 | #ifndef KATE_INDENT_SCRIPT_H |
9 | #define KATE_INDENT_SCRIPT_H |
10 | |
11 | #include "katescript.h" |
12 | |
13 | #include <KTextEditor/Cursor> |
14 | |
15 | namespace KTextEditor |
16 | { |
17 | class ViewPrivate; |
18 | } |
19 | |
20 | class |
21 | { |
22 | public: |
23 | () = default; |
24 | |
25 | inline void (const QString &name) |
26 | { |
27 | m_name = name; |
28 | } |
29 | inline const QString &() const |
30 | { |
31 | return m_name; |
32 | } |
33 | |
34 | inline void (const QString &requiredStyle) |
35 | { |
36 | m_requiredStyle = requiredStyle; |
37 | } |
38 | inline const QString &() const |
39 | { |
40 | return m_requiredStyle; |
41 | } |
42 | |
43 | inline void (const QStringList &indentLanguages) |
44 | { |
45 | m_indentLanguages = indentLanguages; |
46 | } |
47 | inline const QStringList &() const |
48 | { |
49 | return m_indentLanguages; |
50 | } |
51 | |
52 | inline void (int priority) |
53 | { |
54 | m_priority = priority; |
55 | } |
56 | inline int () const |
57 | { |
58 | return m_priority; |
59 | } |
60 | |
61 | inline void (const QString &baseName) |
62 | { |
63 | m_baseName = baseName; |
64 | } |
65 | inline const QString &() const |
66 | { |
67 | return m_baseName; |
68 | } |
69 | |
70 | private: |
71 | QString ; ///< indenter name, e.g. Python |
72 | |
73 | /** |
74 | * If this is an indenter, then this specifies the required syntax |
75 | * highlighting style that must be used for this indenter to work properly. |
76 | * If this property is empty, the indenter doesn't require a specific style. |
77 | */ |
78 | QString ; |
79 | /** |
80 | * If this script is an indenter, then the indentLanguages member specifies |
81 | * which languages this is an indenter for. The values must correspond with |
82 | * the name of a programming language given in a highlighting file (e.g "TI Basic") |
83 | */ |
84 | QStringList ; |
85 | /** |
86 | * If this script is an indenter, this value controls the priority it will take |
87 | * when an indenter for one of the supported languages is requested and multiple |
88 | * indenters are found |
89 | */ |
90 | int = 0; |
91 | |
92 | /** |
93 | * basename of script |
94 | */ |
95 | QString ; |
96 | }; |
97 | |
98 | /** |
99 | * A specialized class for scripts that are of type ScriptType::Indentation. |
100 | */ |
101 | class KateIndentScript : public KateScript |
102 | { |
103 | public: |
104 | explicit (const QString &url, const KateIndentScriptHeader &); |
105 | |
106 | const QString &triggerCharacters(); |
107 | |
108 | const KateIndentScriptHeader &() const; |
109 | |
110 | /** |
111 | * Returns a pair where the first value is the indent amount, and the second |
112 | * value is the alignment. |
113 | */ |
114 | QPair<int, int> indent(KTextEditor::ViewPrivate *view, const KTextEditor::Cursor position, QChar typedCharacter, int indentWidth); |
115 | |
116 | private: |
117 | QString m_triggerCharacters; |
118 | bool = false; |
119 | KateIndentScriptHeader ; |
120 | }; |
121 | |
122 | #endif |
123 | |