improve compileTerminfo. try to read from $TERMCAP.

This commit is contained in:
Christopher Jeffrey 2013-02-28 01:17:37 -06:00
parent 76fa728a89
commit 6acb18fba4
1 changed files with 11 additions and 11 deletions

View File

@ -379,8 +379,11 @@ Tput.prototype.parseExtended = function(data) {
return info;
};
Tput.prototype.compileTerminfo = function() {
return this.compile.apply(this, arguments);
Tput.prototype.compileTerminfo = function(info, inject) {
if (arguments.length === 0) {
info = this.readTerminfo();
}
return this.compile(info, inject);
};
/**
@ -390,10 +393,6 @@ Tput.prototype.compileTerminfo = function() {
Tput.prototype.compile = function(info, inject) {
var self = this;
if (arguments.length === 0) {
info = this.readTerminfo();
}
if (!info) {
throw new Error('Terminal not found.');
}
@ -995,6 +994,7 @@ Tput.prototype._parsePadding = function(code, print, done) {
Tput.prototype.readTermcap = function(data) {
var data = data
|| tryRead(process.env.TERMCAP)
|| process.env.TERMCAP
|| tryRead('/etc/termcap')
|| Tput.termcap;
@ -1098,9 +1098,7 @@ Tput.prototype.translateTermcap = function(info) {
var self = this
, out = {};
if (!info) {
throw new Error('Terminal not found.');
}
if (!info) return;
if (this.debug) {
console.log(info);
@ -1138,14 +1136,15 @@ Tput.prototype.translateTermcap = function(info) {
return out;
};
Tput.prototype.compileTermcap = function(info) {
Tput.prototype.compileTermcap = function(info, inject) {
if (arguments.length === 0) {
info = this.readTermcap();
}
// Translate termcap names to terminfo-style names.
info = this.translateTermcap(info);
return this.compile(info);
return this.compile(info, inject);
};
/**
@ -1170,6 +1169,7 @@ function write(data) {
}
function tryRead() {
if (!file) return '';
var file = path.resolve.apply(path, arguments);
try {
return fs.readFileSync(file, 'utf8');