public SourceBuffer(SourceBuffer other) { this.source = other.source; this.beginPosition = other.beginPosition; this.endPosition = other.endPosition; this.lines.AddRange(other.lines); }
public SourceBuffer(SourceBuffer other) { this.source = other.source; this.beginPosition = other.beginPosition; this.endPosition = other.endPosition; this.lines.AddRange(other.lines); this.id = source.LogSourceHint?.ConnectionId ?? this.GetHashCode().ToString("x8"); }
public SourceBuffer(SourceBuffer other, MessageTextGetter displayTextGetter) { this.source = other.source; this.displayTextGetter = displayTextGetter; if (other.displayTextGetter == this.displayTextGetter) { this.beginPosition = other.beginPosition; this.endPosition = other.endPosition; this.lines.AddRange(other.lines); } else { this.beginPosition = other.beginPosition; this.endPosition = other.beginPosition; } this.loggableId = source.LogSourceHint?.ConnectionId ?? this.GetHashCode().ToString("x8"); this.diagnostics = other.diagnostics; }
static async Task <ScreenBufferMessagesRange> GetScreenBufferLines( SourceBuffer src, int count, bool rawLogMode, CancellationToken cancellation) { var part1 = new ScreenBufferMessagesRange(); part1.Lines = new List <DisplayLine>(); if (src.Count > 0) { if (count < 0) { var top = src.Get(0); if (top.LineIndex != 0) { var messageLinesCount = top.Message.GetDisplayText(rawLogMode).GetLinesCount(); for (var i = 0; i < top.LineIndex; ++i) { part1.Lines.Add(new DisplayLine(top.Message, i, messageLinesCount)); if (++count == 0) { break; } } } } else if (count > 0) { var botton = src.Get(src.Count - 1); var messageLinesCount = botton.Message.GetDisplayText(rawLogMode).GetLinesCount(); if (botton.LineIndex < (messageLinesCount - 1)) { for (int i = botton.LineIndex + 1; i < messageLinesCount; ++i) { part1.Lines.Add(new DisplayLine(botton.Message, i, messageLinesCount)); if (--count == 0) { break; } } } } if (part1.Lines.Count > 0) { part1.BeginPosition = part1.Lines[0].Message.Position; part1.EndPosition = part1.Lines.Last().Message.EndPosition; } if (count == 0) { return(part1); } } var part2 = await GetScreenBufferLines( src.Source, count < 0?src.BeginPosition : src.EndPosition, Math.Abs(count), count < 0?EnumMessagesFlag.Backward : EnumMessagesFlag.Forward, rawLogMode, cancellation ); if (part1.Lines.Count == 0) { return(part2); } if (count > 0) { part1.Lines.AddRange(part2.Lines); part1.EndPosition = part2.EndPosition; } else { part1.Lines.InsertRange(0, part2.Lines); part1.BeginPosition = part2.BeginPosition; } return(part1); }