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

Explicit owning finite UTF-8 document/session; no UI ownership or file I/O. Whole-buffer segmentation and existing snapshot history have costs proportional to finite admitted text. Large/windowed editors use the metadata-only map with their own boundary proofs and history. Caller serializes operations; borrowed text expires on successful text mutation or destruction. There are no callbacks. Logical identity, selection and history survive view replacement and SaveAs. More...

#include <text_document.hpp>

Inheritance diagram for portals::FiniteTextDocument:
portals::FiniteTextDocumentportals::FiniteTextDocument portals::PositionResolver

Public Member Functions

 ~FiniteTextDocument () override
 Release only this session's own text, history and metadata.
const GraphemeText & text () const noexcept
ModelResource resource () const noexcept
SourceStamp session () const noexcept
std::uint64_t revision () const noexcept
TextSelection selection () const noexcept
std::expected< void, TextDocumentError > setSelection (TextSelection selection) noexcept
std::expected< void, TextDocumentError > replace (std::size_t begin, std::size_t end, std::string_view replacement, TextHistoryKind kind=TextHistoryKind::PROGRAMMATIC)
std::expected< void, TextDocumentError > undo ()
std::expected< void, TextDocumentError > redo ()
bool canUndo () const noexcept
bool canRedo () const noexcept
std::expected< ModelBookmark, SourceError > bookmark (std::size_t byteOffset, PositionAffinity affinity=PositionAffinity::FORWARD) const
std::expected< PositionReply, SourceError > resolve (const PositionRequest &request, std::stop_token stop={}) const override
std::expected< TextSaveTicket, TextDocumentError > beginSave (std::string_view target)
std::expected< void, TextDocumentError > acknowledgeSave (const TextSaveTicket &ticket) noexcept
bool dirty () const noexcept
std::string_view saveTarget () const noexcept
void observeExternalReplacement () noexcept
 Report external replacement without accepting unrelated bytes or clearing history.
bool conflicted () const noexcept
std::expected< void, TextDocumentError > acceptExternalReplacement (std::string_view text)
Public Member Functions inherited from portals::PositionResolver
virtual ~PositionResolver ()=default
 Release only the resolver's own bounded metadata.

Static Public Member Functions

static std::expected< std::unique_ptr< FiniteTextDocument >, TextDocumentError > create (std::string_view text, FiniteTextDocumentOptions options={})

Detailed Description

Explicit owning finite UTF-8 document/session; no UI ownership or file I/O. Whole-buffer segmentation and existing snapshot history have costs proportional to finite admitted text. Large/windowed editors use the metadata-only map with their own boundary proofs and history. Caller serializes operations; borrowed text expires on successful text mutation or destruction. There are no callbacks. Logical identity, selection and history survive view replacement and SaveAs.

Member Function Documentation

◆ acceptExternalReplacement()

std::expected< void, TextDocumentError > portals::FiniteTextDocument::acceptExternalReplacement ( std::string_view text)
Parameters
textExplicitly accepted new baseline, copied/validated before publication.
Returns
Success or checked failure; advances lineage and clears incompatible marks/history. This starts a new compatible-history generation, keeping logical resource identity.

◆ acknowledgeSave()

std::expected< void, TextDocumentError > portals::FiniteTextDocument::acknowledgeSave ( const TextSaveTicket & ticket)
noexcept
Parameters
ticketSuccessful physical write acknowledgement from this document.
Returns
Success or STALE/CONFLICT; older acknowledgements cannot replace newer savepoints. SaveAs updates only physical target/savepoint, never selection, identity or history.

◆ beginSave()

std::expected< TextSaveTicket, TextDocumentError > portals::FiniteTextDocument::beginSave ( std::string_view target)
Parameters
targetNonempty physical target metadata; no I/O or target change yet.
Returns
Ticket for current content; allocation failure preserves the document.

◆ bookmark()

std::expected< ModelBookmark, SourceError > portals::FiniteTextDocument::bookmark ( std::size_t byteOffset,
PositionAffinity affinity = PositionAffinity::FORWARD ) const
Parameters
byteOffsetCurrent byte boundary, converted by this finite adapter only.
affinityInsertion preference, retained in the scalar bookmark.
Returns
General ModelBookmark(TEXT), with UTF-8 byte offset in its captured revision.

◆ canRedo()

bool portals::FiniteTextDocument::canRedo ( ) const
noexcept
Returns
Whether existing bounded history has a retained Redo operation.

◆ canUndo()

bool portals::FiniteTextDocument::canUndo ( ) const
noexcept
Returns
Whether existing bounded history has a retained Undo operation.

◆ conflicted()

bool portals::FiniteTextDocument::conflicted ( ) const
noexcept
Returns
Whether an explicit external replacement awaits caller resolution.

◆ create()

std::expected< std::unique_ptr< FiniteTextDocument >, TextDocumentError > portals::FiniteTextDocument::create ( std::string_view text,
FiniteTextDocumentOptions options = {} )
static
Parameters
textInitial borrowed UTF-8, copied/segmented before success.
optionsExplicit finite text/history and metadata bounds.
Returns
Owning session or checked admission failure.

◆ dirty()

bool portals::FiniteTextDocument::dirty ( ) const
noexcept
Returns
Current content differs from acknowledged content state, or external conflict is present.

◆ redo()

std::expected< void, TextDocumentError > portals::FiniteTextDocument::redo ( )
Returns
Success or EMPTY/technical failure; restores text and session selection.

◆ replace()

std::expected< void, TextDocumentError > portals::FiniteTextDocument::replace ( std::size_t begin,
std::size_t end,
std::string_view replacement,
TextHistoryKind kind = TextHistoryKind::PROGRAMMATIC )
Parameters
beginInclusive byte boundary.
endExclusive byte boundary, at or after begin.
replacementBorrowed replacement UTF-8; copied before publication.
kindExisting history category controlling optional grouping.
Returns
Success or checked failure; collapses selection after inserted graphemes.

◆ resolve()

std::expected< PositionReply, SourceError > portals::FiniteTextDocument::resolve ( const PositionRequest & request,
std::stop_token stop = {} ) const
overridevirtual
Parameters
requestExactly qualified general position request.
stopCooperative cancellation.
Returns
General position receipt with a validated UTF-8 byte-boundary offset. A disappeared boundary snaps BACKWARD before, or FORWARD after, its current cluster.

Implements portals::PositionResolver.

◆ resource()

ModelResource portals::FiniteTextDocument::resource ( ) const
noexcept
Returns
Logical identity, unchanged by saving or physical target replacement.

◆ revision()

std::uint64_t portals::FiniteTextDocument::revision ( ) const
noexcept
Returns
Current monotonic text revision; selection/save operations do not advance it.

◆ saveTarget()

std::string_view portals::FiniteTextDocument::saveTarget ( ) const
noexcept
Returns
Last acknowledged physical destination; borrowed until newer acknowledgement/destruction.

◆ selection()

TextSelection portals::FiniteTextDocument::selection ( ) const
noexcept
Returns
Current byte-boundary selection.

◆ session()

SourceStamp portals::FiniteTextDocument::session ( ) const
noexcept
Returns
Delivery namespace used for PositionRequest qualification.

◆ setSelection()

std::expected< void, TextDocumentError > portals::FiniteTextDocument::setSelection ( TextSelection selection)
noexcept
Parameters
selectionCurrent byte boundaries, including end.
Returns
Success or NOT_BOUNDARY; breaks typing/deletion grouping.

◆ text()

const GraphemeText & portals::FiniteTextDocument::text ( ) const
noexcept
Returns
Borrowed current segmented text, invalidated by text mutation/destruction.

◆ undo()

std::expected< void, TextDocumentError > portals::FiniteTextDocument::undo ( )
Returns
Success or EMPTY/technical failure; restores text and session selection.

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