refactor listen.
This commit is contained in:
parent
2072968e03
commit
797feb6ab1
|
@ -313,17 +313,23 @@ Program.prototype.listen = function() {
|
|||
// self._originalTitle = data.text;
|
||||
// });
|
||||
|
||||
this._listenInput();
|
||||
this._listenOutput();
|
||||
// Listen for keys/mouse on input
|
||||
if (!this.input._blessedListened) {
|
||||
this.input._blessedListened = true;
|
||||
this._listenInput();
|
||||
}
|
||||
|
||||
// Listen for resize on output
|
||||
if (!this.output._blessedListened) {
|
||||
this.output._blessedListened = true;
|
||||
this._listenOutput();
|
||||
}
|
||||
};
|
||||
|
||||
Program.prototype._listenInput = function() {
|
||||
var keys = require('./keys')
|
||||
, self = this;
|
||||
|
||||
if (this.input._blessedListened) return;
|
||||
this.input._blessedListened = true;
|
||||
|
||||
// Input
|
||||
this.input.on('keypress', function(ch, key) {
|
||||
key = key || { ch: ch };
|
||||
|
@ -385,9 +391,6 @@ Program.prototype._listenInput = function() {
|
|||
Program.prototype._listenOutput = function() {
|
||||
var self = this;
|
||||
|
||||
if (this.output._blessedListened) return;
|
||||
this.output._blessedListened = true;
|
||||
|
||||
if (!this.output.isTTY) {
|
||||
nextTick(function() {
|
||||
self.emit('warning', 'Output is not a TTY');
|
||||
|
|
Loading…
Reference in New Issue