summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRyan Dahl <ry@tinyclouds.org>2010-11-12 14:37:05 -0800
committerRyan Dahl <ry@tinyclouds.org>2010-11-16 10:50:00 -0800
commit9a066c99e46629c59788cd64c05de569d25ab96a (patch)
tree17d49c86effa7eafde82e9f9a3d0db785c2d8b8e
parent44db37859d584dd40fa2d7011b3a0368bd86e332 (diff)
downloadnode-9a066c99e46629c59788cd64c05de569d25ab96a.tar.gz
Simplify REPL displayPrompt
Now that we insert \r into the stream and aren't switching back and forth between termios modes, not need to worry about when to display the prompt.
-rw-r--r--lib/repl.js24
1 files changed, 4 insertions, 20 deletions
diff --git a/lib/repl.js b/lib/repl.js
index 4592dc813..5683aa238 100644
--- a/lib/repl.js
+++ b/lib/repl.js
@@ -82,8 +82,6 @@ function REPLServer(prompt, stream) {
rli.addListener('line', function (cmd) {
cmd = trimWhitespace(cmd);
- var flushed = true;
-
// Check to see if a REPL keyword was used. If it returns true,
// display next prompt and return.
if (self.parseREPLKeyword(cmd) === true) return;
@@ -98,7 +96,7 @@ function REPLServer(prompt, stream) {
var ret = evalcx(self.buffered_cmd, context, "repl");
if (ret !== undefined) {
context._ = ret;
- flushed = self.stream.write(exports.writer(ret) + "\n");
+ self.stream.write(exports.writer(ret) + "\n");
}
self.buffered_cmd = '';
@@ -111,28 +109,14 @@ function REPLServer(prompt, stream) {
} catch (e) {
// On error: Print the error and clear the buffer
if (e.stack) {
- flushed = self.stream.write(e.stack + "\n");
+ self.stream.write(e.stack + "\n");
} else {
- flushed = self.stream.write(e.toString() + "\n");
+ self.stream.write(e.toString() + "\n");
}
self.buffered_cmd = '';
}
- // need to make sure the buffer is flushed before displaying the prompt
- // again. This is really ugly. Need to have callbacks from
- // net.Stream.write()
- if (flushed) {
- self.displayPrompt();
- } else {
- self.displayPromptOnDrain = true;
- }
- });
-
- self.stream.addListener('drain', function () {
- if (self.displayPromptOnDrain) {
- self.displayPrompt();
- self.displayPromptOnDrain = false;
- }
+ self.displayPrompt();
});
rli.addListener('close', function () {