pub struct MarkdownView;Expand description
A widget for rendering markdown text using MarkdownViewState.
§Example
use basalt_core::markdown;
use basalt_widgets::markdown::{MarkdownViewState, MarkdownView};
use ratatui::prelude::*;
use ratatui::widgets::StatefulWidgetRef;
let text = "# Hello, world!\nThis is a test.";
let mut state = MarkdownViewState::new(text);
let area = Rect::new(0, 0, 20, 10);
let mut buffer = Buffer::empty(area);
MarkdownView.render_ref(area, &mut buffer, &mut state);
let expected = [
"╭──────────────────▲",
"│█ Hello, world! █",
"│ █",
"│This is a test. █",
"│ █",
"│ █",
"│ █",
"│ ║",
"│ ║",
"╰──────────────────▼",
];
// FIXME: Take styles into account
// assert_eq!(buffer, Buffer::with_lines(expected));Trait Implementations§
Source§impl Clone for MarkdownView
impl Clone for MarkdownView
Source§fn clone(&self) -> MarkdownView
fn clone(&self) -> MarkdownView
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for MarkdownView
impl Debug for MarkdownView
Source§impl PartialEq for MarkdownView
impl PartialEq for MarkdownView
Source§impl StatefulWidgetRef for MarkdownView
impl StatefulWidgetRef for MarkdownView
Source§type State = MarkdownViewState
type State = MarkdownViewState
State associated with the stateful widget. Read more
impl StructuralPartialEq for MarkdownView
Auto Trait Implementations§
impl Freeze for MarkdownView
impl RefUnwindSafe for MarkdownView
impl Send for MarkdownView
impl Sync for MarkdownView
impl Unpin for MarkdownView
impl UnwindSafe for MarkdownView
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
Mutably borrows from an owned value. Read more
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>
Converts
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>
Converts
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