use of suite.immutable.IRope.IRopeList in project suite by stupidsing.
the class DevMain method text.
private Text text(IRopeList<Character> text) {
IntsBuilder starts = new IntsBuilder();
IntsBuilder ends = new IntsBuilder();
IntMutable p0 = IntMutable.of(-1);
int size = text.size();
IntSink lf = px -> {
starts.append(p0.get() + 1);
ends.append(px);
p0.update(px);
};
for (int p = 0; p < size; p++) {
char ch = text.get(p);
if (ch == '\n' || wrapSize < p - p0.get())
lf.sink(p);
}
if (1 < size - p0.get())
lf.sink(size);
return new Text(text, starts.toInts().toArray(), ends.toInts().toArray());
}
Aggregations