This commit is contained in:
Christopher Jeffrey 2013-02-27 17:26:34 -06:00
parent 3897e49ef8
commit fe004fff34

View File

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