Skip to content
This repository has been archived by the owner on Apr 22, 2023. It is now read-only.

Commit

Permalink
readline: move the "setRawMode" logic into a private function
Browse files Browse the repository at this point in the history
  • Loading branch information
TooTallNate committed May 22, 2012
1 parent 45de259 commit 2b9967f
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions lib/readline.js
Expand Up @@ -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.
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 2b9967f

Please sign in to comment.