sclass _PrintFlexIndent extends F1 { F1 makeIndent; bool beginningOfLine = true; *() {} *(F1 *makeIndent) {} Bool get(S s) { if (empty(s)) false; S prefix = null; if (beginningOfLine) { if (prefix == null) prefix = unnull(callF(makeIndent, s)); print_raw(prefix); } bool nl = s.endsWith("\n"); if (nl) s = dropLast(s); if (contains(s, '\n')) { if (prefix == null) prefix = unnull(callF(makeIndent, s)); if (nempty(prefix)) s = s.replace("\n", "\n" + prefix); } print_raw(s); if (nl) print_raw("\n"); beginningOfLine = nl; false; } }