/// <summary> /// Finds the line that contains the given index. /// </summary> /// <param name="absolute">The absolute.</param> /// <returns>The line that contains the given index.</returns> private TextLine FindLine(int absolute) { TextLine selected = null; if (_currentLine != null) { if (_currentLine.Contains(absolute)) { selected = _currentLine; } else if (absolute > _currentLine.Index && _currentLine.Index + 1 < _lines.Count) { selected = ScanLines(absolute, _currentLine.Index); } } if (selected == null) { selected = ScanLines(absolute, 0); } _currentLine = selected; return selected; }
/// <summary> /// Pushes a new line. /// </summary> private void PushNewLine() { _endLine = new TextLine(_endLine.End, _endLine.Index + 1); _lines.Add(_endLine); }
/// <summary> /// Initializes a new instance of the <see cref="LineTrackingStringBuffer"/> class. /// </summary> public LineTrackingStringBuffer() { _endLine = new TextLine(0, 0); _lines = new List<TextLine> { _endLine }; }