Portals0.7.0 · dev (544a5c68c72e · 2026-11-28 UTC)
Loading...
Searching...
No Matches
portals::ui::FiniteTextDocument Class Reference

Copyable UI-affine finite document using the existing read-only scalar binding runtime. Copies share the document/session, not a view. Sources bind to one scene, like ui::Model; replacing a view in that scene preserves text, bookmarks, selection, savepoint and history. The core edit commits before presentation publication. A publication failure may leave the accepted document newer than its last visible value; refresh() retries publication. Methods return checked ManagedError for runApp. lastError() preserves a core typed cause. More...

#include <ui_text_document.hpp>

Public Member Functions

 FiniteTextDocument (const FiniteTextDocument &other)=default
FiniteTextDocument & operator= (const FiniteTextDocument &other)=default
Model< TextDocumentValue > source () const
std::expected< ModelBookmark, SourceError > bookmark (std::size_t offset, PositionAffinity affinity=PositionAffinity::FORWARD) const
std::expected< void, ManagedError > replace (std::size_t begin, std::size_t end, std::string_view text) const
std::expected< void, ManagedError > insert (std::size_t offset, std::string_view text) const
std::expected< void, ManagedError > undo () const
 Undo through the existing document history; empty history is a UI no-op.
std::expected< void, ManagedError > redo () const
 Redo through existing history; empty history is a UI no-op.
std::expected< void, ManagedError > restore (const ModelBookmark &bookmark) const
std::expected< void, ManagedError > restore (const std::expected< ModelBookmark, SourceError > &bookmark) const
std::expected< TextSaveTicket, ManagedError > beginSave (std::string_view target) const
std::expected< void, ManagedError > acknowledgeSave (const TextSaveTicket &ticket) const
std::expected< void, ManagedError > acknowledgeSave (const std::expected< TextSaveTicket, ManagedError > &ticket) const
std::expected< void, ManagedError > savepoint (std::string_view target) const
 Mark the current in-memory content saved; performs no physical write.
std::optional< TextDocumentError > lastError () const
std::expected< void, ManagedError > refresh () const
 Retry presentation after a prior notification failure; does not edit content.

Friends

FiniteTextDocument finiteTextDocument (std::string_view text, FiniteTextDocumentOptions options=DEFAULT_FINITE_TEXT_DOCUMENT_OPTIONS)
 Declare one finite in-memory document with a cold read-only presentation source.

Detailed Description

Copyable UI-affine finite document using the existing read-only scalar binding runtime. Copies share the document/session, not a view. Sources bind to one scene, like ui::Model; replacing a view in that scene preserves text, bookmarks, selection, savepoint and history. The core edit commits before presentation publication. A publication failure may leave the accepted document newer than its last visible value; refresh() retries publication. Methods return checked ManagedError for runApp. lastError() preserves a core typed cause.

Constructor & Destructor Documentation

◆ FiniteTextDocument()

portals::ui::FiniteTextDocument::FiniteTextDocument ( const FiniteTextDocument & other)
default
Parameters
otherShared finite session/source to retain.

Member Function Documentation

◆ acknowledgeSave() [1/2]

std::expected< void, ManagedError > portals::ui::FiniteTextDocument::acknowledgeSave ( const std::expected< TextSaveTicket, ManagedError > & ticket) const
inline
Parameters
ticketChecked request result, propagated without caller-side unwrapping.
Returns
Checked acknowledgement or the original request failure.

◆ acknowledgeSave() [2/2]

std::expected< void, ManagedError > portals::ui::FiniteTextDocument::acknowledgeSave ( const TextSaveTicket & ticket) const
inline
Parameters
ticketSuccessful save receipt; stale acknowledgements remain checked failures.
Returns
Checked savepoint/presentation result, without changing caret or history.

◆ beginSave()

std::expected< TextSaveTicket, ManagedError > portals::ui::FiniteTextDocument::beginSave ( std::string_view target) const
inline
Parameters
targetDestination metadata, not a path to be opened here.
Returns
Save ticket for the current bytes; caller acknowledges only after its save succeeds.

◆ bookmark()

std::expected< ModelBookmark, SourceError > portals::ui::FiniteTextDocument::bookmark ( std::size_t offset,
PositionAffinity affinity = PositionAffinity::FORWARD ) const
inline
Parameters
offsetCurrent UTF-8 byte boundary.
affinityInsertion preference.
Returns
Metadata-only bookmark or checked core error; no UI/view is retained.

◆ insert()

std::expected< void, ManagedError > portals::ui::FiniteTextDocument::insert ( std::size_t offset,
std::string_view text ) const
inline
Parameters
offsetInsertion byte boundary.
textBorrowed UTF-8 to copy.
Returns
Checked edit/presentation result.

◆ lastError()

std::optional< TextDocumentError > portals::ui::FiniteTextDocument::lastError ( ) const
inline
Returns
Most recent core failure, if any; UI publication failures are ManagedError only.

◆ operator=()

FiniteTextDocument & portals::ui::FiniteTextDocument::operator= ( const FiniteTextDocument & other)
default
Parameters
otherShared finite session/source to retain.
Returns
This facade after assignment.

◆ redo()

std::expected< void, ManagedError > portals::ui::FiniteTextDocument::redo ( ) const
inline

Redo through existing history; empty history is a UI no-op.

Returns
Checked edit/presentation result.

◆ refresh()

std::expected< void, ManagedError > portals::ui::FiniteTextDocument::refresh ( ) const
inline

Retry presentation after a prior notification failure; does not edit content.

Returns
Checked existing-property publication result.

◆ replace()

std::expected< void, ManagedError > portals::ui::FiniteTextDocument::replace ( std::size_t begin,
std::size_t end,
std::string_view text ) const
inline
Parameters
beginInclusive byte boundary.
endExclusive byte boundary.
textBorrowed replacement copied by the finite core.
Returns
Checked edit/presentation result; no file I/O.

◆ restore() [1/2]

std::expected< void, ManagedError > portals::ui::FiniteTextDocument::restore ( const ModelBookmark & bookmark) const
inline
Parameters
bookmarkScalar read position from this logical document/lineage.
Returns
Checked caret restoration; no write authority is inferred from the bookmark.

◆ restore() [2/2]

std::expected< void, ManagedError > portals::ui::FiniteTextDocument::restore ( const std::expected< ModelBookmark, SourceError > & bookmark) const
inline
Parameters
bookmarkChecked bookmark result, forwarded without caller-side unwrapping.
Returns
Checked restoration or source-admission error.

◆ savepoint()

std::expected< void, ManagedError > portals::ui::FiniteTextDocument::savepoint ( std::string_view target) const
inline

Mark the current in-memory content saved; performs no physical write.

Parameters
targetExplicit in-memory destination metadata.
Returns
Checked synchronous savepoint result, suitable for memory-only demonstrations.

◆ source()

Model< TextDocumentValue > portals::ui::FiniteTextDocument::source ( ) const
inline
Returns
Cold read-only model for ordinary label projections; writes are rejected.

◆ undo()

std::expected< void, ManagedError > portals::ui::FiniteTextDocument::undo ( ) const
inline

Undo through the existing document history; empty history is a UI no-op.

Returns
Checked edit/presentation result.

◆ finiteTextDocument

FiniteTextDocument finiteTextDocument ( std::string_view text,
FiniteTextDocumentOptions options = DEFAULT_FINITE_TEXT_DOCUMENT_OPTIONS )
friend

Declare one finite in-memory document with a cold read-only presentation source.

Parameters
textInitial UTF-8 copied before return.
optionsExplicit finite bounds/history policy.
Returns
Copyable UI session; admission failures are reported when its source mounts. Includes no terminal, file writer, replay or continuous polling.

The documentation for this class was generated from the following file: