MingaEditor.State.FileTree (Minga v0.1.0)

Copy Markdown View Source

File tree sub-state: tree data, focus, and backing buffer.

Wraps the file-tree-related fields from EditorState into a single struct with query and mutation helpers. Includes inline editing state for new file, new folder, and rename operations.

Summary

Types

Inline editing state for creating files/folders or renaming entries.

t()

File tree sub-state.

Functions

Cancels inline editing, clearing the editing state back to nil.

Closes the tree and clears the buffer.

Returns true when inline editing is active.

Returns true when the file tree is open and focused.

Opens the tree with the given data, buffer, and focused state.

Returns true when the file tree is open.

Enters inline editing mode at the given index.

Updates the text being typed in the inline editor.

Returns the tree width, or 0 if the tree is not open.

Types

editing()

@type editing() :: %{
  index: non_neg_integer(),
  text: String.t(),
  type: editing_type(),
  original_name: String.t() | nil
}

editing_type()

@type editing_type() :: :new_file | :new_folder | :rename

Inline editing state for creating files/folders or renaming entries.

When non-nil, the user is actively typing a filename in the tree. The index is the visual position in the visible entry list where the editing row appears. For new file/folder, this is the insertion point. For rename, this is the entry being renamed.

t()

@type t() :: %MingaEditor.State.FileTree{
  buffer: pid() | nil,
  editing: editing() | nil,
  focused: boolean(),
  project_root: String.t() | nil,
  tree: Minga.Project.FileTree.t() | nil
}

File tree sub-state.

Functions

cancel_editing(ft)

@spec cancel_editing(t()) :: t()

Cancels inline editing, clearing the editing state back to nil.

close(ft)

@spec close(t()) :: t()

Closes the tree and clears the buffer.

editing?(file_tree)

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

Returns true when inline editing is active.

focused?(file_tree)

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

Returns true when the file tree is open and focused.

open(ft, tree, buffer)

@spec open(t(), Minga.Project.FileTree.t(), pid() | nil) :: t()

Opens the tree with the given data, buffer, and focused state.

open?(file_tree)

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

Returns true when the file tree is open.

start_editing(ft, index, type, initial_text \\ "")

@spec start_editing(t(), non_neg_integer(), editing_type(), String.t()) :: t()

Enters inline editing mode at the given index.

For new file/folder, initial_text is empty. For rename, initial_text is the current entry name.

update_editing_text(ft, new_text)

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

Updates the text being typed in the inline editor.

width(file_tree)

@spec width(t()) :: non_neg_integer()

Returns the tree width, or 0 if the tree is not open.