preserve cursor pos
authorFedor Indutny <fedor.indutny@gmail.com>
Fri, 9 Dec 2011 09:24:15 +0000 (15:24 +0600)
committerRyan Dahl <ry@tinyclouds.org>
Mon, 19 Dec 2011 19:09:16 +0000 (11:09 -0800)
* configurable via .prompt()'s preserveCursor argument (false by default)

lib/_debugger.js
lib/readline.js
lib/repl.js

index b0fb61c..a97eca1 100644 (file)
@@ -867,7 +867,7 @@ Interface.prototype.childPrint = function(text) {
   }).map(function(chunk) {
     return '< ' + chunk;
   }).join('\n'));
-  this.repl.displayPrompt();
+  this.repl.displayPrompt(true);
 };
 
 // Errors formatting
index a87ba1e..de484d3 100644 (file)
@@ -125,9 +125,9 @@ Interface.prototype.setPrompt = function(prompt, length) {
 };
 
 
-Interface.prototype.prompt = function() {
+Interface.prototype.prompt = function(preserveCursor) {
   if (this.enabled) {
-    this.cursor = 0;
+    if (!preserveCursor) this.cursor = 0;
     this._refreshLine();
   } else {
     this.output.write(this._prompt);
index 3a5ac43..2c3baeb 100644 (file)
@@ -282,11 +282,11 @@ REPLServer.prototype.resetContext = function(force) {
   this.context = context;
 };
 
-REPLServer.prototype.displayPrompt = function() {
+REPLServer.prototype.displayPrompt = function(preserveCursor) {
   this.rli.setPrompt(this.bufferedCommand.length ?
                  '...' + new Array(this.lines.level.length).join('..') + ' ' :
                  this.prompt);
-  this.rli.prompt();
+  this.rli.prompt(preserveCursor);
 };