pub struct Layout { /* private fields */ }Expand description
Prepared terminal rows and document-relative navigation positions.
A layout owns its rendered text and styles, so the source Document and
LayoutOptions can be dropped after construction. Rendering never wraps or
reparses it. Prepare a new layout when the content-area width changes.
Implementations§
Source§impl Layout
impl Layout
Sourcepub fn new(
document: &Document,
width: u16,
options: &LayoutOptions,
) -> Result<Self, LayoutError>
pub fn new( document: &Document, width: u16, options: &LayoutOptions, ) -> Result<Self, LayoutError>
Lays out a parsed document synchronously for width terminal cells.
Unicode grapheme clusters are measured by display width. Width zero
produces an empty layout. A grapheme wider than the available content
width becomes �; a wide grapheme is never split across cells.
§Errors
Returns LayoutError::TooManyLines before retaining more than the
configured LayoutOptions::line_limit budget.
Sourcepub fn line_count(&self) -> usize
pub fn line_count(&self) -> usize
Total row count after wrapping, including block spacing.
Sourcepub fn links(&self) -> &[LinkPosition]
pub fn links(&self) -> &[LinkPosition]
Returns document-relative link cells after wrapping.
Positions use the IDs assigned by markdown_model::Document::links.
Widget offsets and scroll state are not included.
Sourcepub fn headings(&self) -> &[HeadingPosition]
pub fn headings(&self) -> &[HeadingPosition]
Returns heading anchors and their document-relative rows.
Sourcepub fn plain_lines(&self) -> Vec<String>
pub fn plain_lines(&self) -> Vec<String>
Allocates the plain text of every prepared row.
This is useful for tests, export, and accessibility adapters. Render
Layout::widget when styles are needed or the allocation is unwanted.
Sourcepub fn widget(&self) -> MarkdownWidget<'_>
pub fn widget(&self) -> MarkdownWidget<'_>
Borrows this layout as a MarkdownWidget.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Layout
impl RefUnwindSafe for Layout
impl Send for Layout
impl Sync for Layout
impl Unpin for Layout
impl UnsafeUnpin for Layout
impl UnwindSafe for Layout
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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