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

UI-owned Unicode draft; mutate only through its scoped binding between frames. Cursor/anchor are UTF-8 byte boundaries, while scrolling and painting use terminal cells. Paint borrows owning text through the enclosing tree.frame and performs no service/model calls. PASSWORD caches one ASCII '*' per grapheme; NO_ECHO has fixed width one and a fixed-origin caret. Protected modes suppress outbound copy/cut but permit inbound paste when writable. Models, getters, commit receipts and bounded history can contain plaintext; no storage zeroization is promised. More...

#include <line_edit.hpp>

Inheritance diagram for portals::LineEdit:
portals::LineEditportals::LineEdit portals::SizedWidget portals::Widget portals::LayoutItem

Public Member Functions

 ~LineEdit () override
 Notify an optional weak validation gate after widget borrows drain; cancellation never joins.
 LineEdit (LineEdit &&other)=default
 Preserve owning movement before attachment; attached widgets remain stationary.
LineEdit & operator= (LineEdit &&other)=default
 LineEdit (LineEditOptions options={}, SizePolicy policy=DEFAULT_EDITOR_POLICY)
 Construct an empty editor; binding adopts its initial model snapshot.
 LineEdit (LineEditOptions options, SizePolicy policy, detail::LineEditPlaceholder placeholder)
 Internal prepared-presentation construction used by checked recipes.
std::expected< CellSize, TreeError > measure (CellSize available) override
 Measure displayed content plus one caret cell; NO_ECHO always measures one cell.
std::expected< void, TreeError > arrange (CellRect local) override
 Store local bounds and scroll by whole graphemes to expose the caret.
std::expected< void, TreeError > paint (PaintContext &context) override
 Submit bounded local commands; software caret and selection never split a grapheme.
const GraphemeText & text () const
 Borrow validated draft only inside tree.read.
std::size_t cursor () const
 Inspect the active selection endpoint.
std::size_t anchor () const
 Inspect the fixed selection endpoint.
bool dirty () const
 Inspect whether visible text awaits successful publication or cancellation.
ComputedStyle styleDefaults () const override
Public Member Functions inherited from portals::SizedWidget
 SizedWidget (SizePolicy policy={})
 Own the supplied policies; checked by layout.
SizePolicy sizePolicy () const override
 Copy current policy without borrowing storage.
Public Member Functions inherited from portals::Widget
virtual ~Widget ()=default
 Destroy on UI after the last active tree borrow.
virtual void mount ()
 Called exactly once after attachment; exceptions are reported.
virtual void unmount ()
 Called once before destruction, children first; cleanup continues on exceptions.
virtual bool styleReadOnly () const noexcept
 Read actual view-only state during style staging; false by default.
const std::shared_ptr< const StyleSnapshot > & computedStyle () const noexcept
 Inspect the last atomically installed theme inside tree.read/frame.
std::uint64_t styleRevision () const noexcept
Public Member Functions inherited from portals::LayoutItem
virtual ~LayoutItem ()=default
 Destroy with the implementing widget.

Friends

class LineEditBinding
struct detail::LineEditValidationAccess
struct detail::LineEditSourceAccess
class ManagedScene
struct ui::detail::RefAccess

Detailed Description

UI-owned Unicode draft; mutate only through its scoped binding between frames. Cursor/anchor are UTF-8 byte boundaries, while scrolling and painting use terminal cells. Paint borrows owning text through the enclosing tree.frame and performs no service/model calls. PASSWORD caches one ASCII '*' per grapheme; NO_ECHO has fixed width one and a fixed-origin caret. Protected modes suppress outbound copy/cut but permit inbound paste when writable. Models, getters, commit receipts and bounded history can contain plaintext; no storage zeroization is promised.

Constructor & Destructor Documentation

◆ LineEdit() [1/3]

portals::LineEdit::LineEdit ( LineEdit && other)
default

Preserve owning movement before attachment; attached widgets remain stationary.

Parameters
otherOwning editor data transferred into this unattached object.

◆ LineEdit() [2/3]

portals::LineEdit::LineEdit ( LineEditOptions options = {},
SizePolicy policy = DEFAULT_EDITOR_POLICY )
explicit

Construct an empty editor; binding adopts its initial model snapshot.

Parameters
optionsOwning immutable limits, width policy and styles.
policyOwning layout size policy validated by layout.
Exceptions
std::bad_allocIf initial text storage cannot be allocated.
std::bad_expected_access<TextError>If the width policy or placeholder text violates its bounds.
std::invalid_argumentIf the display mode is unknown or the placeholder contains a line separator. Declarative recipes prepare placeholder validation/storage in their checked mount boundary instead.

◆ LineEdit() [3/3]

portals::LineEdit::LineEdit ( LineEditOptions options,
SizePolicy policy,
detail::LineEditPlaceholder placeholder )

Internal prepared-presentation construction used by checked recipes.

Parameters
optionsImmutable editor settings, with display mode already checked.
policyOwning layout size policy.
placeholderOwning prevalidated placeholder; no placeholder parsing/allocation occurs here.
Exceptions
std::bad_allocIf initial draft storage cannot be allocated.

Member Function Documentation

◆ anchor()

std::size_t portals::LineEdit::anchor ( ) const

Inspect the fixed selection endpoint.

Returns
UTF-8 byte boundary; equals cursor() for an empty selection.

◆ arrange()

std::expected< void, TreeError > portals::LineEdit::arrange ( CellRect local)
overridevirtual

Store local bounds and scroll by whole graphemes to expose the caret.

Parameters
localParent-relative allocated rectangle; only its extent is retained.
Returns
Success or INVALID_GEOMETRY for unrepresentable bounds.

Reimplemented from portals::Widget.

◆ cursor()

std::size_t portals::LineEdit::cursor ( ) const

Inspect the active selection endpoint.

Returns
UTF-8 byte boundary in text(), including its end.

◆ dirty()

bool portals::LineEdit::dirty ( ) const

Inspect whether visible text awaits successful publication or cancellation.

Returns
True for a deferred, semantically rejected or conflicting candidate.

◆ measure()

std::expected< CellSize, TreeError > portals::LineEdit::measure ( CellSize available)
overridevirtual

Measure displayed content plus one caret cell; NO_ECHO always measures one cell.

Parameters
availableOffered extent; does not constrain intrinsic measurement.
Returns
Intrinsic cell width and height one, or INVALID_GEOMETRY on overflow.

Reimplemented from portals::Widget.

◆ operator=()

LineEdit & portals::LineEdit::operator= ( LineEdit && other)
default
Parameters
otherOwning editor data transferred before attachment.
Returns
This editor after the owning data transfer.

◆ paint()

std::expected< void, TreeError > portals::LineEdit::paint ( PaintContext & context)
overridevirtual

Submit bounded local commands; software caret and selection never split a grapheme.

Parameters
contextSynchronous sink; retained text borrows expire at enclosing tree.frame exit.
Returns
Success or the sink's error; sink exceptions propagate to WidgetTree::paint.

Reimplemented from portals::Widget.

◆ styleDefaults()

ComputedStyle portals::LineEdit::styleDefaults ( ) const
overridevirtual
Returns
Owning manual control, selection and caret appearances beneath theme declarations.

Reimplemented from portals::Widget.

◆ text()

const GraphemeText & portals::LineEdit::text ( ) const

Borrow validated draft only inside tree.read.

Returns
Reference invalidated by the next edit, synchronization or destruction.

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