Internal state for the Buffer GenServer.
Holds the document, file path, dirty flag, and buffer-local runtime state.
Summary
Types
Buffer type controlling behavior
The source of an edit for undo/redo attribution.
File storage backend for buffer file I/O. Remote buffers still edit locally, but open/save/stat calls route through Erlang distribution.
Functions
Accepts replacement content as a new saved baseline and advances the mutation version once.
Acknowledges disk metadata without changing dirty, version, or the saved content fingerprint.
Returns true when the backing file differs from the saved baseline.
Returns whether the buffer differs from its saved version.
Returns the saved content fingerprint, if one is known.
Returns the saved file size.
Replaces save tracking with a clean baseline for loaded content.
Returns save state for content loaded from storage.
Marks the buffer as having unsaved changes and advances the mutation version.
Records the current version as the save point for dirty tracking.
Returns the saved file mtime.
Records a content change that should not by itself make a clean buffer dirty.
Restores the mutation version and recalculates dirty state from the saved version.
Retargets the buffer to a new file path without changing content or dirty state.
Recalculates dirty state from the current mutation version and saved version.
Returns the current mutation version.
Types
@type buffer_type() :: :file | :nofile | :nowrite | :prompt | :terminal
Buffer type controlling behavior:
:file: (default) normal file buffer, supports save/dirty/undo:nofile: no file association, implicitly read-only, no save:nowrite: has a file path for display but cannot save:prompt: like:nofilebut the last line is editable (for agent input, command input):terminal: backed by an external process writing into the buffer
@type edit_source() :: Minga.Buffer.EditSource.undo_source()
The source of an edit for undo/redo attribution.
@type options_server() :: Minga.Config.Options.server()
File storage backend for buffer file I/O. Remote buffers still edit locally, but open/save/stat calls route through Erlang distribution.
@type t() :: %Minga.Buffer.State{ auto_save_timer: reference() | nil, auto_save_token: reference() | nil, buffer_type: buffer_type(), change_log: Minga.Buffer.ChangeLog.t(), decorations: Minga.Core.Decorations.t(), document: Minga.Buffer.Document.t(), events_registry: Minga.Events.registry(), explicit_options: MapSet.t(atom()), face_overrides: %{required(String.t()) => keyword()}, file_path: String.t() | nil, filetype: atom(), name: String.t() | nil, options: %{required(atom()) => term()}, options_server: options_server(), persistent: boolean(), read_only: boolean(), save_state: Minga.Buffer.SaveState.t(), storage: storage(), swap_dir: String.t() | nil, swap_timer: reference() | nil, undo_history: Minga.Buffer.UndoHistory.t(), unlisted: boolean() }
Functions
@spec accept_saved_content(t(), Minga.Buffer.SaveState.metadata(), String.t()) :: t()
Accepts replacement content as a new saved baseline and advances the mutation version once.
@spec acknowledge_disk_metadata(t(), Minga.Buffer.SaveState.metadata()) :: t()
Acknowledges disk metadata without changing dirty, version, or the saved content fingerprint.
@spec changed_since_saved?( t(), integer() | nil, non_neg_integer() | nil, Minga.Buffer.SaveState.saved_content_status() ) :: boolean()
Returns true when the backing file differs from the saved baseline.
Returns whether the buffer differs from its saved version.
Returns the saved content fingerprint, if one is known.
@spec file_size(t()) :: non_neg_integer() | nil
Returns the saved file size.
@spec load_saved_content( t(), String.t() | nil, Minga.Buffer.SaveState.metadata(), String.t() ) :: t()
Replaces save tracking with a clean baseline for loaded content.
@spec loaded_save_state( String.t() | nil, Minga.Buffer.SaveState.metadata(), String.t() ) :: Minga.Buffer.SaveState.t()
Returns save state for content loaded from storage.
Marks the buffer as having unsaved changes and advances the mutation version.
@spec mark_saved(t(), Minga.Buffer.SaveState.metadata(), String.t()) :: t()
Records the current version as the save point for dirty tracking.
Returns the saved file mtime.
Records a content change that should not by itself make a clean buffer dirty.
@spec restore_version(t(), non_neg_integer()) :: t()
Restores the mutation version and recalculates dirty state from the saved version.
Retargets the buffer to a new file path without changing content or dirty state.
Recalculates dirty state from the current mutation version and saved version.
@spec version(t()) :: non_neg_integer()
Returns the current mutation version.