[seed] Add beginnings of multiline editing support to REPL
- From: Robert Carr <racarr src gnome org>
- To: svn-commits-list gnome org
- Subject: [seed] Add beginnings of multiline editing support to REPL
- Date: Wed, 6 May 2009 14:28:06 -0400 (EDT)
commit a96c30066a2cc54d0e7d88cf2f9cd4e7d2254389
Author: Robert Carr <racarr svn gnome org>
Date: Wed May 6 14:26:59 2009 -0400
Add beginnings of multiline editing support to REPL
---
examples/repl.js | 30 ++++++++++++++++++++++++++++++
modules/readline/seed-readline.c | 17 +++++++++++++++++
2 files changed, 47 insertions(+), 0 deletions(-)
diff --git a/examples/repl.js b/examples/repl.js
index afe888a..9c44eda 100755
--- a/examples/repl.js
+++ b/examples/repl.js
@@ -2,6 +2,36 @@
readline = imports.readline;
+var eoq = 0;
+var bc = 0;
+
+bind_cr = function(){
+ if (bc == 0){
+ readline.rl_done();
+ eoq = 0;
+ }
+ Seed.print("");
+}
+
+bind_eoq = function(){
+ eoq = 1;
+ Seed.print(";");
+}
+
+bind_lb = function(){
+ bc++;
+ Seed.print("{");
+}
+bind_rb = function(){
+ bc--;
+ Seed.print("}");
+}
+
+readline.bind('\n', bind_cr);
+readline.bind('\r', bind_cr);
+readline.bind('{', bind_lb);
+readline.bind('}', bind_rb);
+
while(1){
try{
item = readline.readline("> ");
diff --git a/modules/readline/seed-readline.c b/modules/readline/seed-readline.c
index 5609989..9c47d16 100644
--- a/modules/readline/seed-readline.c
+++ b/modules/readline/seed-readline.c
@@ -73,6 +73,18 @@ seed_readline_bind(SeedContext ctx,
}
static SeedValue
+seed_rl_done(SeedContext ctx,
+ SeedObject function,
+ SeedObject this_object,
+ size_t argumentCount,
+ const SeedValue arguments[],
+ SeedValue * exception)
+{
+ rl_done = 1;
+ return seed_make_null (ctx);
+}
+
+static SeedValue
seed_readline(SeedContext ctx,
SeedObject function,
SeedObject this_object,
@@ -140,6 +152,11 @@ seed_module_init(SeedEngine * local_eng)
(SeedFunctionCallback) seed_readline_bind,
(SeedObject) namespace_ref);
+ seed_create_function(eng->context,
+ "rl_done",
+ (SeedFunctionCallback) seed_rl_done,
+ (SeedObject) namespace_ref);
+
return namespace_ref;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]