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

            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));
            }
        }
Exemple #2
0
        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));
            }
        int GetLastColumn(int position)
        {
            int column = FilterColumn(linePartsCollection.ConvertLinePositionToColumn(position));
            var part   = linePartsCollection.GetLinePartFromColumn(column);

            if (!(part is null))
            {
                var lineParts = linePartsCollection.LineParts;
                int lineIndex = position - 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));
        }