From 962a7bdcc62e8967f8723c035a9c7c9f546051da Mon Sep 17 00:00:00 2001 From: Christopher Jeffrey Date: Tue, 5 Mar 2013 17:38:41 -0600 Subject: [PATCH] handle terminfo fallback better. --- lib/tput.js | 34 +++++++++++++++++++++++++++------- 1 file changed, 27 insertions(+), 7 deletions(-) diff --git a/lib/tput.js b/lib/tput.js index 20c6c47..299963c 100644 --- a/lib/tput.js +++ b/lib/tput.js @@ -51,16 +51,36 @@ function Tput(options) { this.compileTerminfo(); } } catch (e) { - // if (e.message === 'Terminal not found.') { - this.term = 'vt102'; - this.compileTermcap(); - // this.term = 'xterm'; - // this.termcap = true; - // this.termcapFile = __dirname + '/../usr/xterm.termcap'; - // this.compileTermcap(); + // If there was an error, fallback + // to an internally stored terminfo/cap. + this._useXtermI(); } } +/** + * Fallback + */ + +Tput.prototype._useVt102C = function() { + this.term = 'vt102'; + this.termcap = true; + this.compileTermcap(); +}; + +Tput.prototype._useXtermC = function() { + this.term = 'xterm'; + this.termcap = true; + this.termcapFile = __dirname + '/../usr/xterm.termcap'; + this.compileTermcap(); +}; + +Tput.prototype._useXtermI = function() { + this.term = 'xterm'; + this.termcap = false; + this.terminfoFile = __dirname + '/../usr/xterm.terminfo'; + this.compileTerminfo(); +}; + /** * Terminfo */