Kate
kateautoindent.h
Go to the documentation of this file.
00001 /* This file is part of the KDE libraries 00002 Copyright (C) 2003 Jesse Yurkovich <yurkjes@iit.edu> 00003 Copyright (C) 2004 >Anders Lund <anders@alweb.dk> (KateVarIndent class) 00004 Copyright (C) 2005 Dominik Haumann <dhdev@gmx.de> (basic support for config page) 00005 00006 This library is free software; you can redistribute it and/or 00007 modify it under the terms of the GNU Library General Public 00008 License version 2 as published by the Free Software Foundation. 00009 00010 This library is distributed in the hope that it will be useful, 00011 but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00013 Library General Public License for more details. 00014 00015 You should have received a copy of the GNU Library General Public License 00016 along with this library; see the file COPYING.LIB. If not, write to 00017 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 00018 Boston, MA 02110-1301, USA. 00019 */ 00020 00021 #ifndef __KATE_AUTO_INDENT_H__ 00022 #define __KATE_AUTO_INDENT_H__ 00023 00024 #include "kateconfig.h" 00025 00026 #include <QtCore/QObject> 00027 00028 #include <ktexteditor/cursor.h> 00029 #include <kactionmenu.h> 00030 00031 class KateDocument; 00032 class KateIndentScript; 00033 class KateHighlighting; 00034 00040 class KateAutoIndent : public QObject 00041 { 00042 Q_OBJECT 00043 /* 00044 * Static methods to list indention modes 00045 */ 00046 public: 00051 static QStringList listModes (); 00052 00058 static QString modeName (int mode); 00059 00065 static QString modeDescription (int mode); 00066 00072 static QString modeRequiredStyle(int mode); 00073 00079 static uint modeNumber (const QString &name); 00080 00085 static int modeCount (); 00086 00087 /* 00088 * Construction + Destruction 00089 */ 00090 public: 00095 explicit KateAutoIndent (KateDocument *doc); 00096 00100 ~KateAutoIndent (); 00101 00102 /* 00103 * Internal helper for the subclasses and itself 00104 */ 00105 private: 00113 QString tabString (int length, int align) const; 00114 00122 bool doIndent(int line, int indentDepth, int align = 0); 00123 00131 bool doIndentRelative(int line, int change); 00132 00137 void keepIndent ( int line ); 00138 00145 void scriptIndent (KateView *view, const KTextEditor::Cursor &position, QChar typedChar); 00146 00150 static bool isStyleProvided(const KateIndentScript *script, const KateHighlighting *highlight); 00151 00152 public: 00159 void setMode (const QString &name); 00160 00166 void checkRequiredStyle(); 00167 00171 const QString &modeName () const { return m_mode; } 00172 00177 void updateConfig (); 00178 00188 bool changeIndent (const KTextEditor::Range &range, int change); 00189 00198 void indent (KateView *view, const KTextEditor::Range &range); 00199 00207 void userTypedChar (KateView *view, const KTextEditor::Cursor &position, QChar typedChar); 00208 00209 public Q_SLOTS: 00210 void reloadScript(); 00211 00212 /* 00213 * needed data 00214 */ 00215 private: 00216 KateDocument *doc; 00217 int tabWidth; 00218 int indentWidth; 00219 bool useSpaces; 00220 bool keepExtra; 00221 QString m_mode; 00222 KateIndentScript *m_script; 00223 }; 00224 00229 class KateViewIndentationAction : public KActionMenu 00230 { 00231 Q_OBJECT 00232 00233 public: 00234 KateViewIndentationAction(KateDocument *_doc, const QString& text, QObject *parent); 00235 00236 private: 00237 KateDocument* doc; 00238 QActionGroup *actionGroup; 00239 00240 public Q_SLOTS: 00241 void slotAboutToShow(); 00242 00243 private Q_SLOTS: 00244 void setMode (QAction*); 00245 }; 00246 00247 #endif 00248 00249 // kate: space-indent on; indent-width 2; replace-tabs on;
KDE 4.6 API Reference