pub struct MarkupView<R: Renderer + 'static> { /* private fields */ }
Expand description
A view for hypertext that has been rendered by a Renderer
.
This view displays hypertext (a combination of formatted text and links) that typically has
been parsed from a markup language. You can use the arrow keys to navigate between the links,
and the Enter key to select a link. If the focused link is changed, the on_link_focus
callback is triggered. If the focused link is selected using the Enter key, the
on_link_select
callback is triggered.
The displayed hypertext is created by a Renderer
implementation. The MarkupView
calls
the render
method with the size constraint provided by cursive
and receives a
RenderedDocument
that contains the text and the links. This document is cached until the
available width changes.
You can also limit the available width by setting a maximum line width with the
set_maximum_width
method.
Implementations§
Source§impl MarkupView<RichRenderer>
impl MarkupView<RichRenderer>
Sourcepub fn html(html: &str) -> MarkupView<RichRenderer>
pub fn html(html: &str) -> MarkupView<RichRenderer>
Creates a new MarkupView
that uses a rich text HTML renderer.
Requires the html
feature (enabled per default).
Source§impl<R: Renderer + 'static> MarkupView<R>
impl<R: Renderer + 'static> MarkupView<R>
Sourcepub fn with_renderer(renderer: R) -> MarkupView<R>
pub fn with_renderer(renderer: R) -> MarkupView<R>
Creates a new MarkupView
with the given renderer.
Sourcepub fn on_link_focus<F: Fn(&mut Cursive, &str) + 'static>(&mut self, f: F)
pub fn on_link_focus<F: Fn(&mut Cursive, &str) + 'static>(&mut self, f: F)
Sets the callback that is triggered if the link focus is changed.
Note that this callback is only triggered if the link focus is changed with the arrow keys. It is not triggered if the view takes focus. The callback will receive the target of the link as an argument.
Sourcepub fn on_link_select<F: Fn(&mut Cursive, &str) + 'static>(&mut self, f: F)
pub fn on_link_select<F: Fn(&mut Cursive, &str) + 'static>(&mut self, f: F)
Sets the callback that is triggered if a link is selected.
This callback is triggered if a link is focused and the users presses the Enter key. The callback will receive the target of the link as an argument.
Sourcepub fn set_maximum_width(&mut self, width: usize)
pub fn set_maximum_width(&mut self, width: usize)
Sets the maximum width of the view.
This means that the width that is available for the renderer is limited to the given value.
Trait Implementations§
Source§impl<R: Renderer + 'static> View for MarkupView<R>
impl<R: Renderer + 'static> View for MarkupView<R>
Source§fn draw(&self, printer: &Printer<'_, '_>)
fn draw(&self, printer: &Printer<'_, '_>)
Source§fn layout(&mut self, constraint: XY<usize>)
fn layout(&mut self, constraint: XY<usize>)
Source§fn required_size(&mut self, constraint: XY<usize>) -> XY<usize>
fn required_size(&mut self, constraint: XY<usize>) -> XY<usize>
Source§fn take_focus(
&mut self,
direction: Direction,
) -> Result<EventResult, CannotFocus>
fn take_focus( &mut self, direction: Direction, ) -> Result<EventResult, CannotFocus>
Source§fn on_event(&mut self, event: Event) -> EventResult
fn on_event(&mut self, event: Event) -> EventResult
Source§fn important_area(&self, _: XY<usize>) -> Rect
fn important_area(&self, _: XY<usize>) -> Rect
Source§fn needs_relayout(&self) -> bool
fn needs_relayout(&self) -> bool
Source§fn call_on_any(
&mut self,
_: &Selector<'_>,
_: &mut dyn FnMut(&mut (dyn View + 'static)),
)
fn call_on_any( &mut self, _: &Selector<'_>, _: &mut dyn FnMut(&mut (dyn View + 'static)), )
Source§fn focus_view(&mut self, _: &Selector<'_>) -> Result<EventResult, ViewNotFound>
fn focus_view(&mut self, _: &Selector<'_>) -> Result<EventResult, ViewNotFound>
Auto Trait Implementations§
impl<R> Freeze for MarkupView<R>where
R: Freeze,
impl<R> !RefUnwindSafe for MarkupView<R>
impl<R> !Send for MarkupView<R>
impl<R> !Sync for MarkupView<R>
impl<R> Unpin for MarkupView<R>where
R: Unpin,
impl<R> !UnwindSafe for MarkupView<R>
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> Finder for Twhere
T: View,
impl<T> Finder for Twhere
T: View,
Source§fn call_on_all<V, F>(&mut self, sel: &Selector<'_>, callback: F)
fn call_on_all<V, F>(&mut self, sel: &Selector<'_>, callback: F)
sel
. Read moreSource§fn call_on<V, F, R>(&mut self, sel: &Selector<'_>, callback: F) -> Option<R>
fn call_on<V, F, R>(&mut self, sel: &Selector<'_>, callback: F) -> Option<R>
sel
. Read moreSource§fn call_on_name<V, F, R>(&mut self, name: &str, callback: F) -> Option<R>
fn call_on_name<V, F, R>(&mut self, name: &str, callback: F) -> Option<R>
call_on
with a view::Selector::Name
.Source§impl<T> IntoBoxedView for Twhere
T: View,
impl<T> IntoBoxedView for Twhere
T: View,
Source§fn into_boxed_view(self) -> Box<dyn View>
fn into_boxed_view(self) -> Box<dyn View>
Box<View>
.Source§impl<T> Resizable for Twhere
T: View,
impl<T> Resizable for Twhere
T: View,
Source§fn resized(
self,
width: SizeConstraint,
height: SizeConstraint,
) -> ResizedView<Self>
fn resized( self, width: SizeConstraint, height: SizeConstraint, ) -> ResizedView<Self>
self
in a ResizedView
with the given size constraints.Source§fn fixed_size<S>(self, size: S) -> ResizedView<Self>
fn fixed_size<S>(self, size: S) -> ResizedView<Self>
self
into a fixed-size ResizedView
.Source§fn fixed_width(self, width: usize) -> ResizedView<Self>
fn fixed_width(self, width: usize) -> ResizedView<Self>
self
into a fixed-width ResizedView
.Source§fn fixed_height(self, height: usize) -> ResizedView<Self>
fn fixed_height(self, height: usize) -> ResizedView<Self>
self
into a fixed-width ResizedView
.Source§fn full_screen(self) -> ResizedView<Self>
fn full_screen(self) -> ResizedView<Self>
self
into a full-screen ResizedView
.Source§fn full_width(self) -> ResizedView<Self>
fn full_width(self) -> ResizedView<Self>
self
into a full-width ResizedView
.Source§fn full_height(self) -> ResizedView<Self>
fn full_height(self) -> ResizedView<Self>
self
into a full-height ResizedView
.Source§fn max_size<S>(self, size: S) -> ResizedView<Self>
fn max_size<S>(self, size: S) -> ResizedView<Self>
self
into a limited-size ResizedView
.Source§fn max_width(self, max_width: usize) -> ResizedView<Self>
fn max_width(self, max_width: usize) -> ResizedView<Self>
self
into a limited-width ResizedView
.Source§fn max_height(self, max_height: usize) -> ResizedView<Self>
fn max_height(self, max_height: usize) -> ResizedView<Self>
self
into a limited-height ResizedView
.Source§fn min_size<S>(self, size: S) -> ResizedView<Self>
fn min_size<S>(self, size: S) -> ResizedView<Self>
self
into a ResizedView
at least sized size
.Source§fn min_width(self, min_width: usize) -> ResizedView<Self>
fn min_width(self, min_width: usize) -> ResizedView<Self>
self
in a ResizedView
at least min_width
wide.Source§fn min_height(self, min_height: usize) -> ResizedView<Self>
fn min_height(self, min_height: usize) -> ResizedView<Self>
self
in a ResizedView
at least min_height
tall.Source§impl<T> Scrollable for Twhere
T: View,
impl<T> Scrollable for Twhere
T: View,
Source§fn scrollable(self) -> ScrollView<Self>
fn scrollable(self) -> ScrollView<Self>
self
in a ScrollView
.