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);
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;
}