[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: kdelibs/kate
From: Christoph Cullmann <cullmann () kde ! org>
Date: 2005-03-13 11:00:16
Message-ID: 20050313110016.77D061487F () office ! kde ! org
[Download RAW message or body]
CVS commit by cullmann:
don't make old faults, document the new header verbose
M +12 -2 part/katejscript.cpp 1.9
M +43 -0 part/katejscript.h 1.2
M +5 -1 scripts/test.js 1.5
--- kdelibs/kate/part/katejscript.cpp #1.8:1.9
@@ -124,9 +124,19 @@ KateJScript::~KateJScript ()
}
+KJS::ObjectImp *KateJScript::wrapDocument (KJS::ExecState *exec, KateDocument *doc)
+{
+ return new KateJSDocument(exec, doc);
+}
+
+KJS::ObjectImp *KateJScript::wrapView (KJS::ExecState *exec, KateView *view)
+{
+ return new KateJSView(exec, view);
+}
+
bool KateJScript::execute (KateDocument *doc, KateView *view, const QString &script)
{
// put some stuff into env.
- m_interpreter->globalObject().put(m_interpreter->globalExec(), "document", \
KJS::Object(new KateJSDocument(m_interpreter->globalExec(), doc)));
- m_interpreter->globalObject().put(m_interpreter->globalExec(), "view", \
KJS::Object(new KateJSView(m_interpreter->globalExec(), view))); + \
m_interpreter->globalObject().put(m_interpreter->globalExec(), "document", \
KJS::Object(wrapDocument(m_interpreter->globalExec(), doc))); + \
m_interpreter->globalObject().put(m_interpreter->globalExec(), "view", \
KJS::Object(wrapView(m_interpreter->globalExec(), view)));
// run
--- kdelibs/kate/part/katejscript.h #1.1:1.2
@@ -20,19 +20,62 @@
#define __kate_jscript_h__
+/**
+ * Some common stuff
+ */
class KateDocument;
class KateView;
class QString;
+/**
+ * Cool, this is all we need here
+ */
namespace KJS {
class Object;
+ class ObjectImp;
class Interpreter;
+ class ExecState;
}
+/**
+ * Whole Kate Part scripting in one classs
+ */
class KateJScript
{
public:
+ /**
+ * generate new global interpreter for part scripting
+ */
KateJScript ();
+
+ /**
+ * be destructive
+ */
~KateJScript ();
+ /**
+ * creates a JS wrapper object for given KateDocument
+ * @param exec execution state, to find out interpreter to use
+ * @param doc document object to wrap
+ * @return new js wrapper object
+ */
+ KJS::ObjectImp *wrapDocument (KJS::ExecState *exec, KateDocument *doc);
+
+ /**
+ * creates a JS wrapper object for given KateDocument
+ * @param exec execution state, to find out interpreter to use
+ * @param doc document object to wrap
+ * @return new js wrapper object
+ */
+ KJS::ObjectImp *wrapView (KJS::ExecState *exec, KateView *view);
+
+ /**
+ * execute given script
+ * the script will get the doc and view exposed via document and view object
+ * in global scope
+ * @param doc document to expose
+ * @param view view to expose
+ * @param script source code of script to execute
+ * @return success or not?
+ */
bool execute (KateDocument *doc, KateView *view, const QString &script);
--- kdelibs/kate/scripts/test.js #1.4:1.5
@@ -4,9 +4,13 @@
document.editBegin();
-for (var t = 0; t < 10000; t++)
+
+for (var t = 0; t < 100; t++)
{
document.insertLine (start+t, document.lineLength(0));
document.insertText (start+t, 0, " muh");
document.insertText (start+t, 0, view.cursorLine());
+ document.insertText (start+t, 0, "// ");
}
+
document.editEnd();
+
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic