collectAllIndividualStyles method
Returns each node segment's offset in selection with its corresponding style as a list
Implementation
List<Tuple2<int, Style>> collectAllIndividualStyles(int offset, int len,
{int beg = 0}) {
final local = math.min(length - offset, len);
final result = <Tuple2<int, Style>>[];
final data = queryChild(offset, true);
var node = data.node as Leaf?;
if (node != null) {
var pos = 0;
if (node is Text) {
pos = node.length - data.offset;
result.add(Tuple2(beg, node.style));
}
while (!node!.isLast && pos < local) {
node = node.next as Leaf;
if (node is Text) {
result.add(Tuple2(pos + beg, node.style));
pos += node.length;
}
}
}
// TODO: add line style and parent's block style
final remaining = len - local;
if (remaining > 0 && nextLine != null) {
final rest =
nextLine!.collectAllIndividualStyles(0, remaining, beg: local);
result.addAll(rest);
}
return result;
}