• Skip to content
  • Skip to link menu
Trinity API Reference
  • Trinity API Reference
  • kate
 

kate

  • kate
  • part
katejscript.h
1 /* This file is part of the KDE libraries
2  Copyright (C) 2005 Christoph Cullmann <cullmann@kde.org>
3  Copyright (C) 2005 Joseph Wenninger <jowenn@kde.org>
4 
5  This library is free software; you can redistribute it and/or
6  modify it under the terms of the GNU Library General Public
7  License version 2 as published by the Free Software Foundation.
8 
9  This library is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  Library General Public License for more details.
13 
14  You should have received a copy of the GNU Library General Public License
15  along with this library; see the file COPYING.LIB. If not, write to
16  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17  Boston, MA 02110-1301, USA.
18 */
19 
20 #ifndef __kate_jscript_h__
21 #define __kate_jscript_h__
22 
23 #include "../interfaces/document.h"
24 #include "kateindentscriptabstracts.h"
25 #include <tqdict.h>
26 #include <kdebug.h>
30 class KateDocument;
31 class KateView;
32 class TQString;
33 class KateJSDocument;
34 class KateJSView;
35 class KateJSIndenter;
36 class KateDocCursor;
37 
41 namespace KJS {
42  class Object;
43  class ObjectImp;
44  class Interpreter;
45  class ExecState;
46 }
47 
52 class KateJScript
53 {
54  public:
58  KateJScript ();
59 
63  virtual ~KateJScript ();
64 
71  KJS::ObjectImp *wrapDocument (KJS::ExecState *exec, KateDocument *doc);
72 
79  KJS::ObjectImp *wrapView (KJS::ExecState *exec, KateView *view);
80 
90  bool execute (KateView *view, const TQString &script, TQString &errorMsg);
91 
92  protected:
96  KJS::Object *m_global;
97 
101  KJS::Interpreter *m_interpreter;
102 
106  KJS::Object *m_document;
107 
111  KJS::Object *m_view;
112 };
113 
114 class KateJScriptManager : public Kate::Command
115 {
116  private:
120  class Script
121  {
122  public:
127  inline TQString desktopFilename () { return filename.left(filename.length()-2).append ("desktop"); }
128 
129  public:
133  TQString name;
134 
138  TQString filename;
139 
143  bool desktopFileExists;
144  };
145 
146  public:
147  KateJScriptManager ();
148  ~KateJScriptManager ();
149 
150  private:
155  void collectScripts (bool force = false);
156 
157  //
158  // Here we deal with the Kate::Command stuff
159  //
160  public:
168  bool exec( class Kate::View *view, const TQString &cmd, TQString &errorMsg );
169 
177  bool help( class Kate::View *view, const TQString &cmd, TQString &msg );
178 
183  TQStringList cmds();
184 
185  private:
189  TQDict<KateJScriptManager::Script> m_scripts;
190 };
191 
192 class KateIndentJScriptImpl: public KateIndentScriptImplAbstract {
193  public:
194  KateIndentJScriptImpl(const TQString& internalName,
195  const TQString &filePath, const TQString &niceName,
196  const TQString &copyright, double version);
197  ~KateIndentJScriptImpl();
198 
199  virtual bool processChar( class Kate::View *view, TQChar c, TQString &errorMsg );
200  virtual bool processLine( class Kate::View *view, const KateDocCursor &line, TQString &errorMsg );
201  virtual bool processNewline( class Kate::View *view, const KateDocCursor &begin, bool needcontinue, TQString &errorMsg );
202  protected:
203  virtual void decRef();
204  private:
205  KateJSView *m_viewWrapper;
206  KateJSDocument *m_docWrapper;
207  KJS::Object *m_indenter;
208  KJS::Interpreter *m_interpreter;
209  bool setupInterpreter(TQString &errorMsg);
210  void deleteInterpreter();
211 };
212 
213 class KateIndentJScriptManager: public KateIndentScriptManagerAbstract
214 {
215 
216  public:
217  KateIndentJScriptManager ();
218  virtual ~KateIndentJScriptManager ();
219  virtual KateIndentScript script(const TQString &scriptname);
220  private:
225  void collectScripts (bool force = false);
226  void parseScriptHeader(const TQString &filePath,
227  TQString *niceName,TQString *copyright,double *version);
228  TQDict<KateIndentJScriptImpl> m_scripts;
229 };
230 
231 #endif
KateDocCursor
Cursor class with a pointer to its document.
Definition: katecursor.h:93
KateJScript
Whole Kate Part scripting in one classs Allow subclassing to allow specialized scripting engine for i...
Definition: katejscript.h:53
KateJScript::m_global
KJS::Object * m_global
global object of interpreter
Definition: katejscript.h:96
KateJScript::wrapView
KJS::ObjectImp * wrapView(KJS::ExecState *exec, KateView *view)
creates a JS wrapper object for given KateView
Definition: katejscript.cpp:265
KateJScript::execute
bool execute(KateView *view, const TQString &script, TQString &errorMsg)
execute given script the script will get the doc and view exposed via document and view object in glo...
Definition: katejscript.cpp:270
KateJScript::m_interpreter
KJS::Interpreter * m_interpreter
js interpreter
Definition: katejscript.h:101
KateJScript::m_document
KJS::Object * m_document
object for document
Definition: katejscript.h:106
KateJScript::wrapDocument
KJS::ObjectImp * wrapDocument(KJS::ExecState *exec, KateDocument *doc)
creates a JS wrapper object for given KateDocument
Definition: katejscript.cpp:260
KateJScript::m_view
KJS::Object * m_view
object for view
Definition: katejscript.h:111
KateJScript::KateJScript
KateJScript()
generate new global interpreter for part scripting
Definition: katejscript.cpp:238
KateJScript::~KateJScript
virtual ~KateJScript()
be destructive
Definition: katejscript.cpp:252
Kate::Command
Kate Commands.
Definition: document.h:97
Kate::Command::cmds
virtual TQStringList cmds()=0
Pure text start part of the commands which can be handled by this object which means i....
Kate::Command::help
virtual bool help(View *view, const TQString &cmd, TQString &msg)=0
Shows help for the given view and cmd string, return a bool about success, msg for status.
Kate::Command::exec
virtual bool exec(View *view, const TQString &cmd, TQString &msg)=0
Execute this command for the given view and cmd string, return a bool about success,...
Kate::View
The Kate::View text editor interface.
Definition: view.h:45
KJS
Cool, this is all we need here.
Definition: katejscript.cpp:53

kate

Skip menu "kate"
  • Main Page
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members
  • Related Pages

kate

Skip menu "kate"
  • arts
  • dcop
  • dnssd
  • interfaces
  •   kspeech
  •     interface
  •     library
  •   tdetexteditor
  • kate
  • kded
  • kdoctools
  • kimgio
  • kjs
  • libtdemid
  • libtdescreensaver
  • tdeabc
  • tdecmshell
  • tdecore
  • tdefx
  • tdehtml
  • tdeinit
  • tdeio
  •   bookmarks
  •   httpfilter
  •   kpasswdserver
  •   kssl
  •   tdefile
  •   tdeio
  •   tdeioexec
  • tdeioslave
  •   http
  • tdemdi
  •   tdemdi
  • tdenewstuff
  • tdeparts
  • tdeprint
  • tderandr
  • tderesources
  • tdespell2
  • tdesu
  • tdeui
  • tdeunittest
  • tdeutils
  • tdewallet
Generated for kate by doxygen 1.9.1
This website is maintained by Timothy Pearson.