From ce59050ded0fe6baa22e3d154bbd5ea61f851f30 Mon Sep 17 00:00:00 2001 From: Christopher Jeffrey Date: Thu, 30 Jul 2015 23:54:24 -0700 Subject: [PATCH] support node v0.6.x. --- lib/program.js | 21 +++++++++++---------- lib/widgets/screen.js | 8 ++++---- package.json | 2 +- 3 files changed, 16 insertions(+), 15 deletions(-) diff --git a/lib/program.js b/lib/program.js index 3a657c2..af800f4 100644 --- a/lib/program.js +++ b/lib/program.js @@ -16,6 +16,7 @@ var EventEmitter = require('events').EventEmitter var Tput = require('./tput') , colors = require('./colors') + , helpers = require('./helpers') , slice = Array.prototype.slice; var nextTick = global.setImmediate || process.nextTick.bind(process); @@ -324,8 +325,8 @@ Program.prototype.listen = function() { this.on('newListener', this._newHandler = function fn(type) { if (type === 'keypress' || type === 'mouse') { self.removeListener('newListener', fn); - if (self.input.setRawMode && !self.input.isRaw) { - self.input.setRawMode(true); + if (helpers.hasRaw(self.input) && !helpers.isRaw(self.input)) { + helpers.setRawMode(self.input, true); self.input.resume(); } } @@ -401,7 +402,7 @@ Program.prototype._listenInput = function() { Program.prototype._listenOutput = function() { var self = this; - if (!this.output.isTTY) { + if (!helpers.isTTY(this.output)) { nextTick(function() { self.emit('warning', 'Output is not a TTY'); }); @@ -463,9 +464,9 @@ Program.prototype.destroy = function() { delete this.input._keypressHandler; delete this.input._dataHandler; - if (this.input.setRawMode) { - if (this.input.isRaw) { - this.input.setRawMode(false); + if (helpers.hasRaw(this.input)) { + if (helpers.isRaw(this.input)) { + helpers.setRawMode(this.input, false); } if (!this.input.destroyed) { this.input.pause(); @@ -4177,16 +4178,16 @@ Program.prototype.pause = function(callback) { var write = this.output.write; this.output.write = function() {}; - if (this.input.setRawMode) { - this.input.setRawMode(false); + if (helpers.hasRaw(this.input)) { + helpers.setRawMode(this.input, false); } this.input.pause(); return this._resume = function() { delete self._resume; - if (self.input.setRawMode) { - self.input.setRawMode(true); + if (helpers.hasRaw(self.input)) { + helpers.setRawMode(self.input, true); } self.input.resume(); self.output.write = write; diff --git a/lib/widgets/screen.js b/lib/widgets/screen.js index 03c1814..45a570f 100644 --- a/lib/widgets/screen.js +++ b/lib/widgets/screen.js @@ -1722,16 +1722,16 @@ Screen.prototype.spawn = function(file, args, options) { var write = program.output.write; program.output.write = function() {}; program.input.pause(); - if (program.input.setRawMode) { - program.input.setRawMode(false); + if (helpers.hasRaw(program.input)) { + helpers.setRawMode(program.input, false); } var resume = function() { if (resume.done) return; resume.done = true; - if (program.input.setRawMode) { - program.input.setRawMode(true); + if (helpers.hasRaw(program.input)) { + helpers.setRawMode(program.input, true); } program.input.resume(); program.output.write = write; diff --git a/package.json b/package.json index 497c0fb..ef3b3d4 100644 --- a/package.json +++ b/package.json @@ -12,7 +12,7 @@ "keywords": ["curses", "tui", "tput", "terminfo", "termcap"], "tags": ["curses", "tui", "tput", "terminfo", "termcap"], "engines": { - "node": ">= 0.8.0" + "node": ">= 0.6.0" }, "browserify": { "transform": ["./browser/transform.js"]