private void PrepareLogicalLineForPrinting(LogicalLine logicalLine, LogicalLinesHistoryQueue prepared) { if (Configs.IsContextBeforeUsed && _logicalLinesHistoryQueue.Any() && _logicalLine.IsVisible) { prepared.Enqueue(_logicalLinesHistoryQueue); _logicalLinesHistoryQueue.Clear(); } prepared.Enqueue(logicalLine); if (_afterCounter > 0) { --_afterCounter; } }
private void FindLastLinesInStream(Stream stream) { if (_lastLinesProcessed || Configs.LinesStartFrom != NumLinesStart.End) { return; } if (_startFromNum != 0) { var logicalLinesHistory = new LogicalLinesHistoryQueue( _startFromNum * (Configs.ContextLines + 1)); if (stream.CanSeek) { if (!ProcessStreamInPages(stream, logicalLinesHistory)) { // optimization is not working, try without optimization ResetCounters(); logicalLinesHistory.Clear(); ProcessStreamFromLastPosToEnd(stream, logicalLinesHistory); } } else { ProcessStreamFromLastPosToEnd(stream, logicalLinesHistory); } FlushLogicalLine(logicalLinesHistory); while (logicalLinesHistory.Any()) { var forPrinting = new LogicalLinesHistoryQueue(); PrepareLogicalLineForPrinting(logicalLinesHistory.Dequeue(), forPrinting); PrintLogicalLines(forPrinting); } } LastPos = FileSize; _lastLinesProcessed = true; }