From 8cca60beac453007a96f2ae324f1d1fa4bfc92b8 Mon Sep 17 00:00:00 2001 From: Christopher Jeffrey Date: Fri, 7 Jun 2013 06:42:47 -0500 Subject: [PATCH] add workaround for screen-256color terminfo. use correct terminfo fallback. --- lib/tput.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/lib/tput.js b/lib/tput.js index 40b8367..e5b591b 100644 --- a/lib/tput.js +++ b/lib/tput.js @@ -84,7 +84,7 @@ Tput.prototype._useXtermC = function() { Tput.prototype._useXtermI = function() { this.term = 'xterm'; this.termcap = false; - this.terminfoFile = __dirname + '/../usr/xterm.terminfo'; + this.terminfoFile = __dirname + '/../usr/xterm'; this.compileTerminfo(); }; @@ -225,6 +225,15 @@ Tput.prototype.parseTerminfo = function(data) { return; } + // Workaround: fix an odd bug in the screen-256color terminfo where it tries + // to set -1, but it appears to have {0xfe, 0xff} instead of {0xff, 0xff}. + // TODO: Possibly handle errors gracefully below, as well as in the + // extended info. Also possibly do: `if (info.strings[key] >= data.length)`. + if (info.strings[key] === 65534) { + delete info.strings[key]; + return; + } + var s = i + info.strings[key] , j = s;