padding. flags. all methods.

This commit is contained in:
Christopher Jeffrey 2013-02-19 13:21:28 -06:00
parent 2984a58930
commit 40d89449f6
1 changed files with 19 additions and 2 deletions

View File

@ -275,6 +275,12 @@ Tput.prototype.compile = function(key) {
Object.keys(info.all).forEach(function(key) { Object.keys(info.all).forEach(function(key) {
console.log('Compiling ' + key + ': ' + JSON.stringify(info.all[key])); console.log('Compiling ' + key + ': ' + JSON.stringify(info.all[key]));
self.methods[key] = self._compile(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 // $<5> -> padding
// e.g. flash_screen: '\u001b[?5h$<100/>\u001b[?5l',
if (read(/^\$<(\d+)>(\*|\/)/)) { if (read(/^\$<(\d+)>(\*|\/)/)) {
code += 'o("'; code += 'o("';
code += Array(+ch + 1).join(' '); // "padding" characters?
code += '"),'; code += '"),';
continue; continue;
} }
@ -506,7 +512,6 @@ Tput.prototype._compile = function(val) {
// if (read(/^%(?:(:)?([\-+# ]+))(?:(\d+)(\.\d+)?)?([doxXs])?/)) { // if (read(/^%(?:(:)?([\-+# ]+))(?:(\d+)(\.\d+)?)?([doxXs])?/)) {
if (read(/^%(:-|[+# ])(?:(\d+)(\.\d+)?)?([doxXs])?/)) { if (read(/^%(:-|[+# ])(?:(\d+)(\.\d+)?)?([doxXs])?/)) {
code += 'o("'; code += 'o("';
code += 'TODO';
code += '"),'; code += '"),';
continue; continue;
} }
@ -1272,4 +1277,16 @@ Object.keys(Tput.prototype).forEach(function(key) {
}; };
}); });
/**
* Helpers
*/
function noop() {
return '';
}
/**
* Expose
*/
module.exports = Tput; module.exports = Tput;