KTextEditor

kateindentscript.h
1 /*
2  SPDX-FileCopyrightText: 2008 Paul Giannaros <[email protected]>
3  SPDX-FileCopyrightText: 2009-2018 Dominik Haumann <[email protected]>
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 #include "kateview.h"
13 
14 class KateIndentScriptHeader
15 {
16 public:
17  KateIndentScriptHeader() = default;
18 
19  inline void setName(const QString &name)
20  {
21  m_name = name;
22  }
23  inline const QString &name() const
24  {
25  return m_name;
26  }
27 
28  inline void setRequiredStyle(const QString &requiredStyle)
29  {
30  m_requiredStyle = requiredStyle;
31  }
32  inline const QString &requiredStyle() const
33  {
34  return m_requiredStyle;
35  }
36 
37  inline void setIndentLanguages(const QStringList &indentLanguages)
38  {
39  m_indentLanguages = indentLanguages;
40  }
41  inline const QStringList &indentLanguages() const
42  {
43  return m_indentLanguages;
44  }
45 
46  inline void setPriority(int priority)
47  {
48  m_priority = priority;
49  }
50  inline int priority() const
51  {
52  return m_priority;
53  }
54 
55  inline void setBaseName(const QString &baseName)
56  {
57  m_baseName = baseName;
58  }
59  inline const QString &baseName() const
60  {
61  return m_baseName;
62  }
63 
64 private:
65  QString m_name; ///< indenter name, e.g. Python
66 
67  /**
68  * If this is an indenter, then this specifies the required syntax
69  * highlighting style that must be used for this indenter to work properly.
70  * If this property is empty, the indenter doesn't require a specific style.
71  */
72  QString m_requiredStyle;
73  /**
74  * If this script is an indenter, then the indentLanguages member specifies
75  * which languages this is an indenter for. The values must correspond with
76  * the name of a programming language given in a highlighting file (e.g "TI Basic")
77  */
78  QStringList m_indentLanguages;
79  /**
80  * If this script is an indenter, this value controls the priority it will take
81  * when an indenter for one of the supported languages is requested and multiple
82  * indenters are found
83  */
84  int m_priority = 0;
85 
86  /**
87  * basename of script
88  */
89  QString m_baseName;
90 };
91 
92 /**
93  * A specialized class for scripts that are of type ScriptType::Indentation.
94  */
96 {
97 public:
98  explicit KateIndentScript(const QString &url, const KateIndentScriptHeader &header);
99 
100  const QString &triggerCharacters();
101 
102  const KateIndentScriptHeader &indentHeader() const;
103 
104  /**
105  * Returns a pair where the first value is the indent amount, and the second
106  * value is the alignment.
107  */
108  QPair<int, int> indent(KTextEditor::ViewPrivate *view, const KTextEditor::Cursor &position, QChar typedCharacter, int indentWidth);
109 
110 private:
111  QString m_triggerCharacters;
112  bool m_triggerCharactersSet = false;
113  KateIndentScriptHeader m_indentHeader;
114 };
115 
116 #endif
QString name(const QVariant &location)
KateScript objects represent a script that can be executed and inspected.
Definition: katescript.h:106
The Cursor represents a position in a Document.
Definition: cursor.h:71
A specialized class for scripts that are of type ScriptType::Indentation.
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Tue Mar 2 2021 01:49:08 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.