Table of Contents

Class RichTextFolding

Namespace
RichEdit.Maui
Assembly
RichEdit.Maui.dll

Owns explicitly collapsed source ranges for one editor.

public sealed class RichTextFolding
Inheritance
RichTextFolding
Inherited Members

Remarks

Folding changes presentation only. It does not change source, selection, saved state, or undo history. Ranges track text edits; text inserted at either boundary stays outside the fold. Replacing or deleting an entire folded range removes it. Replacing the document clears all folds. Navigation never expands folds. Mutations require the editor's UI thread and cannot run during IME composition.

Properties

CollapsedRanges

Gets the independently collapsed ranges, ordered by start and then decreasing length.

public IReadOnlyList<TextSpan> CollapsedRanges { get; }

Property Value

IReadOnlyList<TextSpan>

Remarks

Overlapping and nested ranges retain their own state; their union is hidden.

Methods

Collapse(TextSpan)

Collapses a source range without changing selection or other folds.

public void Collapse(TextSpan range)

Parameters

range TextSpan

The nonempty UTF-16 source range.

Expand(TextSpan)

Removes the exact range from the collapsed set, preserving independently collapsed nested ranges.

public void Expand(TextSpan range)

Parameters

range TextSpan

A range from CollapsedRanges.

ExpandAll()

Expands all ranges.

public void ExpandAll()

GetCollapsedRange(int)

Gets the union of collapsed ranges containing an offset, or null if that character is visible.

public TextSpan? GetCollapsedRange(int offset)

Parameters

offset int

A UTF-16 source offset; the end of the document is allowed.

Returns

TextSpan?

The containing collapsed interval. Its end is exclusive.

SetCollapsedRanges(IEnumerable<TextSpan>)

Replaces all collapsed ranges. The application owns fold discovery and expansion policy.

public void SetCollapsedRanges(IEnumerable<TextSpan> ranges)

Parameters

ranges IEnumerable<TextSpan>

Nonempty UTF-16 source ranges. Duplicates are ignored.

Events

Changed

Occurs after explicit changes, edit remapping, or document replacement changes the fold state.

public event EventHandler? Changed

Event Type

EventHandler