sclass LineBuffer { VF1 onLine; new StringBuilder currentLine; *() {} *(VF1 *onLine) {} void append(S s) { append(s, onLine); } void append(S s, VF1 onLine) { currentLine.append(s); if (contains(s, '\n')) { int i = 0, j; s = str(currentLine); while ((j = indexOf(s, i, '\n')) >= 0) { S line = dropTrailingBackslashR(substring(s, i, j)); callF(onLine, line); i = j+1; } currentLine = new StringBuilder(substring(s, i)); } } int size() { ret l(currentLine); } }