Kate
kateautoindent.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef __KATE_AUTO_INDENT_H__
00022 #define __KATE_AUTO_INDENT_H__
00023
00024 #include "katecursor.h"
00025 #include "kateconfig.h"
00026
00027 #include <kactionmenu.h>
00028
00029 class KateDocument;
00030 class KateIndentScript;
00031
00037 class KateAutoIndent
00038 {
00039
00040
00041
00042 public:
00047 static QStringList listModes ();
00048
00054 static QString modeName (int mode);
00055
00061 static QString modeDescription (int mode);
00062
00068 static QString modeRequiredStyle(int mode);
00069
00075 static uint modeNumber (const QString &name);
00076
00081 static int modeCount ();
00082
00083
00084
00085
00086 public:
00091 explicit KateAutoIndent (KateDocument *doc);
00092
00096 ~KateAutoIndent ();
00097
00098
00099
00100
00101 private:
00109 QString tabString (int length, int align) const;
00110
00119 bool doIndent(KateView *view, int line, int indentDepth, int align = 0);
00120
00129 bool doIndentRelative(KateView *view, int line, int change);
00130
00136 void keepIndent ( KateView *view, int line );
00137
00144 void scriptIndent (KateView *view, const KTextEditor::Cursor &position, QChar typedChar);
00145
00150 bool isStyleProvided(KateIndentScript *script);
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
00189 bool changeIndent (KateView *view, const KTextEditor::Range &range, int change);
00190
00199 void indent (KateView *view, const KTextEditor::Range &range);
00200
00208 void userTypedChar (KateView *view, const KTextEditor::Cursor &position, QChar typedChar);
00209
00210
00211
00212
00213 private:
00214 KateDocument *doc;
00215 int tabWidth;
00216 int indentWidth;
00217 bool useSpaces;
00218 bool keepExtra;
00219 QString m_mode;
00220 bool m_normal;
00221 KateIndentScript *m_script;
00222 };
00223
00228 class KateViewIndentationAction : public KActionMenu
00229 {
00230 Q_OBJECT
00231
00232 public:
00233 KateViewIndentationAction(KateDocument *_doc, const QString& text, QObject *parent);
00234
00235 private:
00236 KateDocument* doc;
00237
00238 public Q_SLOTS:
00239 void slotAboutToShow();
00240
00241 private Q_SLOTS:
00242 void setMode (QAction*);
00243 };
00244
00245 #endif
00246
00247