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, captured_item} 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.

Closes the source action menu if it is open.

Accepts normalized candidates for the current asynchronous fetch.

Returns whether revision is current for a source without an additional identity.

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.

Invalidates any prior asynchronous result after a ready-state context-only edit.

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

Returns the visible prefix for a switched source.

Moves the action-menu selection when the menu is open.

Returns true if a picker is currently open.

Opens the source action menu for the exact item or marked set captured by actions.

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

Returns a picker state with updated source context.

Replaces the activation offer after any result or action-menu transition.

Resolves an exact action identity from the current activation offer.

Resolves an exact item identity from the current activation offer.

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

Retargets an open picker and replaces its immutable source context atomically.

Updates the inner MingaEditor.UI.Picker instance.

Types

action_menu()

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

action_menu_direction()

@type action_menu_direction() :: :next | :previous

callback_source()

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

Contribution source semantically authorized to provide picker candidates.

fetch_identity()

@type fetch_identity() :: term() | nil

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(),
  activation_offer: MingaEditor.State.Picker.ActivationOffer.t(),
  callback_source: callback_source(),
  context: map() | nil,
  fetch_identity: fetch_identity(),
  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, identity \\ nil)

@spec begin_fetch(t(), fetch_identity()) :: {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.

close_action_menu(ps)

@spec close_action_menu(t()) :: t()

Closes the source action menu if it is open.

complete_fetch(ps, picker)

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

Accepts normalized candidates for the current asynchronous fetch.

current_fetch?(ps, revision)

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

Returns whether revision is current for a source without an additional identity.

current_fetch?(picker, revision, identity)

@spec current_fetch?(t(), fetch_revision(), fetch_identity()) :: 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.

invalidate_fetch(ps)

@spec invalidate_fetch(t()) :: t()

Invalidates any prior asynchronous result after a ready-state context-only edit.

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.

move_action_menu_selection(ps, arg2)

@spec move_action_menu_selection(t(), action_menu_direction()) :: t()

Moves the action-menu selection when the menu is open.

open?(picker)

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

Returns true if a picker is currently open.

open_action_menu(ps, actions, item)

Opens the source action menu for the exact item or marked set captured by actions.

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.

refresh_activation_offer(ps)

@spec refresh_activation_offer(t()) :: t()

Replaces the activation offer after any result or action-menu transition.

resolve_action_activation(picker, generation, activation_id)

@spec resolve_action_activation(t(), non_neg_integer(), non_neg_integer()) ::
  {:ok, MingaEditor.UI.Picker.Source.action_entry(),
   MingaEditor.UI.Picker.Item.t()}
  | :error

Resolves an exact action identity from the current activation offer.

resolve_item_activation(picker, generation, activation_id)

@spec resolve_item_activation(t(), non_neg_integer(), non_neg_integer()) ::
  {:ok, non_neg_integer(), MingaEditor.UI.Picker.Item.t()} | :error

Resolves an exact item identity from the current activation offer.

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.

retarget_with_context(ps, picker, target, context)

@spec retarget_with_context(t(), MingaEditor.UI.Picker.t(), source_target(), term()) ::
  t()

Retargets an open picker and replaces its immutable source context atomically.

update_picker(ps, picker)

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

Updates the inner MingaEditor.UI.Picker instance.