check all terminfo/termcap paths/variables.

This commit is contained in:
Christopher Jeffrey 2013-07-16 15:13:17 -05:00
parent 7e238a470e
commit 445e278af0
1 changed files with 23 additions and 3 deletions

View File

@ -105,6 +105,12 @@ Tput.prototype.readTerminfo = function(data) {
var file = this.terminfoFile var file = this.terminfoFile
|| this._terminfoPrefix(this.terminfoPrefix) || this._terminfoPrefix(this.terminfoPrefix)
|| this._terminfoPrefix('/usr/share/terminfo') || this._terminfoPrefix('/usr/share/terminfo')
|| this._terminfoPrefix('/usr/share/lib/terminfo')
|| this._terminfoPrefix('/usr/lib/terminfo')
|| this._terminfoPrefix('/usr/local/share/terminfo')
|| this._terminfoPrefix('/usr/local/share/lib/terminfo')
|| this._terminfoPrefix('/usr/local/lib/terminfo')
|| this._terminfoPrefix('/usr/local/ncurses/lib/terminfo')
|| this._terminfoPrefix(process.env.HOME + '/.terminfo'); || this._terminfoPrefix(process.env.HOME + '/.terminfo');
data = fs.readFileSync(file); data = fs.readFileSync(file);
} }
@ -1082,12 +1088,19 @@ Tput.prototype._parsePadding = function(code, print, done) {
*/ */
Tput.prototype.readTermcap = function(data) { Tput.prototype.readTermcap = function(data) {
var self = this; var self = this
, TERMCAP = process.env.TERMCAP || ''
, TERMPATH = process.env.TERMPATH || ''
, HOME = process.env.HOME || '';
// TODO: Check to make sure termcap data matches
// the term name, otherwise keep searching.
var data = data var data = data
|| tryRead(this.termcapFile) || tryRead(this.termcapFile)
|| tryRead(process.env.TERMCAP) || (TERMCAP[0] === '/' ? tryRead(TERMCAP) : TERMCAP)
|| process.env.TERMCAP || (TERMPATH && tryRead(TERMPATH.split(/[: ]/)))
|| tryRead(HOME + '/.termcap')
|| tryRead('/usr/share/misc/termcap')
|| tryRead('/etc/termcap') || tryRead('/etc/termcap')
|| Tput.termcap; || Tput.termcap;
@ -1412,6 +1425,13 @@ function write(data) {
} }
function tryRead(file) { function tryRead(file) {
if (Array.isArray(file)) {
for (var i = 0; i < file.length; i++) {
var data = tryRead(file[i]);
if (data) return data;
}
return '';
}
if (!file) return ''; if (!file) return '';
file = path.resolve.apply(path, arguments); file = path.resolve.apply(path, arguments);
try { try {