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 <QtCore/QObject>
00028
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
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
00089
00090 public:
00095 explicit KateAutoIndent (KateDocument *doc);
00096
00100 ~KateAutoIndent ();
00101
00102
00103
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
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