Browse Source

readline: move the "setRawMode" logic into a private function

v0.9.1-release
Nathan Rajlich 13 years ago
parent
commit
2b9967fbcc
  1. 15
      lib/readline.js

15
lib/readline.js

@ -108,9 +108,7 @@ function Interface(input, output, completer, terminal) {
// Current line
this.line = '';
if (typeof input.setRawMode === 'function') {
input.setRawMode(true);
}
this._setRawMode(true);
this.terminal = true;
// Cursor position on the line.
@ -143,6 +141,13 @@ Interface.prototype.setPrompt = function(prompt, length) {
};
Interface.prototype._setRawMode = function(mode) {
if (typeof this.input.setRawMode === 'function') {
return this.input.setRawMode(mode);
}
}
Interface.prototype.prompt = function(preserveCursor) {
if (this.paused) this.resume();
if (this.terminal) {
@ -239,9 +244,7 @@ Interface.prototype._refreshLine = function() {
Interface.prototype.close = function() {
if (this.closed) return;
if (this.terminal) {
if (typeof this.input.setRawMode === 'function') {
this.input.setRawMode(false);
}
this._setRawMode(false);
}
this.pause();
this.closed = true;

Loading…
Cancel
Save