Kate
katejscript.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 #ifndef __kate_jscript_h__
00021 #define __kate_jscript_h__
00022
00023 #include "../interfaces/document.h"
00024 #include "kateindentscriptabstracts.h"
00025 #include <qdict.h>
00026 #include <kdebug.h>
00030 class KateDocument;
00031 class KateView;
00032 class QString;
00033 class KateJSDocument;
00034 class KateJSView;
00035 class KateJSIndenter;
00036 class KateDocCursor;
00037
00041 namespace KJS {
00042 class Object;
00043 class ObjectImp;
00044 class Interpreter;
00045 class ExecState;
00046 }
00047
00052 class KateJScript
00053 {
00054 public:
00058 KateJScript ();
00059
00063 virtual ~KateJScript ();
00064
00071 KJS::ObjectImp *wrapDocument (KJS::ExecState *exec, KateDocument *doc);
00072
00079 KJS::ObjectImp *wrapView (KJS::ExecState *exec, KateView *view);
00080
00090 bool execute (KateView *view, const QString &script, QString &errorMsg);
00091
00092 protected:
00096 KJS::Object *m_global;
00097
00101 KJS::Interpreter *m_interpreter;
00102
00106 KJS::Object *m_document;
00107
00111 KJS::Object *m_view;
00112 };
00113
00114 class KateJScriptManager : public Kate::Command
00115 {
00116 private:
00120 class Script
00121 {
00122 public:
00127 inline QString desktopFilename () { return filename.left(filename.length()-2).append ("desktop"); }
00128
00129 public:
00133 QString name;
00134
00138 QString filename;
00139
00143 bool desktopFileExists;
00144 };
00145
00146 public:
00147 KateJScriptManager ();
00148 ~KateJScriptManager ();
00149
00150 private:
00155 void collectScripts (bool force = false);
00156
00157
00158
00159
00160 public:
00168 bool exec( class Kate::View *view, const QString &cmd, QString &errorMsg );
00169
00177 bool help( class Kate::View *view, const QString &cmd, QString &msg );
00178
00183 QStringList cmds();
00184
00185 private:
00189 QDict<KateJScriptManager::Script> m_scripts;
00190 };
00191
00192 class KateIndentJScriptImpl: public KateIndentScriptImplAbstract {
00193 public:
00194 KateIndentJScriptImpl(const QString& internalName,
00195 const QString &filePath, const QString &niceName,
00196 const QString ©right, double version);
00197 ~KateIndentJScriptImpl();
00198
00199 virtual bool processChar( class Kate::View *view, QChar c, QString &errorMsg );
00200 virtual bool processLine( class Kate::View *view, const KateDocCursor &line, QString &errorMsg );
00201 virtual bool processNewline( class Kate::View *view, const KateDocCursor &begin, bool needcontinue, QString &errorMsg );
00202 protected:
00203 virtual void decRef();
00204 private:
00205 KateJSView *m_viewWrapper;
00206 KateJSDocument *m_docWrapper;
00207 KJS::Object *m_indenter;
00208 KJS::Interpreter *m_interpreter;
00209 bool setupInterpreter(QString &errorMsg);
00210 void deleteInterpreter();
00211 };
00212
00213 class KateIndentJScriptManager: public KateIndentScriptManagerAbstract
00214 {
00215
00216 public:
00217 KateIndentJScriptManager ();
00218 virtual ~KateIndentJScriptManager ();
00219 virtual KateIndentScript script(const QString &scriptname);
00220 private:
00225 void collectScripts (bool force = false);
00226 void parseScriptHeader(const QString &filePath,
00227 QString *niceName,QString *copyright,double *version);
00228 QDict<KateIndentJScriptImpl> m_scripts;
00229 };
00230
00231 #endif
00232
00233