6#include <portals/text.hpp>
59 std::string
bytes = std::string(0,
'\0');
116 [[nodiscard]] std::
size_t cursor() const noexcept;
120 [[nodiscard]] std::
size_t anchor() const noexcept;
137 friend class TextHistory;
140 std::unique_ptr<State> state_;
179 [[nodiscard]] std::expected<PreparedTextHistory, TextHistoryError>
184 [[nodiscard]] std::expected<PreparedTextHistory, TextHistoryError>
prepareUndo()
const;
188 [[nodiscard]] std::expected<PreparedTextHistory, TextHistoryError>
prepareRedo()
const;
193 [[nodiscard]] std::expected<PreparedTextHistory, TextHistoryError>
227 std::unique_ptr<State> state_;
Owning validated UTF-8 and immutable extended grapheme measurements.
Definition text.hpp:145
Owning, move-only staged history and already segmented restoration text.
Definition text_history.hpp:93
std::uint64_t contentState() const noexcept
const GraphemeText * text() const noexcept
Borrow the already segmented target before publication.
std::size_t retainedBytes() const noexcept
std::size_t anchor() const noexcept
Return the validated target selection anchor.
PreparedTextHistory & operator=(PreparedTextHistory &&other) noexcept
Replace this handle without allocating.
void takeText(GraphemeText &destination) noexcept
Transfer staged text into existing storage without allocating.
std::size_t cursor() const noexcept
Return the validated target cursor.
PreparedTextHistory(PreparedTextHistory &&other) noexcept
Transfer a prepared value without allocating.
bool changed() const noexcept
Report whether preparation changes recorded history.
~PreparedTextHistory()
Release abandoned staging without changing the owner.
bool canUndo() const noexcept
Query local undo availability; editor eligibility belongs to the external owner.
void stopGrouping() noexcept
End the open editing group; invalidates outstanding staging without allocation.
std::size_t retainedBytes() const noexcept
Query retained logical memory, excluding documented overhead.
~TextHistory()
Release all owning history storage.
std::expected< void, TextHistoryError > checkPrepared(const PreparedTextHistory &prepared) const noexcept
Check that a prepared value can be committed before publishing its text.
std::expected< PreparedTextHistory, TextHistoryError > prepareUndo() const
Stage one undo with restoration segmentation under captured settings.
TextHistory(TextHistoryOptions options={}, WidthPolicy policy={}, TextLimits limits={})
Create an empty history under immutable text validation settings.
std::expected< void, TextHistoryError > commit(PreparedTextHistory &&prepared) noexcept
Publish prepared history without allocation or callbacks.
std::uint64_t contentState() const noexcept
std::expected< PreparedTextHistory, TextHistoryError > prepareRedo() const
Stage one redo with restoration segmentation under captured settings.
std::expected< PreparedTextHistory, TextHistoryError > prepareResetBaseline(const TextHistorySnapshot &baseline) const
Validate a new external baseline and stage clearing every group, even for equal bytes.
bool canRedo() const noexcept
Query local redo availability.
std::expected< PreparedTextHistory, TextHistoryError > prepareEdit(const TextHistorySnapshot &before, const TextHistorySnapshot &after, TextHistoryKind kind) const
Prepare a whole edit without changing this history.
std::size_t operationCount() const noexcept
Count all retained undo and redo groups.
Public Portals API.
Definition action.hpp:8
TextHistoryError
Technical history failure; no state is changed on failure.
Definition text_history.hpp:67
@ PASTE
Paste category without clipboard or payload.
Definition diagnostics.hpp:65
@ EMPTY
Successful content has zero logical rows.
Definition data_presentation.hpp:14
@ STALE
Receipt belongs to another document or superseded save request.
Definition text_document.hpp:95
@ EXHAUSTED
A monotonic counter cannot advance.
Definition text_document.hpp:96
@ INVALID_TEXT
Projected row is not admitted UTF-8 under the scene text policy.
Definition find_bar.hpp:53
@ NO_MEMORY
Allocation failed at a runner exception boundary.
Definition application.hpp:33
TextHistoryKind
Semantic editing categories; only the first three can form groups.
Definition text_history.hpp:38
@ CUT
A separate clipboard removal.
Definition text_history.hpp:48
@ FORWARD_DELETE
Deletion immediately after the cursor.
Definition text_history.hpp:44
@ TYPING
Plain insertion without replacing a selection.
Definition text_history.hpp:40
@ REPLACEMENT
A separate selection replacement.
Definition text_history.hpp:50
@ WOULD_BLOCK
Active resume, invocation, registration or queue capacity rejects the operation.
Definition async.hpp:30
constexpr std::size_t DEFAULT_TEXT_HISTORY_OPERATIONS
Default maximum combined undo and redo groups.
Definition text_history.hpp:17
constexpr std::size_t DEFAULT_TEXT_HISTORY_MAX_BYTES
Default logical record and UTF-8 capacity budget, in bytes.
Definition text_history.hpp:19
@ PROGRAMMATIC
Explicit semantic action, the default for caller-created ActionEvent.
Definition action.hpp:25
@ NOT_BOUNDARY
A cursor offset is outside the text or inside a cluster.
Definition text.hpp:83
Configurable bounds and explicit-boundary grouping for text history.
Definition text_history.hpp:22
bool enabled
Record edits when true; disabled history accepts edits without retaining them.
Definition text_history.hpp:24
std::size_t maxBytes
Maximum retained entry objects and UTF-8 string capacities, in bytes; zero disables retention.
Definition text_history.hpp:28
bool groupDeletion
Combine adjacent deletions of the same direction until a boundary.
Definition text_history.hpp:32
std::size_t maxOperations
Maximum combined undo and redo groups; zero disables retention.
Definition text_history.hpp:26
bool trackContentStates
Retain opaque content-state tokens for model anchors; default history has no per-entry token storage.
Definition text_history.hpp:34
bool groupTyping
Combine adjacent typing edits until an explicit boundary.
Definition text_history.hpp:30
Owning UTF-8 bytes and byte offsets validated during preparation.
Definition text_history.hpp:56
std::size_t cursor
Active end of selection, at an extended grapheme boundary.
Definition text_history.hpp:61
std::size_t anchor
Fixed end of selection, at an extended grapheme boundary.
Definition text_history.hpp:63
std::string bytes
Original UTF-8 text; no normalization is performed.
Definition text_history.hpp:59
Owning limits checked without silently truncating input or clusters.
Definition text.hpp:57
Owning deterministic width policy; no font or terminal matching promise.
Definition text.hpp:42