katejscript.h
/* This file is part of the KDE libraries
Copyright (C) 2005 Christoph Cullmann <cullmann@kde.org>
Copyright (C) 2005 Joseph Wenninger <jowenn@kde.org>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License version 2 as published by the Free Software Foundation.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#ifndef __kate_jscript_h__
#define __kate_jscript_h__
#include "../interfaces/document.h"
#include "kateindentscriptabstracts.h"
#include <qdict.h>
#include <kdebug.h>
class KateDocument;
class KateView;
class QString;
class KateJSDocument;
class KateJSView;
class KateJSIndenter;
class KateDocCursor;
namespace KJS {
class Object;
class ObjectImp;
class Interpreter;
class ExecState;
}
class KateJScript
{
public:
KateJScript ();
virtual ~KateJScript ();
KJS::ObjectImp *wrapDocument (KJS::ExecState *exec, KateDocument *doc);
KJS::ObjectImp *wrapView (KJS::ExecState *exec, KateView *view);
bool execute (KateView *view, const QString &script, QString &errorMsg);
protected:
KJS::Object *m_global;
KJS::Interpreter *m_interpreter;
KJS::Object *m_document;
KJS::Object *m_view;
};
class KateJScriptManager : public Kate::Command
{
private:
class Script
{
public:
inline QString desktopFilename () { return filename.left(filename.length()-2).append ("desktop"); }
public:
QString name;
QString filename;
bool desktopFileExists;
};
public:
KateJScriptManager ();
~KateJScriptManager ();
private:
void collectScripts (bool force = false);
//
// Here we deal with the Kate::Command stuff
//
public:
bool exec( class Kate::View *view, const QString &cmd, QString &errorMsg );
bool help( class Kate::View *view, const QString &cmd, QString &msg );
QStringList cmds();
private:
QDict<KateJScriptManager::Script> m_scripts;
};
class KateIndentJScriptImpl: public KateIndentScriptImplAbstract {
public:
KateIndentJScriptImpl(const QString& internalName,
const QString &filePath, const QString &niceName,
const QString &copyright, double version);
~KateIndentJScriptImpl();
virtual bool processChar( class Kate::View *view, QChar c, QString &errorMsg );
virtual bool processLine( class Kate::View *view, const KateDocCursor &line, QString &errorMsg );
virtual bool processNewline( class Kate::View *view, const KateDocCursor &begin, bool needcontinue, QString &errorMsg );
protected:
virtual void decRef();
private:
KateJSView *m_viewWrapper;
KateJSDocument *m_docWrapper;
KJS::Object *m_indenter;
KJS::Interpreter *m_interpreter;
bool setupInterpreter(QString &errorMsg);
void deleteInterpreter();
};
class KateIndentJScriptManager: public KateIndentScriptManagerAbstract
{
public:
KateIndentJScriptManager ();
virtual ~KateIndentJScriptManager ();
virtual KateIndentScript script(const QString &scriptname);
private:
void collectScripts (bool force = false);
void parseScriptHeader(const QString &filePath,
QString *niceName,QString *copyright,double *version);
QDict<KateIndentJScriptImpl> m_scripts;
};
#endif
// kate: space-indent on; indent-width 2; replace-tabs on;
KateDocCursor
Cursor class with a pointer to its document.
Definition: katecursor.h:92
KateJScript::wrapDocument
KJS::ObjectImp * wrapDocument(KJS::ExecState *exec, KateDocument *doc)
creates a JS wrapper object for given KateDocument
Definition: katejscript.cpp:260
KateJScript::m_global
KJS::Object * m_global
global object of interpreter
Definition: katejscript.h:96
KateJScript::execute
bool execute(KateView *view, const QString &script, QString &errorMsg)
execute given script the script will get the doc and view exposed via document and view object in glo...
Definition: katejscript.cpp:270
Kate::View
The Kate::View text editor interface.
Definition: view.h:42
Kate::Command::help
virtual bool help(View *view, const QString &cmd, QString &msg)=0
Shows help for the given view and cmd string, return a bool about success, msg for status...
KateJScript::m_view
KJS::Object * m_view
object for view
Definition: katejscript.h:111
Kate::Command
Kate Commands.
Definition: document.h:96
KateJScript
Whole Kate Part scripting in one classs Allow subclassing to allow specialized scripting engine for i...
Definition: katejscript.h:52
KateJScript::KateJScript
KateJScript()
generate new global interpreter for part scripting
Definition: katejscript.cpp:238
KateJScript::m_interpreter
KJS::Interpreter * m_interpreter
js interpreter
Definition: katejscript.h:101
Kate::Command::cmds
virtual QStringList cmds()=0
Pure text start part of the commands which can be handled by this object which means i...
Kate::Command::exec
virtual bool exec(View *view, const QString &cmd, QString &msg)=0
Execute this command for the given view and cmd string, return a bool about success, msg for status.
KateJScript::m_document
KJS::Object * m_document
object for document
Definition: katejscript.h:106
KateJScript::wrapView
KJS::ObjectImp * wrapView(KJS::ExecState *exec, KateView *view)
creates a JS wrapper object for given KateView
Definition: katejscript.cpp:265
KateJScript::~KateJScript
virtual ~KateJScript()
be destructive
Definition: katejscript.cpp:252

KDE Home | KDE Accessibility Home | Description of Access Keys