MingaEditor.InlineOverlay.Prompt (Minga v0.1.0)

Copy Markdown View Source

Shared prompt-input and scroll mechanics for inline overlays.

Inline ask and inline edit edit a :prompt string while :status is :input, and scroll their body with a :scroll offset clamped at zero. Those transitions only touch fields common to both variant structs, so they live here once instead of being copied per variant.

Each function takes and returns the variant's own struct, so the variant modules keep their @enforce_keys, kind-specific fields, and terminal transitions while delegating these shared edits.

Summary

Types

An overlay struct carrying :prompt, :status, and :scroll.

Functions

Appends text to the prompt while the overlay is accepting input.

Deletes one prompt grapheme while the overlay is accepting input.

Scrolls the overlay body, clamped at zero.

Types

overlay()

@type overlay() :: %{
  :__struct__ => module(),
  :prompt => String.t(),
  :status => atom(),
  :scroll => non_neg_integer(),
  optional(atom()) => term()
}

An overlay struct carrying :prompt, :status, and :scroll.

Functions

append_input(overlay, text)

@spec append_input(overlay(), String.t()) :: overlay()

Appends text to the prompt while the overlay is accepting input.

backspace(overlay)

@spec backspace(overlay()) :: overlay()

Deletes one prompt grapheme while the overlay is accepting input.

scroll(overlay, delta)

@spec scroll(overlay(), integer()) :: overlay()

Scrolls the overlay body, clamped at zero.