readline: move the "setRawMode" logic into a private function
This commit is contained in:
parent
45de259b43
commit
2b9967fbcc
@ -108,9 +108,7 @@ function Interface(input, output, completer, terminal) {
|
|||||||
// Current line
|
// Current line
|
||||||
this.line = '';
|
this.line = '';
|
||||||
|
|
||||||
if (typeof input.setRawMode === 'function') {
|
this._setRawMode(true);
|
||||||
input.setRawMode(true);
|
|
||||||
}
|
|
||||||
this.terminal = true;
|
this.terminal = true;
|
||||||
|
|
||||||
// Cursor position on the line.
|
// 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) {
|
Interface.prototype.prompt = function(preserveCursor) {
|
||||||
if (this.paused) this.resume();
|
if (this.paused) this.resume();
|
||||||
if (this.terminal) {
|
if (this.terminal) {
|
||||||
@ -239,9 +244,7 @@ Interface.prototype._refreshLine = function() {
|
|||||||
Interface.prototype.close = function() {
|
Interface.prototype.close = function() {
|
||||||
if (this.closed) return;
|
if (this.closed) return;
|
||||||
if (this.terminal) {
|
if (this.terminal) {
|
||||||
if (typeof this.input.setRawMode === 'function') {
|
this._setRawMode(false);
|
||||||
this.input.setRawMode(false);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
this.pause();
|
this.pause();
|
||||||
this.closed = true;
|
this.closed = true;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user