public VisualTextLine CollapseTextRange(TextRange area, IReadOnlyList<string> lines, ICollapseRepresentation collapseRepresentationAlgorithm) {
            var precedingText = new string(lines[area.StartPosition.Line].Take(area.StartPosition.Column).ToArray());
            var followingText = new string(lines[area.EndPosition.Line].Skip(area.EndPosition.Column + 1).ToArray());
            var collapsedLineIndex = area.StartPosition.Line;
            var middlePart = new List<string>();
            var start = area.StartPosition.Line;
            var end = area.EndPosition.Line;

            if (start != end) {
                for (var i = start; i <= end; i++) {
                    var currentLine = lines[i];

                    if (i == start) {
                        currentLine = string.Join("", currentLine.Skip(area.StartPosition.Column));
                    } else if (i == end) {
                        currentLine = string.Join("", currentLine.Take(area.EndPosition.Column + 1));
                    }

                    middlePart.Add(currentLine);
                }
            } else {
                middlePart.Add(string.Join("", lines[start].Skip(area.StartPosition.Column).Take((1 + area.EndPosition.Column) - area.StartPosition.Column)));
            }

            return VisualTextLine.Create(middlePart, precedingText, followingText, collapsedLineIndex, collapseRepresentationAlgorithm.GetCollapseRepresentation());
        }
Esempio n. 2
0
        public VisualTextLine CollapseTextRange(TextRange area, IReadOnlyList <string> lines, ICollapseRepresentation collapseRepresentationAlgorithm)
        {
            var precedingText      = new string(lines[area.StartPosition.Line].Take(area.StartPosition.Column).ToArray());
            var followingText      = new string(lines[area.EndPosition.Line].Skip(area.EndPosition.Column + 1).ToArray());
            var collapsedLineIndex = area.StartPosition.Line;
            var middlePart         = new List <string>();
            var start = area.StartPosition.Line;
            var end   = area.EndPosition.Line;

            if (start != end)
            {
                for (var i = start; i <= end; i++)
                {
                    var currentLine = lines[i];

                    if (i == start)
                    {
                        currentLine = string.Join("", currentLine.Skip(area.StartPosition.Column));
                    }
                    else if (i == end)
                    {
                        currentLine = string.Join("", currentLine.Take(area.EndPosition.Column + 1));
                    }

                    middlePart.Add(currentLine);
                }
            }
            else
            {
                middlePart.Add(string.Join("", lines[start].Skip(area.StartPosition.Column).Take((1 + area.EndPosition.Column) - area.StartPosition.Column)));
            }

            return(VisualTextLine.Create(middlePart, precedingText, followingText, collapsedLineIndex, collapseRepresentationAlgorithm.GetCollapseRepresentation()));
        }
 public void InitializeTest() {
     tc = new TextCollapsingAlgorithm();
     ra = CollapseRepresentationAlgorithmFactory.GetAlgorithm(FormattingType.BRACKETS);
 }
 public void InitializeTest()
 {
     tc = new TextCollapsingAlgorithm();
     ra = CollapseRepresentationAlgorithmFactory.GetAlgorithm(FormattingType.BRACKETS);
 }