kateautoindent.h
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef __KATE_AUTO_INDENT_H__
00020 #define __KATE_AUTO_INDENT_H__
00021
00022 #include "katecursor.h"
00023 #include "kateconfig.h"
00024
00025 class KateDocument;
00026
00027 class KateAutoIndent
00028 {
00029
00030
00031
00032 public:
00033 static KateAutoIndent *createIndenter (KateDocument *doc, uint mode);
00034
00035 static QStringList listModes ();
00036
00037 static QString modeName (uint mode);
00038
00039 static QString modeDescription (uint mode);
00040
00041 static uint modeNumber (const QString &name);
00042
00043 public:
00044 KateAutoIndent (KateDocument *doc);
00045 virtual ~KateAutoIndent ();
00046
00047
00048 void updateConfig ();
00049
00050
00051
00052
00053 virtual void processNewline (KateDocCursor &cur, bool needContinue);
00054
00055
00056 virtual void processChar (QChar ) { }
00057
00058 virtual uint modeNumber () const { return KateDocumentConfig::imNormal; };
00059
00060 protected:
00061
00062 bool isBalanced (KateDocCursor &begin, const KateDocCursor &end, QChar open, QChar close) const;
00063
00064
00065
00066 bool skipBlanks (KateDocCursor &cur, KateDocCursor &max, bool newline) const;
00067
00068
00069 uint measureIndent (KateDocCursor &cur) const;
00070
00071
00072 QString tabString (uint length) const;
00073
00074
00075 KateDocument *doc;
00076
00077 uint tabWidth;
00078 uint indentWidth;
00079 uint commentAttrib;
00080 bool useSpaces;
00081 };
00082
00083 class KateCSmartIndent : public KateAutoIndent
00084 {
00085 public:
00086 KateCSmartIndent (KateDocument *doc);
00087 ~KateCSmartIndent ();
00088
00089 virtual void processNewline (KateDocCursor &begin, bool needContinue);
00090 virtual void processChar (QChar c);
00091
00092 virtual uint modeNumber () const { return KateDocumentConfig::imCStyle; };
00093
00094 private:
00095 uint calcIndent (KateDocCursor &begin, bool needContinue);
00096 uint calcContinue (KateDocCursor &begin, KateDocCursor &end);
00097
00098 bool allowSemi;
00099 };
00100
00101 class KatePythonIndent : public KateAutoIndent
00102 {
00103 public:
00104 KatePythonIndent (KateDocument *doc);
00105 ~KatePythonIndent ();
00106
00107 virtual void processNewline (KateDocCursor &begin, bool needContinue);
00108
00109 virtual uint modeNumber () const { return KateDocumentConfig::imPythonStyle; };
00110
00111 private:
00112 int calcExtra (int &prevBlock, int &pos, KateDocCursor &end);
00113
00114 static QRegExp endWithColon;
00115 static QRegExp stopStmt;
00116 static QRegExp blockBegin;
00117 };
00118
00119 #endif
00120
00121
This file is part of the documentation for kate Library Version 3.2.1.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Thu Mar 4 22:45:57 2004 by
doxygen 1.3.6-20040222 written by
Dimitri van Heesch, © 1997-2003