|
|
@ -53,14 +53,26 @@ function REPLServer(prompt, stream) { |
|
|
|
var rli = self.rli = rl.createInterface(self.stream, function (text) { |
|
|
|
return self.complete(text); |
|
|
|
}); |
|
|
|
|
|
|
|
if (rli.enabled) { |
|
|
|
// Turn on ANSI coloring.
|
|
|
|
exports.writer = function(obj, showHidden, depth) { |
|
|
|
return sys.inspect(obj, showHidden, depth, true); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
rli.setPrompt(self.prompt); |
|
|
|
|
|
|
|
rli.on("SIGINT", function () { |
|
|
|
if (self.buffered_cmd && self.buffered_cmd.length > 0) { |
|
|
|
rli.write("\n"); |
|
|
|
self.buffered_cmd = ''; |
|
|
|
self.displayPrompt(); |
|
|
|
} else { |
|
|
|
rli.close(); |
|
|
|
} |
|
|
|
}); |
|
|
|
|
|
|
|
self.stream.addListener("data", function (chunk) { |
|
|
|
rli.write(chunk); |
|
|
|
}); |
|
|
@ -136,7 +148,7 @@ exports.start = function (prompt, source) { |
|
|
|
}; |
|
|
|
|
|
|
|
REPLServer.prototype.displayPrompt = function () { |
|
|
|
this.rli.setPrompt(this.buffered_cmd.length ? '... ' : this.prompt); |
|
|
|
this.rli.setPrompt(this.buffered_cmd.length ? '... ' : this.prompt); |
|
|
|
this.rli.prompt(); |
|
|
|
}; |
|
|
|
|
|
|
@ -387,6 +399,7 @@ REPLServer.prototype.parseREPLKeyword = function (cmd) { |
|
|
|
|
|
|
|
switch (cmd) { |
|
|
|
case ".break": |
|
|
|
// TODO remove me after 0.3.x
|
|
|
|
self.buffered_cmd = ''; |
|
|
|
self.displayPrompt(); |
|
|
|
return true; |
|
|
@ -400,7 +413,6 @@ REPLServer.prototype.parseREPLKeyword = function (cmd) { |
|
|
|
self.stream.destroy(); |
|
|
|
return true; |
|
|
|
case ".help": |
|
|
|
self.stream.write(".break\tSometimes you get stuck in a place you can't get out... This will get you out.\n"); |
|
|
|
self.stream.write(".clear\tBreak, and also clear the local context.\n"); |
|
|
|
self.stream.write(".exit\tExit the prompt\n"); |
|
|
|
self.stream.write(".help\tShow repl options\n"); |
|
|
|