Exemple #1
0
        public override TextRun GetTextRun(int textSourceCharacterIndex)
        {
            var linePart = linePartsCollection.GetLinePartFromColumn(textSourceCharacterIndex);

            if (linePart == null)
            {
                return(endOfLine);
            }
            var part = linePart.Value;

            if (part.AdornmentElement != null)
            {
                return(new AdornmentTextRun(part));
            }
            else
            {
                int offs   = textSourceCharacterIndex - part.Column;
                int length = part.ColumnLength - offs;
                Debug.Assert(length >= 0);
                if (length > maxLengthLeft)
                {
                    length = maxLengthLeft;
                }
                if (length == 0)
                {
                    return(endOfLine);
                }
                maxLengthLeft -= length;
                return(new TextCharacters(text, part.Span.Start + offs, length, part.TextRunProperties));
            }
        }
        public override TextRun GetTextRun(int textSourceCharacterIndex)
        {
            var linePart = linePartsCollection.GetLinePartFromColumn(textSourceCharacterIndex, ref linePartIndex);

            if (linePart is null)
            {
                return(endOfLine);
            }
            var part = linePart.Value;

            if (!(part.AdornmentElement is null))
            {
                return(new AdornmentTextRun(part));
            }
Exemple #3
0
        int GetLastColumn(SnapshotPoint point)
        {
            if (point.Snapshot != Snapshot)
            {
                throw new ArgumentException();
            }
            int column = FilterColumn(linePartsCollection.ConvertBufferPositionToColumn(point));
            var part   = linePartsCollection.GetLinePartFromColumn(column);

            if (part is not null)
            {
                var lineParts = linePartsCollection.LineParts;
                int lineIndex = point - linePartsCollection.Span.Start;
                for (int i = part.Value.Index + 1; i < lineParts.Count; i++, column++)
                {
                    var part2 = lineParts[i];
                    if (!part2.BelongsTo(lineIndex))
                    {
                        break;
                    }
                }
            }
            return(FilterColumn(column));
        }