Beispiel #1
0
    public static TextSpan GetSpan(this SourceNode node)
    {
        // TODO remove this after SourceNode has this method itself
        var pos = node.AncestorsAndSelf().Select(item =>
        {
            if (item.Parent is null)
            {
                return(0);
            }
            var precedingSiblingWidth = item.Parent.Children().Take(item.IndexInParent).Sum(x => x.GetWidth());
            return(precedingSiblingWidth);
        }).Sum();

        return(new TextSpan(pos, node.GetWidth()));
    }