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

Scoped model/action ownership; destroy and move on UI outside frames. Tree, router and scheduler outlive the binding. Call sync before each frame. Drafts survive external revisions; confirmation detects conflict and Escape adopts latest. EditMode selects immediate publication, confirmation on focus loss, or explicit confirmation only. Admitted callbacks retain state; removal suppresses future callbacks and observer delivery. More...

#include <line_edit.hpp>

Public Member Functions

 ~LineEditBinding ()
 Disconnect subscription/action; admitted calls retain their owners.
 LineEditBinding (LineEditBinding &&other) noexcept
 Transfer ownership on UI.
LineEditBinding & operator= (LineEditBinding &&other) noexcept
 Install replacement before retiring old captures, which may reenter UI.
 LineEditBinding (const LineEditBinding &)=delete
LineEditBinding & operator= (const LineEditBinding &)=delete
std::expected< void, TreeError > sync (Node< Widget > focused)
 Synchronize latest clean model and focus presentation between frames.
std::expected< void, TreeError > undo ()
std::expected< void, TreeError > redo ()
std::expected< void, TreeError > clear ()
 Clear a writable eligible editor as one separate user edit, applying its EditMode.
std::expected< void, TreeError > stopGrouping ()
std::expected< HistoryAvailability, TreeError > historyAvailability () const
bool canUndo () const
bool canRedo () const

Friends

struct detail::LineEditValidationAccess
struct detail::LineEditSourceAccess
struct ui::detail::RefAccess
struct ui::detail::Access
class ManagedScene
std::expected< LineEditBinding, TreeError > bindLineEditWithEvents (WidgetTree &tree, EventRouter &router, Node< LineEdit > node, std::shared_ptr< Property< std::string > > model, std::function< void(LineEditResult)> result, std::shared_ptr< Clipboard > clipboard, std::function< bool(std::string_view)> validate, LineEditEvents events)
 Bind a one-line editor and adopt its initial model on UI outside frames.

Detailed Description

Scoped model/action ownership; destroy and move on UI outside frames. Tree, router and scheduler outlive the binding. Call sync before each frame. Drafts survive external revisions; confirmation detects conflict and Escape adopts latest. EditMode selects immediate publication, confirmation on focus loss, or explicit confirmation only. Admitted callbacks retain state; removal suppresses future callbacks and observer delivery.

Constructor & Destructor Documentation

◆ LineEditBinding()

portals::LineEditBinding::LineEditBinding ( LineEditBinding && other)
noexcept

Transfer ownership on UI.

Parameters
otherBinding emptied by this transfer.

Member Function Documentation

◆ canRedo()

bool portals::LineEditBinding::canRedo ( ) const
Returns
Effective Redo availability; false on checked failure, with no error reporting.

◆ canUndo()

bool portals::LineEditBinding::canUndo ( ) const
Returns
Effective Undo availability; false on checked failure, with no error reporting.

◆ clear()

std::expected< void, TreeError > portals::LineEditBinding::clear ( )

Clear a writable eligible editor as one separate user edit, applying its EditMode.

Returns
Success for an empty draft or semantic rejection; technical failures retain their exact TreeError. Pre-accept failures preserve draft/history; post-accept publication failure keeps a dirty undoable draft. Read-only and disabled editors return WOULD_BLOCK, including when already empty.

◆ historyAvailability()

std::expected< HistoryAvailability, TreeError > portals::LineEditBinding::historyAvailability ( ) const
Returns
Effective availability, or typed liveness/frame/reentry error; never adopts or reports.

◆ operator=()

LineEditBinding & portals::LineEditBinding::operator= ( LineEditBinding && other)
noexcept

Install replacement before retiring old captures, which may reenter UI.

Parameters
otherBinding emptied by transfer; self-move preserves all state.
Returns
This binding; reentrant cleanup may have destroyed its containing owner.

◆ redo()

std::expected< void, TreeError > portals::LineEditBinding::redo ( )
Returns
Success after restoring Redo and applying EditMode, or typed admission/publication failure.

◆ stopGrouping()

std::expected< void, TreeError > portals::LineEditBinding::stopGrouping ( )
Returns
Success after closing grouping without redraw/notification, or typed liveness/reentry failure.

◆ sync()

std::expected< void, TreeError > portals::LineEditBinding::sync ( Node< Widget > focused)

Synchronize latest clean model and focus presentation between frames.

Parameters
focusedSnapshot from EventRouter::focused; empty means no focus.
Returns
Success, INVALID_ARGUMENT for an empty binding, WOULD_BLOCK on frame/reentry, NO_MEMORY, INVALID_ARGUMENT for invalid model text, or delegated tree/model error. Rejected/old notifications never override a dirty draft. Invalid models preserve presentation.

◆ undo()

std::expected< void, TreeError > portals::LineEditBinding::undo ( )
Returns
Success after restoring Undo and applying EditMode, or typed admission/publication failure. Empty history closes grouping without callbacks or invalidation. Semantic rejection remains a visible draft.

◆ bindLineEditWithEvents

std::expected< LineEditBinding, TreeError > bindLineEditWithEvents ( WidgetTree & tree,
EventRouter & router,
Node< LineEdit > node,
std::shared_ptr< Property< std::string > > model,
std::function< void(LineEditResult)> result,
std::shared_ptr< Clipboard > clipboard,
std::function< bool(std::string_view)> validate,
LineEditEvents events )
friend

Bind a one-line editor and adopt its initial model on UI outside frames.

Parameters
treeBorrowed UI owner, outliving binding and model.
routerBorrowed router for this tree, outliving binding.
nodeObserving editor handle; one action registration is allowed per node.
modelRequired shared model owner. External values must satisfy editor text limits.
resultRequired owning callback, invoked before typed events for editing/confirmation operations; may remove node/ancestors or destroy the binding. Successful commits stay committed if this callback throws.
clipboardOptional shared UI service for Ctrl+C/X/V; absence reports CLIPBOARD_FAILED.
validateOptional publication predicate borrowing an owned candidate only during its call. False preserves draft with VALIDATION_FAILED; exceptions report FAILED/CALLBACK_FAILED.
Returns
Owning binding or delegated tree/router/property error; invalid initial text is INVALID_ARGUMENT. Internal allocations report NO_MEMORY; by-value argument construction may throw before entry. Publication uses options.editMode and requires the original revision, including after validator reentry. IMMEDIATE is the default; semantic rejection retains the accepted candidate without a model set. Invoke Action::ACTIVATE for the same programmatic confirmation as Enter, in every mode. History owns bounded text/selection snapshots; accepted edits and restorations precede validator callbacks. Default Ctrl+Z/Ctrl+Y/Ctrl+Shift+Z chords are configurable; reserved router keys and Undo/Redo overlap reject bind. Read-only accepts explicit programmatic text changes but blocks user typing/deletion/cut/paste and Undo/Redo. User clear is also blocked by read-only/disabled eligibility; programmatic text mutation remains unchanged. PASSWORD/NO_ECHO consume Ctrl+C/X without service access or outcomes. Ctrl+V and paste remain writable inputs. Escape adopts latest. Shift+arrows/Home/End select; Ctrl+A selects all. Cut changes draft only after a successful service write, then applies the same publication policy as input and fluent edits. Paste rejects invalid UTF-8, CR/LF/U+2028/U+2029 and whole over-limit edits. Other controls remain logical data displayed as safe renderer placeholders.
Parameters
eventsTyped observations delivered after the legacy result; no borrowed widget text survives callbacks.

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