GPUI.Text.Buffer (gpui v0.2.0-rc.1)

Copy Markdown View Source

Persistent native Rope text storage with revisioned atomic edits.

This is a model primitive. It does not represent a file, editor, language, gutter, or workspace. Consumers own those policies and may later attach one or more renderer primitives to the same buffer.

Summary

Functions

Creates a native text buffer with one primary selection.

Redoes one native transaction and creates a new monotonic revision.

Returns the current text, revision, selections, and history availability.

Atomically applies a transaction based on the current revision.

Undoes one native transaction and creates a new monotonic revision.

Types

result(value)

@type result(value) :: {:ok, value} | {:error, term()}

t()

@opaque t()

Functions

new(text, opts \\ [])

@spec new(
  String.t(),
  keyword()
) :: result(t())

Creates a native text buffer with one primary selection.

redo(buffer, base_revision)

@spec redo(t(), non_neg_integer()) :: result(GPUI.Text.Snapshot.t())

Redoes one native transaction and creates a new monotonic revision.

snapshot(buffer)

@spec snapshot(t()) :: result(GPUI.Text.Snapshot.t())

Returns the current text, revision, selections, and history availability.

transact(buffer, transaction)

@spec transact(t(), GPUI.Text.Transaction.t()) :: result(map())

Atomically applies a transaction based on the current revision.

undo(buffer, base_revision)

@spec undo(t(), non_neg_integer()) :: result(GPUI.Text.Snapshot.t())

Undoes one native transaction and creates a new monotonic revision.