diff --git a/lib/tput.js b/lib/tput.js index e04f317..b34b2ea 100644 --- a/lib/tput.js +++ b/lib/tput.js @@ -501,22 +501,16 @@ Tput.prototype._compile = function(val) { } } - function read(regex) { + function read(regex, buf) { cap = regex.exec(val); if (!cap) return; val = val.substring(cap[0].length); ch = op = i = v = cap[1]; - clear(); - return cap; - } - - function read_(regex, buf) { - cap = regex.exec(val); - if (!cap) return; - val = val.substring(cap[0].length); - ch = op = i = v = cap[1]; - if (!buf) clear(); - else if (typeof buf === 'string') buff += buf; + //if (buf == null) { + clear(); + //} else if (typeof buf === 'string') { + //buff += buf; + //} return cap; } @@ -538,6 +532,7 @@ Tput.prototype._compile = function(val) { } function print(c) { + //buff += c; echo('"' + c + '"'); } @@ -551,17 +546,8 @@ Tput.prototype._compile = function(val) { while (val) { // '\e' -> ^[ - // if (read(/^\\e/i)) { - // print('\\x1b'); - // continue; - // } - // optimized: - // if (read_(/^\\e/i, '\x1b')) { - // continue; - // } - if (/^\\e/i.test(val)) { - val = val.substring(2); - buff += '\x1b'; + if (read(/^\\e/i)) { // , '\x1b')) { + print('\\x1b'); continue; }