# TextHighlighterCollection

Version: 0.5.0
Framework commit: d503df2befa756e681fcdc6250e9552dc7388bea
Canonical URL: /docs/0.5.0/api/ferroui-controls/documents/struct-texthighlightercollection/

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

```rust
struct TextHighlighterCollection
```



[View source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/documents/text_highlighter_collection.rs#L17)

## Members

- [`new`](#function-new)
- [`from_items`](#function-from_items)
- [`downgrade`](#function-downgrade)
- [`add`](#function-add)
- [`insert`](#function-insert)
- [`set`](#function-set)
- [`remove`](#function-remove)
- [`remove_at`](#function-remove_at)
- [`snapshot`](#function-snapshot)
- [`invalidated`](#function-invalidated)
- [`merged_regions`](#function-merged_regions)
- [`merged_regions_with`](#function-merged_regions_with)

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

### new

```rust
fn new() -> Self
```



[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/documents/text_highlighter_collection.rs#L60)

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

### from_items

```rust
fn from_items(items: impl IntoIterator<Item = Ref<TextHighlighter>>) -> Self
```



[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/documents/text_highlighter_collection.rs#L78)

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

### downgrade

```rust
fn downgrade(self: &Self) -> WeakTextHighlighterCollection
```



[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/documents/text_highlighter_collection.rs#L84)

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

### add

```rust
fn add(self: &Self, highlighter: impl IntoRef<TextHighlighter>)
```



[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/documents/text_highlighter_collection.rs#L87)

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

### insert

```rust
fn insert(self: &Self, index: usize, highlighter: impl IntoRef<TextHighlighter>)
```



[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/documents/text_highlighter_collection.rs#L90)

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

### set

```rust
fn set(self: &Self, index: usize, highlighter: impl IntoRef<TextHighlighter>) -> bool
```



[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/documents/text_highlighter_collection.rs#L95)

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

### remove

```rust
fn remove(self: &Self, highlighter: impl IntoRef<TextHighlighter>) -> bool
```



[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/documents/text_highlighter_collection.rs#L102)

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

### remove_at

```rust
fn remove_at(self: &Self, index: usize) -> Option<Ref<TextHighlighter>>
```



[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/documents/text_highlighter_collection.rs#L105)

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

### snapshot

```rust
fn snapshot(self: &Self) -> Rc<Vec<Ref<TextHighlighter>>>
```



[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/documents/text_highlighter_collection.rs#L110)

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

### invalidated

```rust
fn invalidated(self: &Self, handler: impl Fn() -> () + 'static) -> Subscription
```

Dropping the returned guard removes the handler; `Subscription::detach` keeps it for the
life of the collection.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/documents/text_highlighter_collection.rs#L116)

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

### merged_regions

```rust
fn merged_regions(self: &Self, content_length: usize, default_foreground: Option<Rc<dyn IBrush>>, default_background: Option<Rc<dyn IBrush>>) -> Vec<TextHighlightRegion>
```

Produces ordered, disjoint regions, ignoring invalid/empty ranges and
clipping ranges to the view's content. Null brushes use the supplied
theme defaults rather than inheriting a lower layer's brush.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/documents/text_highlighter_collection.rs#L129)

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

### merged_regions_with

```rust
fn merged_regions_with(self: &Self, content_length: usize, default_foreground: Option<Rc<dyn IBrush>>, default_background: Option<Rc<dyn IBrush>>, normalize: impl FnMut(Range<usize>) -> Range<usize>) -> Vec<TextHighlightRegion>
```

Normalizes each source layer before merging. A document view can widen
boundaries that fall inside a UTF-16 surrogate pair to scalar boundaries,
retaining collection-order priority even when two half-pairs overlap.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/documents/text_highlighter_collection.rs#L146)

## Trait implementations

- `Send`
- `Sync`
- `Freeze`
- `UnsafeUnpin`
- `Unpin`
- `UnwindSafe`
- `RefUnwindSafe`
- `Borrow<T>`
- `BorrowMut<T>`
- `CloneToUninit`
- `Into<U>`
- `From<T>`
- `TryInto<U>`
- `TryFrom<U>`
- [`Receiver`](/docs/0.5.0/api/ferroui-system/task/oneshot/struct-receiver/)
- `Any`
- `ToOwned`
- [`PropertyValue`](/docs/0.5.0/api/ferroui-base/trait-propertyvalue/)
- [`AnyValue`](/docs/0.5.0/api/ferroui-base/trait-anyvalue/)
- [`ClassDefaults`](/docs/0.5.0/api/ferroui-base/trait-classdefaults/)
- `ErasedDestructor`
- `IntoEither`
- `Clone`
- `PartialEq`
- `Debug`
- `Default`
- `Deref`
- [`MarkupTyped`](/docs/0.5.0/api/ferroui-base/metadata/trait-markuptyped/)
- [`ValueTypeRegistration`](/docs/0.5.0/api/ferroui-base/data/core/trait-valuetyperegistration/)

## Availability

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