private void Set(ScreenBufferLinesRange range) { lines.Clear(); lines.AddRange(range.Lines); beginPosition = range.BeginPosition; endPosition = range.EndPosition; if (Debugger.IsAttached) { VerifyInvariants(); } }
private void Prepend(ScreenBufferLinesRange range) { diagnostics.VerifyPositionsOrderBeforeRangeConcatenation( range.EndPosition, beginPosition, source.HasConsecutiveMessages); lines.InsertRange(0, range.Lines); beginPosition = range.BeginPosition; if (Debugger.IsAttached) { VerifyInvariants(); } }
public async Task LoadBefore(int nrOfLines, CancellationToken cancellation) { if (Count > 0) { var firstLine = Get(0); var existingNrOfLines = Math.Min(nrOfLines, firstLine.LineIndex); var range1 = new ScreenBufferLinesRange { Lines = Enumerable.Range(firstLine.LineIndex - existingNrOfLines, existingNrOfLines) .Select(ln => new DisplayLine(firstLine.Message, ln, firstLine.TotalLinesInMessage, displayTextGetter, source)).ToList(), BeginPosition = firstLine.Message.Position, EndPosition = BeginPosition }; Prepend(range1); nrOfLines -= existingNrOfLines; } if (nrOfLines > 0) { var range2 = await GetScreenBufferLines(Source, BeginPosition, nrOfLines, EnumMessagesFlag.Backward, displayTextGetter, diagnostics, cancellation); Prepend(range2); } }
public async Task LoadAfter(int nrOfLines, CancellationToken cancellation) { if (Count > 0) { var lastLine = Get(Count - 1); var existingNrOfLines = Math.Min(nrOfLines, lastLine.TotalLinesInMessage - lastLine.LineIndex - 1); var range1 = new ScreenBufferLinesRange { Lines = Enumerable.Range(lastLine.LineIndex + 1, existingNrOfLines).Select(ln => new DisplayLine( lastLine.Message, ln, lastLine.TotalLinesInMessage, displayTextGetter, source)).ToList(), BeginPosition = EndPosition, EndPosition = lastLine.Message.EndPosition }; Append(range1); nrOfLines -= existingNrOfLines; } if (nrOfLines > 0) { var range2 = await GetScreenBufferLines(Source, EndPosition, nrOfLines, EnumMessagesFlag.Forward, displayTextGetter, diagnostics, cancellation); Append(range2); } }