text(data, className);
return;
}
int tail = 0;
Match match = CONTROL.match(data, 0);
while (match != null)
{
int pos = match.getIndex();
// If we passed over any plain text on the way to this control
// character, add it.
text(data.substring(tail, pos), className);
tail = pos + 1;
switch (data.charAt(pos))
{
case '\r':
carriageReturn();
break;
case '\b':
backspace();
break;
case '\n':
newline();
break;
case '\f':
formfeed();
break;
default:
assert false : "Unknown control char, please check regex";
text(data.charAt(pos) + "", className);
break;
}
match = match.nextMatch();
}
// If there was any plain text after the last control character, add it
text(data.substring(tail), className);
}