Raxol.Terminal.Scroll.Predictor (Raxol v2.0.1)

View Source

Handles predictive scrolling operations for the terminal. Tracks recent scrolls and provides pattern analysis for smarter prediction.

Summary

Functions

Analyzes recent scroll patterns: returns average scroll size and alternation ratio.

Creates a new predictor instance.

Adds a scroll event to the history and keeps only the window size worth of history.

Types

scroll_event()

@type scroll_event() :: %{
  direction: :up | :down,
  lines: non_neg_integer(),
  timestamp: integer()
}

t()

@type t() :: %Raxol.Terminal.Scroll.Predictor{
  history: [scroll_event()],
  window_size: non_neg_integer()
}

Functions

analyze_patterns(predictor)

@spec analyze_patterns(t()) :: %{avg_lines: float(), alternation_ratio: float()}

Analyzes recent scroll patterns: returns average scroll size and alternation ratio.

new()

@spec new() :: t()

Creates a new predictor instance.

predict(predictor, direction, lines)

@spec predict(t(), :up | :down, non_neg_integer()) :: t()

Adds a scroll event to the history and keeps only the window size worth of history.