collectAllStyles method

List<Style> collectAllStyles(
  1. int offset,
  2. int len
)

Returns all styles for any character within the specified text range. In essence, it is UNION of each individual segment's styles

Implementation

List<Style> collectAllStyles(int offset, int len) {
  final local = math.min(length - offset, len);
  final result = <Style>[];

  final data = queryChild(offset, true);
  var node = data.node as Leaf?;
  if (node != null) {
    result.add(node.style);
    var pos = node.length - data.offset;
    while (!node!.isLast && pos < local) {
      node = node.next as Leaf;
      result.add(node.style);
      pos += node.length;
    }
  }

  result.add(style);
  if (parent is Block) {
    final block = parent as Block;
    result.add(block.style);
  }

  final remaining = len - local;
  if (remaining > 0 && nextLine != null) {
    final rest = nextLine!.collectAllStyles(0, remaining);
    result.addAll(rest);
  }

  return result;
}