Minga.Core.Decorations.FoldRegion (Minga v0.1.0)

Copy Markdown View Source

A buffer-level fold region decoration: a collapsible range with a custom placeholder.

Unlike per-window folds (managed by FoldMap), decoration folds are per-buffer. Every window showing the buffer sees the same fold state. This is the right model for agent chat thinking blocks, tool output, and other decoration-driven collapsible content.

The placeholder callback receives the fold's start line, end line, and available width, and returns styled segments for the summary line shown when the fold is closed.

Summary

Types

Placeholder render callback for a closed fold region.

t()

Functions

Returns true if the given buffer line is within this fold (start inclusive, end inclusive).

Returns the number of lines hidden when this fold is closed.

Returns true if the given buffer line is hidden by this closed fold.

Types

placeholder_fn()

@type placeholder_fn() ::
  (non_neg_integer(), non_neg_integer(), pos_integer() ->
     [{String.t(), Minga.Core.Face.t()}])
  | nil

Placeholder render callback for a closed fold region.

Receives (start_line, end_line, width) and returns styled segments. When nil, the default placeholder "··· N lines" is used.

t()

@type t() :: %Minga.Core.Decorations.FoldRegion{
  closed: boolean(),
  end_line: non_neg_integer(),
  group: term() | nil,
  id: reference(),
  placeholder: placeholder_fn(),
  start_line: non_neg_integer()
}

Functions

contains?(fold_region, line)

@spec contains?(t(), non_neg_integer()) :: boolean()

Returns true if the given buffer line is within this fold (start inclusive, end inclusive).

hidden_count(fold_region)

@spec hidden_count(t()) :: non_neg_integer()

Returns the number of lines hidden when this fold is closed.

hides?(fold_region, line)

@spec hides?(t(), non_neg_integer()) :: boolean()

Returns true if the given buffer line is hidden by this closed fold.