Created
January 12, 2011 03:14
-
-
Save piscisaureus/775635 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
From 5d68b71e52cd7a596ac5ead2a3ae7711e55f212c Mon Sep 17 00:00:00 2001 | |
From: Bert Belder <bertbelder@gmail.com> | |
Date: Wed, 12 Jan 2011 04:13:41 +0100 | |
Subject: [PATCH 1/1] Readline: use tty methods instead of control sequences | |
--- | |
lib/readline.js | 10 +++++----- | |
1 files changed, 5 insertions(+), 5 deletions(-) | |
diff --git a/lib/readline.js b/lib/readline.js | |
index b52994c..7dd8b80 100644 | |
--- a/lib/readline.js | |
+++ b/lib/readline.js | |
@@ -139,17 +139,17 @@ Interface.prototype._refreshLine = function() { | |
if (this._closed) return; | |
// Cursor to left edge. | |
- this.output.write('\x1b[0G'); | |
+ this.output.cursorTo(0); | |
// Write the prompt and the current buffer content. | |
this.output.write(this._prompt); | |
this.output.write(this.line); | |
// Erase to right. | |
- this.output.write('\x1b[0K'); | |
+ this.output.clearLine(1); | |
// Move cursor to original position. | |
- this.output.write('\x1b[0G\x1b[' + (this._promptLength + this.cursor) + 'C'); | |
+ this.output.cursorTo(this._promptLength + this.cursor); | |
}; | |
@@ -479,14 +479,14 @@ Interface.prototype._ttyWrite = function(b) { | |
// left arrow | |
if (this.cursor > 0) { | |
this.cursor--; | |
- this.output.write('\x1b[0D'); | |
+ this.output.moveCursor(-1, 0); | |
} | |
} else if (b[1] === 91 && b[2] === 67) { | |
// right arrow | |
if (this.cursor != this.line.length) { | |
this.cursor++; | |
- this.output.write('\x1b[0C'); | |
+ this.output.moveCursor(1, 0); | |
} | |
} else if ((b[1] === 91 && b[2] === 72) || | |
-- | |
1.7.3.1.msysgit.0 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment