[seed] Built in REPL was broken because it was installing from examples tree (now seed-examples on git.gnom
- From: Robert Carr <racarr src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [seed] Built in REPL was broken because it was installing from examples tree (now seed-examples on git.gnom
- Date: Thu, 17 Dec 2009 22:09:56 +0000 (UTC)
commit d70268ca6c3482b38f1076b13f360bade04dbe6c
Author: Robert Carr <racarr gnome org>
Date: Thu Dec 17 17:09:48 2009 -0500
Built in REPL was broken because it was installing from examples tree (now seed-examples on git.gnome.org). Move a copy of REPL snippet into seed
extensions/Makefile.am | 3 ++
extensions/repl.js | 49 ++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 52 insertions(+), 0 deletions(-)
---
diff --git a/extensions/Makefile.am b/extensions/Makefile.am
index 37c253c..13f0150 100644
--- a/extensions/Makefile.am
+++ b/extensions/Makefile.am
@@ -2,3 +2,6 @@ EXTRA_DIST= Gio.js Seed.js.in Gtk.js GObject.js Clutter.js Gst.js
extensiondir=$(datadir)/seed/extensions
extension_DATA = Gio.js Seed.js Gtk.js GObject.js Clutter.js Gst.js
+
+repldir=$(datadir)/seed
+repl_DATA = repl.js
diff --git a/extensions/repl.js b/extensions/repl.js
new file mode 100755
index 0000000..6e80cf3
--- /dev/null
+++ b/extensions/repl.js
@@ -0,0 +1,49 @@
+#!/usr/bin/env seed
+
+readline = imports.readline;
+sandbox = imports.sandbox;
+os = imports.os;
+
+var lastLastLength = '-1';
+
+context = new sandbox.Context();
+context.add_globals();
+
+bind_cr = function(){
+ var buffer = readline.buffer();
+ if (buffer.length == lastLastLength)
+ readline.done();
+ try {
+ Seed.check_syntax(buffer);
+ readline.done();
+ }
+ catch (e){
+ os.write(1, "\n..");
+ lastLastLength = buffer.length;
+ return;
+ }
+ os.write(1, "\n");
+ lastLastLength = buffer.length;
+}
+
+readline.bind('\n', bind_cr);
+readline.bind('\r', bind_cr);
+readline.bind('\t', function(){
+ readline.insert("\t");
+});
+
+//var re = /[^=<>*-^/]=[^=<>*-^/]\(*\s*(new\s*)?[^:punct:]|'|"+\)*$/
+
+while(1){
+ try{
+ item = readline.readline("> ");
+ result = context.eval(item);
+// if (!re.exec(item) && (result != undefined))
+ if (result != undefined)
+ print(result)
+
+ }
+ catch(e){
+ print(e.name + " " + e.message);
+ }
+}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]