MingaEditor.State.Picker (Minga v0.1.0)

Copy Markdown View Source

Groups picker-related fields from EditorState.

Tracks the current picker instance, the source module providing candidates, the buffer index to restore on cancel, and the action-menu overlay state.

Summary

Types

Action menu state: {actions, selected_index} or nil when closed.

Contribution source semantically authorized to provide picker candidates.

Latest-wins guard for async candidate fetches. Each open_async mints a fresh reference; a result whose revision doesn't match the live picker's is stale and dropped. A newer search, project switch, or reopen supersedes older in-flight fetches.

Async loading status for sources that fetch candidates in the background.

Latest native query edit accepted by the BEAM.

Correlation generation for native full-query editing.

Source-switch state for the picker currently shown.

Source metadata installed by a picker source transition.

t()

Functions

Installs an accepted native query and advances its acknowledgement.

Mints a fresh fetch revision and marks the picker as loading.

Starts a fresh native query-editing generation.

Accepts normalized candidates for the current asynchronous fetch.

Returns whether revision is the picker's current (live) fetch revision.

Returns whether a native query edit belongs to this picker and is newer than its acknowledgement.

Records a user-visible failure for the current asynchronous fetch.

Builds the semantic state for an asynchronous picker before fetching starts.

Returns the visible prefix for a switched source.

Returns true if a picker is currently open.

Returns whether this picker is semantically owned by a contribution source.

Returns a picker state with updated source context.

Retargets an open picker while retaining its session-owned fields.

Updates the inner MingaEditor.UI.Picker instance.

Types

action_menu()

@type action_menu() ::
  {[MingaEditor.UI.Picker.Source.action_entry()], non_neg_integer()} | nil

Action menu state: {actions, selected_index} or nil when closed.

callback_source()

@type callback_source() ::
  Minga.Extension.ContributionCleanup.contribution_source() | nil

Contribution source semantically authorized to provide picker candidates.

fetch_revision()

@type fetch_revision() :: reference() | nil

Latest-wins guard for async candidate fetches. Each open_async mints a fresh reference; a result whose revision doesn't match the live picker's is stale and dropped. A newer search, project switch, or reopen supersedes older in-flight fetches.

load_status()

@type load_status() :: :ready | :loading | {:error, String.t()}

Async loading status for sources that fetch candidates in the background.

query_edit_seq()

@type query_edit_seq() :: non_neg_integer()

Latest native query edit accepted by the BEAM.

query_generation()

@type query_generation() :: non_neg_integer()

Correlation generation for native full-query editing.

source_switch()

@type source_switch() :: :original | {:switched, module(), String.t()}

Source-switch state for the picker currently shown.

source_target()

@type source_target() ::
  {module(), callback_source(), MingaEditor.UI.Picker.Source.layout()}

Source metadata installed by a picker source transition.

source_transition()

@type source_transition() :: {:switch, String.t()} | :restore

t()

@type t() :: %MingaEditor.State.Picker{
  acknowledged_query_edit_seq: query_edit_seq(),
  action_menu: action_menu(),
  callback_source: callback_source(),
  context: map() | nil,
  fetch_revision: fetch_revision(),
  layout: MingaEditor.UI.Picker.Source.layout(),
  load_status: load_status(),
  picker: MingaEditor.UI.Picker.t() | nil,
  query_generation: query_generation(),
  restore: non_neg_integer() | nil,
  restore_theme: MingaEditor.UI.Theme.t() | nil,
  source: module() | nil,
  source_switch: source_switch()
}

Functions

accept_query_edit(ps, picker, edit_seq)

@spec accept_query_edit(t(), MingaEditor.UI.Picker.t(), query_edit_seq()) :: t()

Installs an accepted native query and advances its acknowledgement.

begin_fetch(ps)

@spec begin_fetch(t()) :: {t(), reference()}

Mints a fresh fetch revision and marks the picker as loading.

Call this when starting an async candidate fetch. The returned {ps, revision} tuple lets the caller tag the off-path fetch with revision so a stale result (one whose revision no longer matches the live picker) can be dropped.

begin_query_session(ps)

@spec begin_query_session(t()) :: t()

Starts a fresh native query-editing generation.

complete_fetch(ps, picker)

@spec complete_fetch(t(), MingaEditor.UI.Picker.t()) :: t()

Accepts normalized candidates for the current asynchronous fetch.

current_fetch?(picker, revision)

@spec current_fetch?(t(), fetch_revision()) :: boolean()

Returns whether revision is the picker's current (live) fetch revision.

current_query_edit?(picker, generation, edit_seq)

@spec current_query_edit?(t(), query_generation(), query_edit_seq()) :: boolean()

Returns whether a native query edit belongs to this picker and is newer than its acknowledgement.

fail_fetch(ps, reason)

@spec fail_fetch(t(), String.t()) :: t()

Records a user-visible failure for the current asynchronous fetch.

loading(picker, source, callback_source, restore, restore_theme, context, layout)

Builds the semantic state for an asynchronous picker before fetching starts.

mode_prefix(picker)

@spec mode_prefix(t()) :: String.t()

Returns the visible prefix for a switched source.

open?(picker)

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

Returns true if a picker is currently open.

owned_by?(picker, source)

@spec owned_by?(t(), callback_source()) :: boolean()

Returns whether this picker is semantically owned by a contribution source.

put_context(ps, context)

@spec put_context(t(), map() | nil) :: t()

Returns a picker state with updated source context.

retarget(ps, picker, target, arg4)

@spec retarget(t(), MingaEditor.UI.Picker.t(), source_target(), source_transition()) ::
  t()

Retargets an open picker while retaining its session-owned fields.

update_picker(ps, picker)

@spec update_picker(t(), MingaEditor.UI.Picker.t()) :: t()

Updates the inner MingaEditor.UI.Picker instance.