From ea4542027b6c88d34a442351ddccbc6e97763382 Mon Sep 17 00:00:00 2001 From: Christopher Jeffrey Date: Mon, 25 Feb 2013 02:05:27 -0600 Subject: [PATCH] fix clr_eos/ed and other possible collisions. --- lib/program.js | 4 +++- lib/tput.js | 25 +++++++++++++++++++++++++ 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/lib/program.js b/lib/program.js index d1a4c58..56b8c63 100644 --- a/lib/program.js +++ b/lib/program.js @@ -1053,7 +1053,9 @@ Program.prototype.eraseInDisplay = function(param) { }; Program.prototype.clear = function() { - return this.eraseInDisplay('all'); + if (this.tput) return this.tput.clear(); + return this.write('\x1b[H\x1b[J'); + // return this.ed('all'); }; // CSI Ps K Erase in Line (EL). diff --git a/lib/tput.js b/lib/tput.js index 2f7f0a0..6417e5a 100644 --- a/lib/tput.js +++ b/lib/tput.js @@ -1188,6 +1188,31 @@ delete Tput.alias.numbers; merge(Tput.alias, Tput.alias.strings); delete Tput.alias.strings; +// Make sure there are no collisions between cap and tcap. +Tput._vec = []; + +Object.keys(Tput.alias).forEach(function(key) { + if (!Array.isArray(Tput.alias[key])) { + return Tput._vec.push(Tput.alias[key]); + } + Tput._vec.push(Tput.alias[key][0]); +}); + +Object.keys(Tput.alias).forEach(function(key) { + if (!Array.isArray(Tput.alias[key])) { + return; + } + + var alias = Tput.alias[key] + , tcap = alias[1]; + + if (!tcap) return; + + if (~Tput._vec.indexOf(tcap)) { + alias.splice(1, 1); + } +}); + /** * Terminfo Data */