sclass LastLineBuffer { int lineCount; S lastLine, currentLine = ""; void append(S s) { currentLine += s; int i; while ((i = currentLine.indexOf('\n')) >= 0) { // inefficient lastLine = dropTrailingBackslashR(substring(currentLine, 0, i)); currentLine = substring(currentLine, i+1); } } S lastCompleteLine() { ret lastLine; } }