preserve cursor pos

* configurable via .prompt()'s preserveCursor argument (false by default)
This commit is contained in:
Fedor Indutny 2011-12-09 15:24:15 +06:00 committed by Ryan Dahl
parent d9377f5eb0
commit c07edd90f5
3 changed files with 5 additions and 5 deletions

View File

@ -867,7 +867,7 @@ Interface.prototype.childPrint = function(text) {
}).map(function(chunk) { }).map(function(chunk) {
return '< ' + chunk; return '< ' + chunk;
}).join('\n')); }).join('\n'));
this.repl.displayPrompt(); this.repl.displayPrompt(true);
}; };
// Errors formatting // Errors formatting

View File

@ -125,9 +125,9 @@ Interface.prototype.setPrompt = function(prompt, length) {
}; };
Interface.prototype.prompt = function() { Interface.prototype.prompt = function(preserveCursor) {
if (this.enabled) { if (this.enabled) {
this.cursor = 0; if (!preserveCursor) this.cursor = 0;
this._refreshLine(); this._refreshLine();
} else { } else {
this.output.write(this._prompt); this.output.write(this._prompt);

View File

@ -282,11 +282,11 @@ REPLServer.prototype.resetContext = function(force) {
this.context = context; this.context = context;
}; };
REPLServer.prototype.displayPrompt = function() { REPLServer.prototype.displayPrompt = function(preserveCursor) {
this.rli.setPrompt(this.bufferedCommand.length ? this.rli.setPrompt(this.bufferedCommand.length ?
'...' + new Array(this.lines.level.length).join('..') + ' ' : '...' + new Array(this.lines.level.length).join('..') + ' ' :
this.prompt); this.prompt);
this.rli.prompt(); this.rli.prompt(preserveCursor);
}; };