pub struct DocumentWidget<'a> { /* private fields */ }Expand description
Custom widget for rendering document content with proper text wrapping and inline images.
This widget handles the complete layout of document elements including:
- Text with unicode-aware wrapping
- Inline images with correct positioning
- Tables, lists, and other formatted content
- Search result highlighting
Unlike using the Paragraph widget with image overlays, this widget renders everything in a single pass with full control over layout, ensuring images are positioned correctly even when text wraps across multiple lines.
Implementations§
Source§impl<'a> DocumentWidget<'a>
impl<'a> DocumentWidget<'a>
Sourcepub fn new(elements: &'a [DocumentElement]) -> Self
pub fn new(elements: &'a [DocumentElement]) -> Self
Create a new DocumentWidget with the given document elements
Sourcepub fn scroll_offset(self, offset: usize) -> Self
pub fn scroll_offset(self, offset: usize) -> Self
Set the scroll offset (number of elements to skip from the top)
Sourcepub fn color_enabled(self, enabled: bool) -> Self
pub fn color_enabled(self, enabled: bool) -> Self
Enable or disable color rendering
Sourcepub fn search_results(self, results: &'a [SearchResult]) -> Self
pub fn search_results(self, results: &'a [SearchResult]) -> Self
Set search results for highlighting
Sourcepub fn current_search_index(self, index: usize) -> Self
pub fn current_search_index(self, index: usize) -> Self
Set the current search result index for highlighting
Sourcepub fn render(
&mut self,
area: Rect,
frame: &mut Frame<'_>,
image_protocols: &mut [StatefulProtocol],
layout_cache: &mut LayoutCache,
)
pub fn render( &mut self, area: Rect, frame: &mut Frame<'_>, image_protocols: &mut [StatefulProtocol], layout_cache: &mut LayoutCache, )
Custom render method that has access to Frame for complete rendering.
This method renders all document elements including text (with wrapping) and images. Unlike the Widget trait’s render method, this has access to Frame which is required for rendering StatefulImage widgets.
Auto Trait Implementations§
impl<'a> Freeze for DocumentWidget<'a>
impl<'a> RefUnwindSafe for DocumentWidget<'a>
impl<'a> Send for DocumentWidget<'a>
impl<'a> Sync for DocumentWidget<'a>
impl<'a> Unpin for DocumentWidget<'a>
impl<'a> UnsafeUnpin for DocumentWidget<'a>
impl<'a> UnwindSafe for DocumentWidget<'a>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more