Class ScrollbackBuffer

java.lang.Object
org.aesh.terminal.tty.split.ScrollbackBuffer

public class ScrollbackBuffer extends Object
A circular buffer that stores lines for a screen region's scrollback history.

When the buffer reaches its maximum capacity, the oldest lines are dropped. Thread-safe for concurrent reads and writes.

  • Constructor Details

    • ScrollbackBuffer

      public ScrollbackBuffer(int maxLines)
      Creates a scrollback buffer with the specified capacity.
      Parameters:
      maxLines - maximum number of lines to store
  • Method Details

    • addLine

      public void addLine(String line)
      Add a line to the buffer. If the buffer is full, the oldest line is dropped.
      Parameters:
      line - the line to add
    • getLastLines

      public List<String> getLastLines(int count)
      Get the last N lines from the buffer (most recent at the end).
      Parameters:
      count - maximum number of lines to return
      Returns:
      list of lines, oldest first
    • size

      public int size()
      Returns the number of lines currently stored.
      Returns:
      the line count
    • clear

      public void clear()
      Clear all stored lines.