# RichEditTextSelection

Version: 0.5.0
Framework commit: d503df2befa756e681fcdc6250e9552dc7388bea
Canonical URL: /docs/0.5.0/api/ferroui-controls/rich_text/struct-richedittextselection/

**struct** · [`ferroui-controls`](/docs/0.5.0/api/ferroui-controls/) · v0.5.0

```rust
struct RichEditTextSelection
```

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

[View source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/rich_text/rich_edit_text_document.rs#L1306)

## Members

- [`delete_by`](#function-delete_by)
- [`home_key`](#function-home_key)
- [`end_key`](#function-end_key)
- [`move_left`](#function-move_left)
- [`move_right`](#function-move_right)
- [`move_up`](#function-move_up)
- [`move_down`](#function-move_down)
- [`options`](#function-options)
- [`set_options`](#function-set_options)
- [`selection_type`](#function-selection_type)
- [`gravity`](#function-gravity)
- [`set_gravity`](#function-set_gravity)
- [`set_gravity_value`](#function-set_gravity_value)
- [`selection`](#function-selection)
- [`set_range`](#function-set_range)
- [`range`](#function-range)
- [`text`](#function-text)
- [`select_all`](#function-select_all)
- [`type_text`](#function-type_text)
- [`delete`](#function-delete)
- [`character_format`](#function-character_format)
- [`character_format_value`](#function-character_format_value)
- [`paragraph_format`](#function-paragraph_format)
- [`set_character_format`](#function-set_character_format)
- [`set_paragraph_format`](#function-set_paragraph_format)
- [`move_by`](#function-move_by)

<a id="function-delete_by"></a>

### delete_by

```rust
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](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/rich_text/rich_edit_text_range_operations.rs#L227)

<a id="function-home_key"></a>

### home_key

```rust
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](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/rich_text/rich_edit_text_selection_navigation.rs#L17)

<a id="function-end_key"></a>

### end_key

```rust
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](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/rich_text/rich_edit_text_selection_navigation.rs#L28)

<a id="function-move_left"></a>

### move_left

```rust
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](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/rich_text/rich_edit_text_selection_movement.rs#L26)

<a id="function-move_right"></a>

### move_right

```rust
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](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/rich_text/rich_edit_text_selection_movement.rs#L39)

<a id="function-move_up"></a>

### move_up

```rust
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](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/rich_text/rich_edit_text_selection_movement.rs#L120)

<a id="function-move_down"></a>

### move_down

```rust
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](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/rich_text/rich_edit_text_selection_movement.rs#L127)

<a id="function-options"></a>

### options

```rust
fn options(self: &Self) -> SelectionOptions
```

Reads the shared editor modes and the accepted selection direction.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/rich_text/rich_edit_text_selection_options.rs#L52)

<a id="function-set_options"></a>

### set_options

```rust
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](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/rich_text/rich_edit_text_selection_options.rs#L59)

<a id="function-selection_type"></a>

### selection_type

```rust
fn selection_type(self: &Self) -> SelectionType
```



[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/rich_text/rich_edit_text_selection_options.rs#L63)

<a id="function-gravity"></a>

### gravity

```rust
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](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/rich_text/rich_edit_text_selection_gravity.rs#L9)

<a id="function-set_gravity"></a>

### set_gravity

```rust
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](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/rich_text/rich_edit_text_selection_gravity.rs#L21)

<a id="function-set_gravity_value"></a>

### set_gravity_value

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

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

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/rich_text/rich_edit_text_selection_gravity.rs#L26)

<a id="function-selection"></a>

### selection

```rust
fn selection(self: &Self) -> EditorSelection
```



[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/rich_text/rich_edit_text_document.rs#L1310)

<a id="function-set_range"></a>

### set_range

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



[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/rich_text/rich_edit_text_document.rs#L1313)

<a id="function-range"></a>

### range

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



[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/rich_text/rich_edit_text_document.rs#L1328)

<a id="function-text"></a>

### text

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



[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/rich_text/rich_edit_text_document.rs#L1331)

<a id="function-select_all"></a>

### select_all

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



[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/rich_text/rich_edit_text_document.rs#L1334)

<a id="function-type_text"></a>

### type_text

```rust
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](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/rich_text/rich_edit_text_document.rs#L1339)

<a id="function-delete"></a>

### delete

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



[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/rich_text/rich_edit_text_document.rs#L1342)

<a id="function-character_format"></a>

### character_format

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



[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/rich_text/rich_edit_text_document.rs#L1345)

<a id="function-character_format_value"></a>

### character_format_value

```rust
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](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/rich_text/rich_edit_text_document.rs#L1350)

<a id="function-paragraph_format"></a>

### paragraph_format

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



[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/rich_text/rich_edit_text_document.rs#L1360)

<a id="function-set_character_format"></a>

### set_character_format

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



[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/rich_text/rich_edit_text_document.rs#L1363)

<a id="function-set_paragraph_format"></a>

### set_paragraph_format

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



[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/rich_text/rich_edit_text_document.rs#L1366)

<a id="function-move_by"></a>

### move_by

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



[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/rich_text/rich_edit_text_document.rs#L1369)

## 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`](/docs/0.5.0/api/ferroui-base/trait-classdefaults/)
- `ErasedDestructor`
- `IntoEither`
- `Clone`

## Availability

Extracted for `aarch64-apple-darwin`. Cargo features are listed in the [crate index](/docs/0.5.0/api/).
