FerroUI/ docs

Search guides, controls, Rust APIs, and XAML.

    GitHub ↗

    RichEditTextSelection

    struct · ferroui-controls · v0.5.0

    struct RichEditTextSelection
    

    Live directed editor selection. Extending preserves the anchor; moving without extension collapses to the requested text-unit boundary.

    View source

    Members

    delete_by

    fn delete_by(self: &Self, unit: TextRangeUnit, count: i32) -> Result<usize, EditError>
    

    TOM unit deletion over the shared directed selection. The existing parameterless delete remains the direct selection-deletion convenience.

    Source

    home_key

    fn home_key(self: &Self, unit: TextRangeUnit, extend: bool) -> Result<isize, EditError>
    

    Moves to the logical start of a Line or the Story. Extension follows the active end and retains the anchor. A collapsed Line request first chooses the normalized selection start. Other units are rejected before effects.

    The result is the accepted signed UTF-16 displacement of the active end, including application changes made through cancellable selection events. Line uses complete untrimmed shaping when a view is associated, and the shared paragraph fallback otherwise. No editing/history unit is created.

    Source

    end_key

    fn end_key(self: &Self, unit: TextRangeUnit, extend: bool) -> Result<isize, EditError>
    

    Moves to the logical end of a Line or the Story. A collapsed Line request chooses the normalized selection end and excludes its terminator. An extended Line request follows the active end, includes real hard paragraph marks, and retains that line-end affinity on repetition. Soft-break and wrap affinity retain FerroUI's existing caret policy. Story ends at the model's final caret; no synthetic terminal CR is exposed. See home_key for extension, layout and result policy.

    Source

    move_left

    fn move_left(self: &Self, unit: TextRangeUnit, count: i32, extend: bool) -> Result<i32, EditError>
    

    Moves the selection left by Character or Word units. Character follows Unicode text elements (including combining sequences and emoji), while Word uses the document's logical word boundaries. Negative counts reverse direction. Extension keeps the anchor and moves only the active endpoint.

    As in the recorded system MSFTEDIT cases, these are logical source movements even in bidirectional paragraphs. They do not substitute for visual caret movement. The model does not expose a synthetic terminal EOP.

    Source

    move_right

    fn move_right(self: &Self, unit: TextRangeUnit, count: i32, extend: bool) -> Result<i32, EditError>
    

    Moves the selection right; see move_left. Collapsing a nonempty Character selection consumes one unit at its directional edge. Word collapse aligns that edge to its surrounding word boundary. Counts describe accepted units, including cancellation or callback redirection.

    Source

    move_up

    fn move_up(self: &Self, unit: TextRangeUnit, count: i32, extend: bool) -> Result<i32, EditError>
    

    Moves upward by actual display lines or logical paragraphs. A negative count moves downward. Extension retains the directed anchor. Collapsing starts at the directional selection edge, then moves the requested units; a collapse with no further movement still reports one unit.

    Line movement requires a complete, untrimmed shaped view. A collapsed caret retains its desired horizontal coordinate across short lines; an extension follows the reached caret through each intermediate line while preserving the desired column for later collapsed movement. Paragraph works without a view. Screen and Window units are not represented by TextRangeUnit.

    Source

    move_down

    fn move_down(self: &Self, unit: TextRangeUnit, count: i32, extend: bool) -> Result<i32, EditError>
    

    Moves downward by display lines or logical paragraphs. Negative counts reverse the direction. The return value counts accepted units relative to this command's direction, rather than UTF-16 positions.

    Source

    options

    fn options(self: &Self) -> SelectionOptions
    

    Reads the shared editor modes and the accepted selection direction.

    Source

    set_options

    fn set_options(self: &Self, options: SelectionOptions) -> Result<(), EditError>
    

    Changes direction and modes through the control's selection projection. A cancelled or redirected direction request does not install stale modes; a newer nested request keeps ownership. Unknown flag bits are rejected.

    Source

    selection_type

    fn selection_type(self: &Self) -> SelectionType
    

    Source

    gravity

    fn gravity(self: &Self) -> RangeGravity
    

    Reads the accepted mode shared by this editor's live selection handles. A fresh editor starts with UIBehavior. Selecting another range, moving, typing and obtaining an independent range retain the live mode.

    Source

    set_gravity

    fn set_gravity(self: &Self, gravity: RangeGravity)
    

    Changes character-format affinity at a collapsed insertion boundary. Outward reads back as UIBehavior. The explicit typing patch still wins; a resolved neighboring format is never stored as a new typing patch.

    Changing affinity does not move endpoints, modify text, end composition or add history. Undo/redo keep the current mode; a failed grouped edit restores its starting mode. The latter are FerroUI transaction policies. Native synthetic terminal EOP styling is not part of the visible model.

    Source

    set_gravity_value

    fn set_gravity_value(self: &Self, value: i32) -> Result<(), EditError>
    

    Validates a native/serialized numeric value before changing any state.

    Source

    selection

    fn selection(self: &Self) -> EditorSelection
    

    Source

    set_range

    fn set_range(self: &Self, anchor: usize, active: usize) -> Result<(), EditError>
    

    Source

    range

    fn range(self: &Self) -> Result<RichEditTextRange, EditError>
    

    Source

    text

    fn text(self: &Self) -> Result<String, EditError>
    

    Source

    select_all

    fn select_all(self: &Self) -> Result<(), EditError>
    

    Source

    type_text

    fn type_text(self: &Self, text: &str) -> Result<bool, EditError>
    

    Enters typed scalars using the shared selection modes. CR and LF each type a paragraph break; an empty call leaves selection and preview intact.

    Source

    delete

    fn delete(self: &Self) -> Result<bool, EditError>
    

    Source

    character_format

    fn character_format(self: &Self) -> Result<CharacterFormat, EditError>
    

    Source

    character_format_value

    fn character_format_value(self: &Self) -> Result<TextFormatValue<CharacterFormat>, EditError>
    

    Unlike the insertion-format convenience getter, this query reports mixed formatting across a nonempty selection instead of choosing its first run.

    Source

    paragraph_format

    fn paragraph_format(self: &Self) -> Result<TextFormatValue<ParagraphFormat>, EditError>
    

    Source

    set_character_format

    fn set_character_format(self: &Self, format: &CharacterFormat) -> Result<(), EditError>
    

    Source

    set_paragraph_format

    fn set_paragraph_format(self: &Self, format: &ParagraphFormat) -> Result<(), EditError>
    

    Source

    move_by

    fn move_by(self: &Self, unit: TextRangeUnit, count: i32, extend: bool) -> Result<i32, EditError>
    

    Source

    Trait implementations

    • Send
    • Sync
    • Freeze
    • UnsafeUnpin
    • Unpin
    • UnwindSafe
    • RefUnwindSafe
    • Borrow<T>
    • BorrowMut<T>
    • CloneToUninit
    • Into<U>
    • From<T>
    • TryInto<U>
    • TryFrom<U>
    • Any
    • ToOwned
    • ClassDefaults
    • ErasedDestructor
    • IntoEither
    • Clone

    Availability

    Extracted for aarch64-apple-darwin. Cargo features are listed in the crate index.