misc. remove old code.

This commit is contained in:
Christopher Jeffrey 2013-07-12 00:08:36 -05:00
parent cc863af2cf
commit 5a96c3611d
1 changed files with 42 additions and 24 deletions

View File

@ -39,6 +39,8 @@ function Program(options) {
this.x = 0; this.x = 0;
this.y = 0; this.y = 0;
this.savedX = 0;
this.savedY = 0;
this.cols = this.output.columns || 1; this.cols = this.output.columns || 1;
this.rows = this.output.rows || 1; this.rows = this.output.rows || 1;
@ -48,18 +50,22 @@ function Program(options) {
this.terminal = options.terminal || process.env.TERM || 'xterm'; this.terminal = options.terminal || process.env.TERM || 'xterm';
// if (!Program.global) {
// Program._write = process.stdout.write;
// process.stdout.write = function() {};
// process.stderr.write = function() {};
// Program.global = this;
// }
if (!Program.global) {
Program.global = this;
}
if (options.tput) { if (options.tput) {
this.setupTput(); this.setupTput();
} }
this.listen(); this.listen();
//if (!Program.global) {
// Program._write = process.stdout.write;
// process.stdout.write = function() {};
// process.stderr.write = function() {};
// Program.global = this;
//}
} }
Program.prototype.__proto__ = EventEmitter.prototype; Program.prototype.__proto__ = EventEmitter.prototype;
@ -123,15 +129,6 @@ Program.prototype.listen = function() {
// Input // Input
this.input.on('keypress', function(ch, key) { this.input.on('keypress', function(ch, key) {
key = key || 0; key = key || 0;
if (key.ctrl && key.name === 'c') {
if (process.listeners('SIGINT').length) {
process.emit('SIGINT');
}
if (self.listeners('SIGINT').length) {
self.emit('SIGINT');
}
// return;
}
if (key.name === 'undefined' && key.code === '[M') { if (key.name === 'undefined' && key.code === '[M') {
// A mouse sequence. The readline module doesn't understand these. // A mouse sequence. The readline module doesn't understand these.
return; return;
@ -698,11 +695,11 @@ Program.prototype.receive_ = function(text, callback) {
Program.prototype.write = Program.prototype.write =
Program.prototype.echo = function(text, attr) { Program.prototype.echo = function(text, attr) {
//if (this.output === process.stdout) { // if (this.output === process.stdout) {
// return attr // return attr
// ? Program._write.call(this.output, this.text(text, attr)) // ? Program._write.call(this.output, this.text(text, attr))
// : Program._write.call(this.output, text); // : Program._write.call(this.output, text);
//} // }
return attr return attr
? this.output.write(this.text(text, attr)) ? this.output.write(this.text(text, attr))
: this.output.write(text); : this.output.write(text);
@ -764,7 +761,7 @@ Program.prototype.repeat = function(ch, i) {
//Program.prototype.pad = //Program.prototype.pad =
Program.prototype.nul = function() { Program.prototype.nul = function() {
//if (this.tput) return this.put.nul(); //if (this.tput) return this.put.pad();
return this.write('\0'); return this.write('\0');
}; };
@ -796,7 +793,7 @@ Program.prototype.ht =
Program.prototype.tab = function() { Program.prototype.tab = function() {
this.x += 8; this.x += 8;
this._ncoords(); this._ncoords();
if (this.tput) return this.put.ht(); // or `tab` if (this.tput) return this.put.ht();
return this.write('\t'); return this.write('\t');
}; };
@ -863,7 +860,7 @@ Program.prototype.nextLine = function() {
// ESC c Full Reset (RIS). // ESC c Full Reset (RIS).
Program.prototype.reset = function() { Program.prototype.reset = function() {
//this.x = this.y = 0; this.x = this.y = 0;
if (this.tput) return this.put.rs1 ? this.put.rs1() : this.put.ris(); if (this.tput) return this.put.rs1 ? this.put.rs1() : this.put.ris();
return this.write('\x1bc'); return this.write('\x1bc');
}; };
@ -2850,6 +2847,27 @@ Program.prototype.deleteColumns = function() {
return this.write('\x1b[' + Array.prototype.slice.call(arguments).join(';') + ' ~'); return this.write('\x1b[' + Array.prototype.slice.call(arguments).join(';') + ' ~');
}; };
/**
* A workaround to output sequences without writing to a stream.
*/
Program.prototype._owrite = function(data) {
this._odata = data;
};
Program.prototype.out = function(name) {
var args = Array.prototype.slice.call(arguments, 1);
var write = this.write;
this.write = this._owrite;
var receive = this.receive;
this.receive = this._owrite;
this._odata = '';
this[name].apply(this, args);
this.write = write;
this.receive = receive;
return this._odata;
};
/** /**
* Expose * Expose
*/ */