tput.js fixes.

This commit is contained in:
Christopher Jeffrey 2013-07-27 05:13:04 -05:00
parent efbae0c203
commit d63762fbe8

View File

@ -1092,28 +1092,37 @@ Tput.prototype.readTermcap = function(term) {
, term = term || this.terminal
, TERMCAP = process.env.TERMCAP || ''
, TERMPATH = process.env.TERMPATH || ''
, HOME = process.env.HOME || '';
, HOME = process.env.HOME || ''
, terms
, term_
, root;
// Termcap has a bunch of terminals usually stored in one file/string,
// so we need to find the one containing our desired terminal.
var terms = (term[0] === '/' && this._tryCap(term))
|| this._tryCap(this.termcapFile, term)
|| this._tryCap(TERMCAP, term)
|| this._tryCap(TERMPATH && TERMPATH.split(/[: ]/), term)
|| this._tryCap(HOME + '/.termcap', term)
|| this._tryCap('/usr/share/misc/termcap', term)
|| this._tryCap('/etc/termcap', term)
|| this._tryCap(Tput.termcap, term);
if (term[0] === '/' && (terms = this._tryCap(term))) {
term_ = path.basename(term).split('.')[0];
if (terms[process.env.TERM]) {
term = process.env.TERM;
} else if (terms[term_]) {
term = term_;
} else {
term = Object.keys(terms)[0];
}
} else {
terms = this._tryCap(this.termcapFile, term)
|| this._tryCap(TERMCAP, term)
|| this._tryCap(TERMPATH && TERMPATH.split(/[: ]/), term)
|| this._tryCap(HOME + '/.termcap', term)
|| this._tryCap('/usr/share/misc/termcap', term)
|| this._tryCap('/etc/termcap', term)
|| this._tryCap(Tput.termcap, term);
}
if (!terms) {
throw new Error('Cannot find termcap for: ' + term);
}
if (term[0] === '/') {
term = Object.keys(terms)[0];
}
var root = terms[term];
root = terms[term];
if (this.debug) {
this._termcap = terms;
@ -1589,7 +1598,7 @@ Tput.prototype._captoinfo = function(cap, s, parameterized) {
if ((s[i] === '=' || s[i] === '+' || s[i] === '-'
|| s[i] === '*' || s[i] === '/')
&& (s[i + 1] === 'p' || s[i + 1] === 'c')
&& s[i + 2] !== '\0') {
&& s[i + 2] !== '\0' && s[i + 2]) {
var l;
l = 2;
if (s[i] !== '=') {