RichTextBlock
struct · ferroui-controls · v0.5.0
struct RichTextBlock
Displays paragraphs, nested spans, hyperlinks and embedded controls. All text indices are UTF-16 code units, matching the shaping and input-method contracts.
Members
context_menu_opening_eventcontext_menu_openingTYPEto_refrender_textcaret_visibleallow_hyperlink_navigationon_selection_changingrequest_selection_changerebase_selection_on_document_changetext_insetstext_layout_constraintdefault_incremental_tabtext_originselection_is_visibleselection_render_brushraise_selection_changed_eventtext_focus_targettext_background_boundsadditional_visual_childrenrich_document_propertyselection_start_propertyselection_end_propertyselected_text_propertyis_text_selection_enabled_propertyselection_highlight_color_propertyselection_foreground_brush_propertycaret_brush_propertybackground_propertypadding_propertyfont_family_propertyfont_size_propertyfont_style_propertyfont_weight_propertyfont_stretch_propertyfont_features_propertylanguage_propertyforeground_propertyletter_spacing_propertytext_alignment_propertyline_height_propertytext_indent_propertyline_stacking_strategy_propertytext_line_bounds_propertytext_decorations_propertytext_trimming_propertytext_wrapping_propertymax_lines_propertyoverflow_content_target_propertyhas_overflow_content_propertybaseline_offset_propertyis_text_trimmed_propertyselection_changed_eventis_text_trimmed_changed_eventconstructnewrich_documentset_rich_documenttry_set_rich_documentdocumentset_documenttry_set_documentblockstext_highlightersadd_childtextselection_startselection_endcaret_indexset_selection_startset_selection_endselectselection_changedselected_textselect_allclear_selectioncan_copyhyperlink_atcopyexport_rtfhit_test_text_positionget_rect_from_character_indexget_rect_from_text_positiontext_view_for_positioncursor_rectangleselection_rectsget_rects_for_rangeline_metricsvisible_text_rangesis_text_trimmedbaseline_offsethas_overflow_contentcontent_startcontent_endis_text_selection_enabledset_is_text_selection_enabledselection_highlight_colorset_selection_highlight_colorselection_foreground_brushset_selection_foreground_brushcaret_brushset_caret_brushbackgroundset_backgroundpaddingset_paddingfont_familyset_font_familyfont_sizeset_font_sizefont_styleset_font_stylefont_weightset_font_weightfont_stretchset_font_stretchfont_featureslanguageset_languageset_font_featuresforegroundset_foregroundletter_spacingset_letter_spacingtext_alignmentset_text_alignmenthorizontal_text_alignmentset_horizontal_text_alignmenttext_indentset_text_indentline_stacking_strategyset_line_stacking_strategytext_line_boundsset_text_line_boundstext_decorationsset_text_decorationstext_trimmingset_text_trimmingline_heightset_line_heighttext_wrappingset_text_wrappingmax_linesset_max_linesoverflow_content_targettry_set_overflow_content_targetset_overflow_content_target
context_menu_opening_event
fn context_menu_opening_event() -> &'static RoutedEvent<ContextMenuEventArgs>
Raised synchronously before this view opens a configured context
menu or flyout. Handled cancels the associated request.
Native overflow views do not raise this event for the modern context-flyout path. Their configured flyout still opens at the requesting overflow, including one inherited from the master.
context_menu_opening
fn context_menu_opening(self: &Self, handler: impl Fn(&Interactive, &ContextMenuEventArgs) -> () + 'static) -> RoutedEventHandlerToken
TYPE
const TYPE: &'static $crate::TypeInfo
The runtime type of this class.
to_ref
fn to_ref(self: &Self) -> $crate::Ref<RichTextBlock>
Returns a strong reference to this object.
render_text
fn render_text(self: &Self, context: &mut DrawingContext<'_>)
Paints text content after the background and selection highlights.
caret_visible
fn caret_visible(self: &Self) -> bool
Whether the insertion caret is visible (editable views override this).
allow_hyperlink_navigation
fn allow_hyperlink_navigation(self: &Self, modifiers: KeyModifiers) -> bool
Whether pointer input activates a hyperlink or edits its text.
on_selection_changing
fn on_selection_changing(self: &Self, args: &RichTextSelectionChangedEventArgs) -> bool
Runs synchronously while the proposed selection is visible to readers. Returning false cancels it unless a handler selected a different range.
request_selection_change
fn request_selection_change(self: &Self, start: usize, end: usize) -> bool
Lets an editable view arbitrate a normalized selection through its editor.
rebase_selection_on_document_change
fn rebase_selection_on_document_change(self: &Self) -> bool
Editors publish their final transaction selection after document changes.
text_insets
fn text_insets(self: &Self) -> Thickness
Space outside the document's formatted text, including editor adornments.
text_layout_constraint
fn text_layout_constraint(self: &Self, available_size: Size) -> Size
The formatter constraint, independent of a scrollable view's viewport.
default_incremental_tab
fn default_incremental_tab(self: &Self, font_size: f64) -> f64
Implicit tab interval for a paragraph without an assigned override.
text_origin
fn text_origin(self: &Self) -> Point
Shared origin for text, inline controls, caret, selection and hit testing.
selection_is_visible
fn selection_is_visible(self: &Self) -> bool
Whether the selection is currently drawn in this view (its highlight, and the selection foreground of the selected text).
selection_render_brush
fn selection_render_brush(self: &Self) -> Option<Rc<dyn IBrush>>
The selection background after the host's focus policy is applied.
raise_selection_changed_event
fn raise_selection_changed_event(self: &Self)
Publishes the selection event on the owning control.
text_focus_target
fn text_focus_target(self: &Self) -> Ref<InputElement>
The keyboard focus target for pointer interaction with text.
text_background_bounds
fn text_background_bounds(self: &Self) -> Rect
Bounds painted by the document background; editor headers are outside it.
additional_visual_children
fn additional_visual_children(self: &Self) -> Vec<Ref<Visual>>
Native framework visuals displayed beside the document's inline controls.
rich_document_property
fn rich_document_property() -> &'static DirectProperty<RichTextBlock, RichTextDocument>
The shared document the view shows: a FerroUI addition (WinUI's RichTextBlock
has only Blocks), named RichDocument so that it never reads as the text
object model RichEditBox.Document is (docs/porting/winui-rich-text.md, D3).
selection_start_property
fn selection_start_property() -> &'static DirectProperty<RichTextBlock, i32>
selection_end_property
fn selection_end_property() -> &'static DirectProperty<RichTextBlock, i32>
selected_text_property
fn selected_text_property() -> &'static DirectProperty<RichTextBlock, String>
is_text_selection_enabled_property
fn is_text_selection_enabled_property() -> &'static StyledProperty<bool>
selection_highlight_color_property
fn selection_highlight_color_property() -> &'static StyledProperty<Option<Rc<dyn IBrush>>>
selection_foreground_brush_property
fn selection_foreground_brush_property() -> &'static StyledProperty<Option<Rc<dyn IBrush>>>
caret_brush_property
fn caret_brush_property() -> &'static StyledProperty<Option<Rc<dyn IBrush>>>
background_property
fn background_property() -> &'static StyledProperty<Option<Rc<dyn IBrush>>>
padding_property
fn padding_property() -> &'static StyledProperty<Thickness>
font_family_property
fn font_family_property() -> &'static StyledProperty<FontFamily>
font_size_property
fn font_size_property() -> &'static StyledProperty<f64>
font_style_property
fn font_style_property() -> &'static StyledProperty<FontStyle>
font_weight_property
fn font_weight_property() -> &'static StyledProperty<FontWeight>
font_stretch_property
fn font_stretch_property() -> &'static StyledProperty<FontStretch>
font_features_property
fn font_features_property() -> &'static StyledProperty<Option<FontFeatureCollection>>
language_property
fn language_property() -> &'static StyledProperty<ferroui_base::utilities::Locale>
foreground_property
fn foreground_property() -> &'static StyledProperty<Option<Rc<dyn IBrush>>>
letter_spacing_property
fn letter_spacing_property() -> &'static StyledProperty<f64>
text_alignment_property
fn text_alignment_property() -> &'static StyledProperty<TextAlignment>
line_height_property
fn line_height_property() -> &'static StyledProperty<f64>
text_indent_property
fn text_indent_property() -> &'static StyledProperty<f64>
line_stacking_strategy_property
fn line_stacking_strategy_property() -> &'static StyledProperty<LineStackingStrategy>
text_line_bounds_property
fn text_line_bounds_property() -> &'static StyledProperty<TextLineBounds>
text_decorations_property
fn text_decorations_property() -> &'static StyledProperty<Option<TextDecorationCollection>>
text_trimming_property
fn text_trimming_property() -> &'static StyledProperty<Rc<dyn TextTrimming>>
text_wrapping_property
fn text_wrapping_property() -> &'static StyledProperty<TextWrapping>
max_lines_property
fn max_lines_property() -> &'static StyledProperty<i32>
overflow_content_target_property
fn overflow_content_target_property() -> &'static StyledProperty<Option<ElementRef<RichTextBlockOverflow>>>
has_overflow_content_property
fn has_overflow_content_property() -> &'static DirectProperty<RichTextBlock, bool>
baseline_offset_property
fn baseline_offset_property() -> &'static DirectProperty<RichTextBlock, f64>
is_text_trimmed_property
fn is_text_trimmed_property() -> &'static DirectProperty<RichTextBlock, bool>
selection_changed_event
fn selection_changed_event() -> &'static RoutedEvent<RoutedEventArgs>
is_text_trimmed_changed_event
fn is_text_trimmed_changed_event() -> &'static RoutedEvent<RoutedEventArgs>
construct
fn construct() -> Self
new
fn new() -> Ref<Self>
rich_document
fn rich_document(self: &Self) -> RichTextDocument
The shared document of the view (the property RichDocument, D3).
set_rich_document
fn set_rich_document(self: &Self, value: RichTextDocument)
Sets the shared document of the view (the property RichDocument, D3).
try_set_rich_document
fn try_set_rich_document(self: &Self, value: RichTextDocument) -> bool
Attaches a shared document whose blocks no other view owns; see try_set_document.
document
fn document(self: &Self) -> RichTextDocument
set_document
fn set_document(self: &Self, value: RichTextDocument)
try_set_document
fn try_set_document(self: &Self, value: RichTextDocument) -> bool
Attaches a document whose block elements are not owned by another view. Use an overflow target to share a view's document, or restore a snapshot into another document to make an independent view.
blocks
fn blocks(self: &Self) -> BlockCollection
text_highlighters
fn text_highlighters(self: &Self) -> TextHighlighterCollection
add_child
fn add_child(self: &Self, block: impl IntoRef<Block>)
text
fn text(self: &Self) -> String
selection_start
fn selection_start(self: &Self) -> usize
selection_end
fn selection_end(self: &Self) -> usize
caret_index
fn caret_index(self: &Self) -> usize
set_selection_start
fn set_selection_start(self: &Self, value: usize)
set_selection_end
fn set_selection_end(self: &Self, value: usize)
select
fn select(self: &Self, start: usize, end: usize)
selection_changed
fn selection_changed(self: &Self, handler: impl Fn(&RichTextSelectionChangedEventArgs) -> () + 'static) -> Subscription
Adds a handler of the changes of the selection.
Dropping the returned guard removes the handler;
Subscription::detach keeps it for the life of the block.
selected_text
fn selected_text(self: &Self) -> String
select_all
fn select_all(self: &Self)
clear_selection
fn clear_selection(self: &Self)
can_copy
fn can_copy(self: &Self) -> bool
hyperlink_at
fn hyperlink_at(self: &Self, point: Point) -> Option<Ref<Hyperlink>>
Finds a hyperlink inside rendered content, excluding blank padding.
copy
fn copy(self: &Self)
export_rtf
fn export_rtf(self: &Self) -> Result<String, crate::rich_text::RtfError>
Exports using the same resolved tab intervals as this view and its overflow chain. RTF has one document-wide default interval, so paragraphs resolving to different intervals return an unsupported-feature error.
hit_test_text_position
fn hit_test_text_position(self: &Self, point: Point) -> usize
get_rect_from_character_index
fn get_rect_from_character_index(self: &Self, index: usize) -> Rect
get_rect_from_text_position
fn get_rect_from_text_position(self: &Self, position: TextPosition) -> Rect
Gets a caret rectangle at the leading or trailing character edge of the same UTF-16 insertion position. Affinity matters at a bidi run boundary.
text_view_for_position
fn text_view_for_position(self: &Self, index: usize) -> Option<Ref<RichTextBlock>>
Finds the view containing a document insertion position. A terminal insertion point belongs to the final column; an off-page position has no view until enough overflow columns are linked and laid out.
cursor_rectangle
fn cursor_rectangle(self: &Self) -> Rect
selection_rects
fn selection_rects(self: &Self) -> Vec<Rect>
get_rects_for_range
fn get_rects_for_range(self: &Self, range: Range<usize>) -> Vec<Rect>
Gets the visible bounds of a UTF-16 range without changing selection. Invalid or empty ranges have no rectangles. Overflow views return only the rectangles within their own formatted page.
line_metrics
fn line_metrics(self: &Self) -> Vec<RichTextLineMetrics>
visible_text_ranges
fn visible_text_ranges(self: &Self) -> Vec<Range<usize>>
Source ranges retained in this formatted page, excluding collapsed text represented by an ellipsis. Ancestor viewports may clip these further.
is_text_trimmed
fn is_text_trimmed(self: &Self) -> bool
baseline_offset
fn baseline_offset(self: &Self) -> f64
has_overflow_content
fn has_overflow_content(self: &Self) -> bool
content_start
fn content_start(self: &Self) -> usize
content_end
fn content_end(self: &Self) -> usize
is_text_selection_enabled
fn is_text_selection_enabled(self: &Self) -> bool
set_is_text_selection_enabled
fn set_is_text_selection_enabled(self: &Self, value: bool)
selection_highlight_color
fn selection_highlight_color(self: &Self) -> Option<Rc<dyn IBrush>>
set_selection_highlight_color
fn set_selection_highlight_color(self: &Self, value: Option<Rc<dyn IBrush>>)
selection_foreground_brush
fn selection_foreground_brush(self: &Self) -> Option<Rc<dyn IBrush>>
set_selection_foreground_brush
fn set_selection_foreground_brush(self: &Self, value: Option<Rc<dyn IBrush>>)
caret_brush
fn caret_brush(self: &Self) -> Option<Rc<dyn IBrush>>
set_caret_brush
fn set_caret_brush(self: &Self, value: Option<Rc<dyn IBrush>>)
background
fn background(self: &Self) -> Option<Rc<dyn IBrush>>
set_background
fn set_background(self: &Self, value: Option<Rc<dyn IBrush>>)
padding
fn padding(self: &Self) -> Thickness
set_padding
fn set_padding(self: &Self, value: Thickness)
font_family
fn font_family(self: &Self) -> FontFamily
set_font_family
fn set_font_family(self: &Self, value: FontFamily)
font_size
fn font_size(self: &Self) -> f64
set_font_size
fn set_font_size(self: &Self, value: f64)
font_style
fn font_style(self: &Self) -> FontStyle
set_font_style
fn set_font_style(self: &Self, value: FontStyle)
font_weight
fn font_weight(self: &Self) -> FontWeight
set_font_weight
fn set_font_weight(self: &Self, value: FontWeight)
font_stretch
fn font_stretch(self: &Self) -> FontStretch
set_font_stretch
fn set_font_stretch(self: &Self, value: FontStretch)
font_features
fn font_features(self: &Self) -> Option<FontFeatureCollection>
language
fn language(self: &Self) -> ferroui_base::utilities::Locale
set_language
fn set_language(self: &Self, value: ferroui_base::utilities::Locale)
set_font_features
fn set_font_features(self: &Self, value: Option<FontFeatureCollection>)
foreground
fn foreground(self: &Self) -> Option<Rc<dyn IBrush>>
set_foreground
fn set_foreground(self: &Self, value: Option<Rc<dyn IBrush>>)
letter_spacing
fn letter_spacing(self: &Self) -> f64
set_letter_spacing
fn set_letter_spacing(self: &Self, value: f64)
text_alignment
fn text_alignment(self: &Self) -> TextAlignment
set_text_alignment
fn set_text_alignment(self: &Self, value: TextAlignment)
horizontal_text_alignment
fn horizontal_text_alignment(self: &Self) -> TextAlignment
set_horizontal_text_alignment
fn set_horizontal_text_alignment(self: &Self, value: TextAlignment)
text_indent
fn text_indent(self: &Self) -> f64
set_text_indent
fn set_text_indent(self: &Self, value: f64)
line_stacking_strategy
fn line_stacking_strategy(self: &Self) -> LineStackingStrategy
set_line_stacking_strategy
fn set_line_stacking_strategy(self: &Self, value: LineStackingStrategy)
text_line_bounds
fn text_line_bounds(self: &Self) -> TextLineBounds
The shared formatter's bounds policy for every line in this document. The value is inherited from the framework's TextBlock attached property.
set_text_line_bounds
fn set_text_line_bounds(self: &Self, value: TextLineBounds)
text_decorations
fn text_decorations(self: &Self) -> Option<TextDecorationCollection>
set_text_decorations
fn set_text_decorations(self: &Self, value: Option<TextDecorationCollection>)
text_trimming
fn text_trimming(self: &Self) -> Rc<dyn TextTrimming>
set_text_trimming
fn set_text_trimming(self: &Self, value: Rc<dyn TextTrimming>)
line_height
fn line_height(self: &Self) -> f64
set_line_height
fn set_line_height(self: &Self, value: f64)
text_wrapping
fn text_wrapping(self: &Self) -> TextWrapping
set_text_wrapping
fn set_text_wrapping(self: &Self, value: TextWrapping)
max_lines
fn max_lines(self: &Self) -> usize
set_max_lines
fn set_max_lines(self: &Self, value: usize)
overflow_content_target
fn overflow_content_target(self: &Self) -> Option<Ref<RichTextBlockOverflow>>
try_set_overflow_content_target
fn try_set_overflow_content_target(self: &Self, target: Option<Ref<RichTextBlockOverflow>>) -> bool
Links an overflow view. Cycles and a target already owned by another view are rejected without changing either chain.
set_overflow_content_target
fn set_overflow_content_target(self: &Self, target: Option<Ref<RichTextBlockOverflow>>)
Trait implementations
SendSyncFreezeUnsafeUnpinUnpinUnwindSafeRefUnwindSafeControlImplExtRichTextBlockImplExtBorrow<T>BorrowMut<T>Into<U>From<T>TryInto<U>TryFrom<U>ReceiverAnyInputElementImplExtInteractiveImplExtLayoutableImplExtFerroObjectImplExtStyledElementImplExtClassDefaultsVisualImplExtErasedDestructorIntoEitherDerefUpcast<T>Upcast<RichTextBlock>StaticTypeObjectTypeSubclassable<T>DefaultConstructibleStyledElementImplInteractiveImplFerroObjectImplControlImplVisualImplRichTextBlockImplLayoutableImplInputElementImplDrop
Availability
Extracted for aarch64-apple-darwin. Cargo features are listed in the crate index.