refactor listen input and listen output into separate methods.

This commit is contained in:
Christopher Jeffrey 2015-07-21 20:03:26 -07:00
parent ef0a6af11a
commit 0cf4934ac1

View File

@ -300,9 +300,6 @@ Program.prototype.listen = function() {
var keys = require('./keys')
, self = this;
if (this.input._blessedListened) return;
this.input._blessedListened = true;
// unshiftEvent(process, 'exit', function() {
// if (self._originalTitle) {
// self.setTitle(self._originalTitle);
@ -314,6 +311,17 @@ Program.prototype.listen = function() {
// self._originalTitle = data.text;
// });
this._listenInput();
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 };
@ -370,6 +378,10 @@ Program.prototype.listen = function() {
self.bindMouse();
}
});
};
Program.prototype._listenOutput = function() {
var self = this;
if (this.output._blessedListened) return;
this.output._blessedListened = true;