collectStyle method
Get a sublist of texts starting from start index
with the given length.
Implementation
EasyAttributeStyles collectStyle(int start, int length) {
final EasyAttributeStyles result = EasyAttributeStyles.empty();
int offset = 0;
int remain = length;
// probably i can just use extractAt, but
// i prefer just making this manually
for (final EasyText text in this) {
if (offset + text.length <= start) {
offset += text.length;
continue;
}
if (remain <= 0) break;
final int localStart = math.max(0, start - offset);
final int localEnd = math.min(
text.length,
localStart + remain,
);
if (localEnd > localStart) {
result.mergeAll(text.styles);
remain -= (localEnd - localStart);
}
offset += text.length;
}
return result;
}