KateScript
#include <katescript.h>
Public Types | |
typedef QMap< QString, QJSValue > | FieldMap |
enum | InputType { InputURL , InputSCRIPT } |
Public Member Functions | |
KateScript (const QString &urlOrScript, enum InputType inputType=InputURL) | |
void | clearExceptions () |
void | displayBacktrace (const QJSValue &error, const QString &header=QString()) |
const QString & | errorMessage () |
QJSValue | evaluate (const QString &program, const FieldMap &env=FieldMap()) |
QJSValue | function (const QString &name) |
KateScriptHeader & | generalHeader () |
QJSValue | global (const QString &name) |
bool | load () |
void | setGeneralHeader (const KateScriptHeader &generalHeader) |
bool | setView (KTextEditor::ViewPrivate *view) |
const QString & | url () |
Static Public Member Functions | |
static QString | backtrace (const QJSValue &error, const QString &header=QString()) |
Protected Member Functions | |
bool | hasException (const QJSValue &object, const QString &file) |
Protected Attributes | |
QJSEngine * | m_engine = nullptr |
Detailed Description
KateScript objects represent a script that can be executed and inspected.
Definition at line 106 of file katescript.h.
Member Typedef Documentation
◆ FieldMap
Definition at line 114 of file katescript.h.
Member Enumeration Documentation
◆ InputType
enum KateScript::InputType |
Definition at line 109 of file katescript.h.
Constructor & Destructor Documentation
◆ KateScript()
|
explicit |
Create a new script representation, passing either a file or the script content urlOrScript
to it.
In case of a file, loading of the script will happen lazily.
Definition at line 26 of file katescript.cpp.
◆ ~KateScript()
|
virtual |
Definition at line 33 of file katescript.cpp.
Member Function Documentation
◆ backtrace()
Returns the backtrace when a script has errored out.
Definition at line 44 of file katescript.cpp.
◆ clearExceptions()
void KateScript::clearExceptions | ( | ) |
Clears any uncaught exceptions in the script engine.
Definition at line 66 of file katescript.cpp.
◆ displayBacktrace()
Displays the backtrace when a script has errored out.
Definition at line 57 of file katescript.cpp.
◆ errorMessage()
|
inline |
Return a context-specific error message.
Definition at line 158 of file katescript.h.
◆ evaluate()
Execute a piece of code.
Definition at line 184 of file katescript.cpp.
◆ function()
Return a function in the script of the given name, or an invalid QJSValue if no such function exists.
Definition at line 82 of file katescript.cpp.
◆ generalHeader()
KateScriptHeader & KateScript::generalHeader | ( | ) |
Return the general header.
Definition at line 240 of file katescript.cpp.
◆ global()
Get a QJSValue for a global item in the script given its name, or an invalid QJSValue if no such global item exists.
Definition at line 73 of file katescript.cpp.
◆ hasException()
Checks for exception and gives feedback on the console.
Definition at line 211 of file katescript.cpp.
◆ load()
bool KateScript::load | ( | ) |
Load the script.
If loading is successful, returns true. Otherwise, returns returns false and an error message will be set (see errorMessage()). Note that you don't have to call this – it is called as necessary by the functions that require it. Subsequent calls to load will return the value it returned the first time.
Definition at line 91 of file katescript.cpp.
◆ setGeneralHeader()
void KateScript::setGeneralHeader | ( | const KateScriptHeader & | generalHeader | ) |
set the general header after construction of the script
Definition at line 235 of file katescript.cpp.
◆ setView()
bool KateScript::setView | ( | KTextEditor::ViewPrivate * | view | ) |
set view for this script for the execution will trigger load!
Definition at line 224 of file katescript.cpp.
◆ url()
|
inline |
The script's URL.
Definition at line 125 of file katescript.h.
Member Data Documentation
◆ m_engine
|
protected |
The Qt interpreter for this script.
Definition at line 199 of file katescript.h.
The documentation for this class was generated from the following files:
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 18 2024 12:11:28 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.