allow options object for Program constructor.
This commit is contained in:
parent
1d2c2f182b
commit
06d6734622
|
@ -15,17 +15,25 @@ var EventEmitter = require('events').EventEmitter
|
|||
* Program
|
||||
*/
|
||||
|
||||
function Program(input, output) {
|
||||
function Program(options) {
|
||||
if (!(this instanceof Program)) {
|
||||
return new Program(input, output);
|
||||
return new Program(options);
|
||||
}
|
||||
|
||||
var self = this;
|
||||
|
||||
EventEmitter.call(this);
|
||||
|
||||
this.input = input || process.stdin;
|
||||
this.output = output || process.stdout;
|
||||
if (!options || options.__proto__ !== Object.prototype) {
|
||||
options = {
|
||||
input: arguments[0],
|
||||
output: arguments[1]
|
||||
};
|
||||
}
|
||||
|
||||
this.options = options;
|
||||
this.input = options.input || process.stdin;
|
||||
this.output = options.output || process.stdout;
|
||||
|
||||
this.x = 1;
|
||||
this.y = 1;
|
||||
|
@ -34,7 +42,10 @@ function Program(input, output) {
|
|||
this.rows = this.output.rows || 1;
|
||||
|
||||
this.terminal = process.env.TERM || 'xterm';
|
||||
this.tput = new Tput(this.terminal);
|
||||
|
||||
if (options.tput) {
|
||||
this.tput = new Tput(this.terminal);
|
||||
}
|
||||
|
||||
this.listen();
|
||||
|
||||
|
|
Loading…
Reference in New Issue