KTextEditor

kateautoindent.h
1 /*
2  SPDX-FileCopyrightText: 2003 Jesse Yurkovich <[email protected]>
3 
4  KateVarIndent class:
5  SPDX-FileCopyrightText: 2004 Anders Lund <[email protected]>
6 
7  Basic support for config page:
8  SPDX-FileCopyrightText: 2005 Dominik Haumann <[email protected]>
9 
10  SPDX-License-Identifier: LGPL-2.0-or-later
11 */
12 
13 #ifndef KATE_AUTO_INDENT_H
14 #define KATE_AUTO_INDENT_H
15 
16 #include "kateconfig.h"
17 
18 #include <QObject>
19 
20 #include <KActionMenu>
21 #include <ktexteditor/cursor.h>
22 
23 namespace KTextEditor
24 {
25 class DocumentPrivate;
26 }
27 class KateIndentScript;
28 class KateHighlighting;
29 
35 class KateAutoIndent : public QObject
36 {
37  Q_OBJECT
38  /*
39  * Static methods to list indention modes
40  */
41 public:
46  static QStringList listModes();
47 
52  static QStringList listIdentifiers();
53 
59  static QString modeName(int mode);
60 
66  static QString modeDescription(int mode);
67 
73  static QString modeRequiredStyle(int mode);
74 
80  static uint modeNumber(const QString &name);
81 
86  static int modeCount();
87 
88  /*
89  * Construction + Destruction
90  */
91 public:
96  explicit KateAutoIndent(KTextEditor::DocumentPrivate *doc);
97 
101  ~KateAutoIndent();
102 
103  /*
104  * Internal helper for the subclasses and itself
105  */
106 private:
114  QString tabString(int length, int align) const;
115 
123  bool doIndent(int line, int indentDepth, int align = 0);
124 
132  bool doIndentRelative(int line, int change);
133 
138  void keepIndent(int line);
139 
146  void scriptIndent(KTextEditor::ViewPrivate *view, const KTextEditor::Cursor &position, QChar typedChar);
147 
151  static bool isStyleProvided(const KateIndentScript *script, const KateHighlighting *highlight);
152 
153 public:
160  void setMode(const QString &name);
161 
167  void checkRequiredStyle();
168 
172  const QString &modeName() const
173  {
174  return m_mode;
175  }
176 
181  void updateConfig();
182 
192  bool changeIndent(const KTextEditor::Range &range, int change);
193 
202  void indent(KTextEditor::ViewPrivate *view, const KTextEditor::Range &range);
203 
211  void userTypedChar(KTextEditor::ViewPrivate *view, const KTextEditor::Cursor &position, QChar typedChar);
212 
213 public Q_SLOTS:
214  void reloadScript();
215 
216  /*
217  * needed data
218  */
219 private:
220  KTextEditor::DocumentPrivate *doc;
221  int tabWidth;
222  int indentWidth;
223  bool useSpaces;
224  bool keepExtra;
225  QString m_mode;
226  KateIndentScript *m_script;
227 };
228 
234 {
235  Q_OBJECT
236 
237 public:
238  KateViewIndentationAction(KTextEditor::DocumentPrivate *_doc, const QString &text, QObject *parent);
239 
240 private:
241  KTextEditor::DocumentPrivate *doc;
242  QActionGroup *actionGroup;
243 
244 public Q_SLOTS:
245  void slotAboutToShow();
246 
247 private Q_SLOTS:
248  void setMode(QAction *);
249 };
250 
251 #endif
bool setMode(const QString &name) override
Set the current mode of the document by giving its name.
QString mode() const override
Return the name of the currently used mode.
The Cursor represents a position in a Document.
Definition: cursor.h:71
Provides Auto-Indent functionality for katepart.
The KTextEditor namespace contains all the public API that is required to use the KTextEditor compone...
Definition: katetextblock.h:21
A specialized class for scripts that are of type ScriptType::Indentation.
An object representing a section of text, from one Cursor to another.
This action provides a list of available indenters and gets plugged into the KTextEditor::ViewPrivate...
const QString & modeName() const
mode name
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Sat Jan 23 2021 03:31:32 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.