diff --git a/lib/tput.js b/lib/tput.js index 728d3e4..ecc8156 100644 --- a/lib/tput.js +++ b/lib/tput.js @@ -275,6 +275,12 @@ Tput.prototype.compile = function(key) { Object.keys(info.all).forEach(function(key) { console.log('Compiling ' + key + ': ' + JSON.stringify(info.all[key])); self.methods[key] = self._compile(info.all[key]); + var alias = self.alias(key); + self.methods[alias] = self.methods[key]; + }); + + Tput.bools.concat(Tput.numbers).concat(Tput.strings).forEach(function(key) { + if (!self.methods[key]) self.methods[key] = noop; }); }; @@ -484,9 +490,9 @@ Tput.prototype._compile = function(val) { } // $<5> -> padding + // e.g. flash_screen: '\u001b[?5h$<100/>\u001b[?5l', if (read(/^\$<(\d+)>(\*|\/)/)) { code += 'o("'; - code += Array(+ch + 1).join(' '); // "padding" characters? code += '"),'; continue; } @@ -506,7 +512,6 @@ Tput.prototype._compile = function(val) { // if (read(/^%(?:(:)?([\-+# ]+))(?:(\d+)(\.\d+)?)?([doxXs])?/)) { if (read(/^%(:-|[+# ])(?:(\d+)(\.\d+)?)?([doxXs])?/)) { code += 'o("'; - code += 'TODO'; code += '"),'; continue; } @@ -1272,4 +1277,16 @@ Object.keys(Tput.prototype).forEach(function(key) { }; }); +/** + * Helpers + */ + +function noop() { + return ''; +} + +/** + * Expose + */ + module.exports = Tput;