• Skip to content
  • Skip to link menu
KDE 4.6 API Reference
  • KDE API Reference
  • kdelibs
  • KDE Home
  • Contact Us
 

Kate

katescript.h

Go to the documentation of this file.
00001 // This file is part of the KDE libraries
00002 // Copyright (C) 2008 Paul Giannaros <paul@giannaros.org>
00003 // Copyright (C) 2009 Dominik Haumann <dhaumann kde org>
00004 // Copyright (C) 2010 Joseph Wenninger <jowenn@kde.org>
00005 //
00006 // This library is free software; you can redistribute it and/or
00007 // modify it under the terms of the GNU Library General Public
00008 // License as published by the Free Software Foundation; either
00009 // version 2 of the License, or (at your option) version 3.
00010 //
00011 // This library is distributed in the hope that it will be useful,
00012 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014 // Library General Public License for more details.
00015 //
00016 // You should have received a copy of the GNU Library General Public License
00017 // along with this library; see the file COPYING.LIB.  If not, write to
00018 // the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00019 // Boston, MA 02110-1301, USA.
00020 
00021 #ifndef KATE_SCRIPT_H
00022 #define KATE_SCRIPT_H
00023 
00024 #include <QtCore/QObject>
00025 #include <QtCore/QHash>
00026 #include <QtCore/QStringList>
00027 
00028 #include <QtScript/QScriptValue>
00029 #include <QtScript/QScriptable>
00030 
00031 class QScriptEngine;
00032 class QScriptContext;
00033 
00034 class KateDocument;
00035 class KateView;
00036 
00037 class KateScriptDocument;
00038 class KateScriptView;
00039 
00040 namespace Kate {
00041   enum ScriptType {
00043     IndentationScript,
00045     CommandLineScript,
00047     UnknownScript
00048   };
00049 }
00050 
00051 //BEGIN KateScriptHeader
00052 
00053 class KateScriptHeader
00054 {
00055   public:
00056     KateScriptHeader() : m_revision(0), m_scriptType(Kate::UnknownScript)
00057     {}
00058     virtual ~KateScriptHeader()
00059     {}
00060 
00061     inline void setLicense(const QString& license)
00062     { m_license = license; }
00063     inline const QString& license() const
00064     { return m_license; }
00065 
00066     inline void setAuthor(const QString& author)
00067     { m_author = author; }
00068     inline const QString& author() const
00069     { return m_author; }
00070 
00071     inline void setRevision(int revision)
00072     { m_revision = revision; }
00073     inline int revision() const
00074     { return m_revision; }
00075 
00076     inline void setKateVersion(const QString& kateVersion)
00077     { m_kateVersion = kateVersion; }
00078     inline const QString& kateVersion() const
00079     { return m_kateVersion; }
00080 
00081     inline void setCatalog(const QString& catalog)
00082     { m_i18nCatalog = catalog; }
00083     inline const QString& catalog() const
00084     { return m_i18nCatalog; }
00085 
00086     inline void setScriptType(Kate::ScriptType scriptType)
00087     { m_scriptType = scriptType; }
00088     inline Kate::ScriptType scriptType() const
00089     { return m_scriptType; }
00090 
00091   private:
00092     QString m_license;        
00093     QString m_author;         
00094     int m_revision;           
00095     QString m_kateVersion;    
00096     QString m_i18nCatalog;        
00097     Kate::ScriptType m_scriptType;  
00098 };
00099 //END
00100 
00101 //BEGIN KateScript
00102 
00106 class KateScript {
00107   public:
00108 
00109     enum InputType {
00110       InputURL,
00111       InputSCRIPT
00112     };
00113 
00119     KateScript(const QString &urlOrScript, enum InputType inputType = InputURL);
00120     virtual ~KateScript();
00121 
00123     const QString &url() { return m_url; }
00124 
00132     bool load();
00133 
00138     bool setView (KateView *view);
00139 
00144     QScriptValue global(const QString &name);
00145 
00150     QScriptValue function(const QString &name);
00151 
00153     const QString &errorMessage() { return m_errorMessage; }
00154 
00156     QString backtrace(const QScriptValue &error, const QString &header = QString());
00157 
00159     void displayBacktrace(const QScriptValue &error, const QString &header = QString());
00160 
00162     void clearExceptions();
00163 
00165     void setGeneralHeader(const KateScriptHeader& generalHeader);
00167     KateScriptHeader& generalHeader();
00168 
00169   protected:
00171     bool hasException(const QScriptValue& object, const QString& file);
00172 
00174     static bool readFile(const QString& sourceUrl, QString& sourceCode);
00175 
00176   private:
00178     bool initApi ();
00179 
00181     void initEngine();
00182 
00184     bool m_loaded;
00186     bool m_loadSuccessful;
00188     QString m_url;
00190     QString m_errorMessage;
00191 
00192   protected:
00194     QScriptEngine *m_engine;
00195 
00196   private:
00198     KateScriptHeader m_generalHeader;
00199 
00201     KateScriptDocument *m_document;
00202     KateScriptView *m_view;
00203 
00204   public:
00205     static void reloadScriptingApi();
00206 
00207   private:
00209     static bool s_scriptingApiLoaded;
00210 
00212     enum InputType m_inputType;
00213     QString m_script;
00214 };
00215 
00216 //END
00217 
00218 #endif
00219 
00220 // kate: space-indent on; indent-width 2; replace-tabs on;

Kate

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

kdelibs

Skip menu "kdelibs"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • Kate
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDEWebKit
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  •   WTF
  • kjsembed
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUnitConversion
  • KUtils
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver
Generated for kdelibs by doxygen 1.7.3
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal