RichTextDocument
struct · ferroui-controls · v0.5.0
struct RichTextDocument
Authoritative structured content shared by read-only and editable text controls. Its plain string is a derived read cache; every mutation changes the block tree.
Members
newwith_blocksfrom_textblocksrevisiondowngradeparagraphstexttext_lengthchangedbegin_editsnapshotrestorevalidate_rangeget_textslicereplace_textreplace_rangeapply_formatapply_paragraph_formatcharacter_format_atelement_atcreate_pointeris_grapheme_boundaryprevious_graphemenext_graphemeprevious_wordnext_word
new
fn new() -> Self
with_blocks
fn with_blocks(blocks: BlockCollection) -> Self
from_text
fn from_text(text: &str) -> Self
blocks
fn blocks(self: &Self) -> BlockCollection
revision
fn revision(self: &Self) -> u64
downgrade
fn downgrade(self: &Self) -> WeakRichTextDocument
paragraphs
fn paragraphs(self: &Self) -> Vec<Ref<Paragraph>>
text
fn text(self: &Self) -> String
text_length
fn text_length(self: &Self) -> usize
changed
fn changed(self: &Self, handler: impl Fn(&DocumentChangedEventArgs) -> () + 'static) -> Subscription
Dropping the returned guard removes the handler; Subscription::detach keeps it for the
life of the document.
begin_edit
fn begin_edit(self: &Self) -> DocumentEditBatch
Nested batches publish one revision and one Changed event at the outer end.
snapshot
fn snapshot(self: &Self) -> DocumentSnapshot
restore
fn restore(self: &Self, snapshot: &DocumentSnapshot) -> Result<(), DocumentError>
validate_range
fn validate_range(self: &Self, range: Range<usize>) -> Result<(), DocumentError>
get_text
fn get_text(self: &Self, range: Range<usize>) -> Result<String, DocumentError>
slice
fn slice(self: &Self, range: Range<usize>) -> Result<DocumentSnapshot, DocumentError>
replace_text
fn replace_text(self: &Self, range: Range<usize>, text: &str) -> Result<(), DocumentError>
replace_range
fn replace_range(self: &Self, range: Range<usize>, fragment: &DocumentSnapshot) -> Result<(), DocumentError>
apply_format
fn apply_format(self: &Self, range: Range<usize>, format: &CharacterFormat) -> Result<(), DocumentError>
apply_paragraph_format
fn apply_paragraph_format(self: &Self, range: Range<usize>, format: &ParagraphFormat) -> Result<(), DocumentError>
character_format_at
fn character_format_at(self: &Self, offset: usize) -> Result<CharacterFormat, DocumentError>
element_at
fn element_at(self: &Self, offset: usize, gravity: TextGravity) -> Option<Ref<TextElement>>
create_pointer
fn create_pointer(self: &Self, offset: usize, gravity: TextGravity) -> Result<TextPointer, DocumentError>
is_grapheme_boundary
fn is_grapheme_boundary(self: &Self, offset: usize) -> bool
previous_grapheme
fn previous_grapheme(self: &Self, offset: usize) -> usize
next_grapheme
fn next_grapheme(self: &Self, offset: usize) -> usize
previous_word
fn previous_word(self: &Self, offset: usize) -> usize
next_word
fn next_word(self: &Self, offset: usize) -> usize
Trait implementations
SendSyncFreezeUnsafeUnpinUnpinUnwindSafeRefUnwindSafeBorrow<T>BorrowMut<T>CloneToUninitInto<U>From<T>TryInto<U>TryFrom<U>AnyToOwnedPropertyValueAnyValueClassDefaultsErasedDestructorIntoEitherClonePartialEqDebugDefaultMarkupTypedValueTypeRegistration
Availability
Extracted for aarch64-apple-darwin. Cargo features are listed in the crate index.