• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • applications API Reference
  • KDE Home
  • Contact Us
 

Kate

  • kde-4.14
  • applications
  • kate
  • part
  • utils
kateautoindent.h
Go to the documentation of this file.
1 /* This file is part of the KDE libraries
2  Copyright (C) 2003 Jesse Yurkovich <yurkjes@iit.edu>
3  Copyright (C) 2004 >Anders Lund <anders@alweb.dk> (KateVarIndent class)
4  Copyright (C) 2005 Dominik Haumann <dhdev@gmx.de> (basic support for config page)
5 
6  This library is free software; you can redistribute it and/or
7  modify it under the terms of the GNU Library General Public
8  License version 2 as published by the Free Software Foundation.
9 
10  This library is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  Library General Public License for more details.
14 
15  You should have received a copy of the GNU Library General Public License
16  along with this library; see the file COPYING.LIB. If not, write to
17  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18  Boston, MA 02110-1301, USA.
19 */
20 
21 #ifndef __KATE_AUTO_INDENT_H__
22 #define __KATE_AUTO_INDENT_H__
23 
24 #include "kateconfig.h"
25 
26 #include <QtCore/QObject>
27 
28 #include <ktexteditor/cursor.h>
29 #include <kactionmenu.h>
30 
31 class KateDocument;
32 class KateIndentScript;
33 class KateHighlighting;
34 
40 class KateAutoIndent : public QObject
41 {
42  Q_OBJECT
43  /*
44  * Static methods to list indention modes
45  */
46  public:
51  static QStringList listModes ();
52 
57  static QStringList listIdentifiers ();
58 
64  static QString modeName (int mode);
65 
71  static QString modeDescription (int mode);
72 
78  static QString modeRequiredStyle(int mode);
79 
85  static uint modeNumber (const QString &name);
86 
91  static int modeCount ();
92 
93  /*
94  * Construction + Destruction
95  */
96  public:
101  explicit KateAutoIndent (KateDocument *doc);
102 
106  ~KateAutoIndent ();
107 
108  /*
109  * Internal helper for the subclasses and itself
110  */
111  private:
119  QString tabString (int length, int align) const;
120 
128  bool doIndent(int line, int indentDepth, int align = 0);
129 
137  bool doIndentRelative(int line, int change);
138 
143  void keepIndent ( int line );
144 
151  void scriptIndent (KateView *view, const KTextEditor::Cursor &position, QChar typedChar);
152 
156  static bool isStyleProvided(const KateIndentScript *script, const KateHighlighting *highlight);
157 
158  public:
165  void setMode (const QString &name);
166 
172  void checkRequiredStyle();
173 
177  const QString &modeName () const { return m_mode; }
178 
183  void updateConfig ();
184 
194  bool changeIndent (const KTextEditor::Range &range, int change);
195 
204  void indent (KateView *view, const KTextEditor::Range &range);
205 
213  void userTypedChar (KateView *view, const KTextEditor::Cursor &position, QChar typedChar);
214 
215  public Q_SLOTS:
216  void reloadScript();
217 
218  /*
219  * needed data
220  */
221  private:
222  KateDocument *doc;
223  int tabWidth;
224  int indentWidth;
225  bool useSpaces;
226  bool keepExtra;
227  QString m_mode;
228  KateIndentScript *m_script;
229 };
230 
235 class KateViewIndentationAction : public KActionMenu
236 {
237  Q_OBJECT
238 
239  public:
240  KateViewIndentationAction(KateDocument *_doc, const QString& text, QObject *parent);
241 
242  private:
243  KateDocument* doc;
244  QActionGroup *actionGroup;
245 
246  public Q_SLOTS:
247  void slotAboutToShow();
248 
249  private Q_SLOTS:
250  void setMode (QAction*);
251 };
252 
253 #endif
254 
255 // kate: space-indent on; indent-width 2; replace-tabs on;
KateViewIndentationAction::slotAboutToShow
void slotAboutToShow()
Definition: kateautoindent.cpp:471
KateAutoIndent::modeDescription
static QString modeDescription(int mode)
Return the mode description.
Definition: kateautoindent.cpp:83
KateAutoIndent::updateConfig
void updateConfig()
Update indenter's configuration (indention width, etc.) Is called in the updateConfig() of the docume...
Definition: kateautoindent.cpp:370
QActionGroup
QChar
KateAutoIndent::setMode
void setMode(const QString &name)
Switch indenter Nop if already set to given mode Otherwise switch to given indenter or to "None" if n...
Definition: kateautoindent.cpp:304
KateAutoIndent::indent
void indent(KateView *view, const KTextEditor::Range &range)
The document requests the indenter to indent the given range of existing text.
Definition: kateautoindent.cpp:415
KateAutoIndent::modeRequiredStyle
static QString modeRequiredStyle(int mode)
Return the syntax highlighting style required to use this mode.
Definition: kateautoindent.cpp:94
KateAutoIndent::listIdentifiers
static QStringList listIdentifiers()
List all possible names, i.e.
Definition: kateautoindent.cpp:55
QObject::name
const char * name() const
KateAutoIndent
Provides Auto-Indent functionality for katepart.
Definition: kateautoindent.h:40
KateViewIndentationAction::KateViewIndentationAction
KateViewIndentationAction(KateDocument *_doc, const QString &text, QObject *parent)
Definition: kateautoindent.cpp:464
QObject
KateAutoIndent::modeNumber
static uint modeNumber(const QString &name)
Maps name -> index.
Definition: kateautoindent.cpp:102
QString
KateIndentScript
A specialized class for scripts that are of type KateScriptInformation::IndentationScript.
Definition: kateindentscript.h:94
QStringList
KateView
Definition: kateview.h:77
KateDocument
Definition: katedocument.h:74
KateAutoIndent::userTypedChar
void userTypedChar(KateView *view, const KTextEditor::Cursor &position, QChar typedChar)
The user typed some char, the indenter can react on this ' ' will be send as char if the user wraps a...
Definition: kateautoindent.cpp:436
KateViewIndentationAction
This action provides a list of available indenters and gets plugged into the KateView's KActionCollec...
Definition: kateautoindent.h:235
KateAutoIndent::modeCount
static int modeCount()
count of modes
Definition: kateautoindent.cpp:65
KateAutoIndent::changeIndent
bool changeIndent(const KTextEditor::Range &range, int change)
Function to provide the common indent/unindent/clean indent functionality to the document This should...
Definition: kateautoindent.cpp:381
KActionMenu
KateAutoIndent::modeName
const QString & modeName() const
mode name
Definition: kateautoindent.h:177
KateHighlighting
Definition: katehighlight.h:119
QAction
kateconfig.h
KateAutoIndent::KateAutoIndent
KateAutoIndent(KateDocument *doc)
Constructor, creates dummy indenter "None".
Definition: kateautoindent.cpp:111
KateAutoIndent::~KateAutoIndent
~KateAutoIndent()
Destructor.
Definition: kateautoindent.cpp:121
KateAutoIndent::listModes
static QStringList listModes()
List all possible modes by name, i.e.
Definition: kateautoindent.cpp:45
KateAutoIndent::reloadScript
void reloadScript()
Definition: kateautoindent.cpp:253
KateAutoIndent::checkRequiredStyle
void checkRequiredStyle()
Check if the current highlighting mode provides the style required by the current indenter...
Definition: kateautoindent.cpp:355
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Sat May 9 2020 03:56:57 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

Kate

Skip menu "Kate"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Related Pages

applications API Reference

Skip menu "applications API Reference"
  •   kate
  •       kate
  •   KTextEditor
  •   Kate
  • Konsole

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal