MingaEditor.Shell.Traditional.SpaceLeader (Minga v0.1.0)

Copy Markdown View Source

Pure lifecycle owner for the TUI CUA space-leader timeout window.

Each installation advances a generation. Timeout delivery carries that generation, so cancellation and replacement remain safe even when an old timer message is already in the Editor mailbox.

Summary

Functions

Begins a new pending leader window and returns its generation.

Expires only the current pending generation.

Records the timer handle only for the current pending generation.

Returns whether a space-leader window is pending.

Cancels or consumes the current pending window without changing identity.

Returns the timer handle for best-effort cancellation by a handler.

Types

generation()

@type generation() :: non_neg_integer()

t()

@type t() :: %MingaEditor.Shell.Traditional.SpaceLeader{
  generation: generation(),
  pending: boolean(),
  timer: reference() | nil
}

Functions

begin(leader)

@spec begin(t()) :: {generation(), t()}

Begins a new pending leader window and returns its generation.

expire(leader, generation)

@spec expire(t(), generation()) :: {:expired | :stale, t()}

Expires only the current pending generation.

install_timer(leader, generation, timer)

@spec install_timer(t(), generation(), reference()) :: t()

Records the timer handle only for the current pending generation.

pending?(space_leader)

@spec pending?(t()) :: boolean()

Returns whether a space-leader window is pending.

reset(leader)

@spec reset(t()) :: t()

Cancels or consumes the current pending window without changing identity.

timer(space_leader)

@spec timer(t()) :: reference() | nil

Returns the timer handle for best-effort cancellation by a handler.