[−][src]Struct cursive_markup::MarkupView
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
impl MarkupView<RichRenderer>
[src]
pub fn html(html: &str) -> MarkupView<RichRenderer>
[src]
Creates a new MarkupView
that uses a rich text HTML renderer.
Requires the html
feature (enabled per default).
impl<R: Renderer + 'static> MarkupView<R>
[src]
pub fn with_renderer(renderer: R) -> MarkupView<R>
[src]
Creates a new MarkupView
with the given renderer.
pub fn on_link_focus<F: Fn(&mut Cursive, &str) + 'static>(&mut self, f: F)
[src]
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.
pub fn on_link_select<F: Fn(&mut Cursive, &str) + 'static>(&mut self, f: F)
[src]
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.
pub fn set_maximum_width(&mut self, width: usize)
[src]
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
impl<R: Renderer + 'static> View for MarkupView<R>
[src]
fn draw(&self, printer: &Printer<'_, '_>)
[src]
fn layout(&mut self, constraint: XY<usize>)
[src]
fn required_size(&mut self, constraint: XY<usize>) -> XY<usize>
[src]
fn take_focus(&mut self, direction: Direction) -> bool
[src]
fn on_event(&mut self, event: Event) -> EventResult
[src]
fn important_area(&self, _: XY<usize>) -> Rect
[src]
fn needs_relayout(&self) -> bool
fn call_on_any(
&mut self,
&Selector<'_>,
&'a mut (dyn FnMut(&mut (dyn View + 'static)) + 'a)
)
&mut self,
&Selector<'_>,
&'a mut (dyn FnMut(&mut (dyn View + 'static)) + 'a)
)
fn focus_view(&mut self, &Selector<'_>) -> Result<(), ()>
fn type_name(&self) -> &'static str
Auto Trait Implementations
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,
R: Unpin,
impl<R> !UnwindSafe for MarkupView<R>
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> AnyView for T where
T: View,
T: View,
fn as_any(&self) -> &(dyn Any + 'static)
Downcast self to a Any
.
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Downcast self to a mutable Any
.
fn as_boxed_any(self: Box<T>) -> Box<dyn Any + 'static>
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Erased for T
impl<T> Finder for T where
T: View,
T: View,
fn call_on<V, F, R>(&mut self, sel: &Selector<'_>, callback: F) -> Option<R> where
F: FnOnce(&mut V) -> R,
V: View,
F: FnOnce(&mut V) -> R,
V: View,
fn call_on_name<V, F, R>(&mut self, name: &str, callback: F) -> Option<R> where
F: FnOnce(&mut V) -> R,
V: View,
F: FnOnce(&mut V) -> R,
V: View,
fn call_on_id<V, F, R>(&mut self, id: &str, callback: F) -> Option<R> where
F: FnOnce(&mut V) -> R,
V: View,
F: FnOnce(&mut V) -> R,
V: View,
fn find_name<V>(
&mut self,
name: &str
) -> Option<OwningHandle<OwningRef<Rc<RefCell<V>>, RefCell<V>>, RefMut<'static, V>>> where
V: View,
&mut self,
name: &str
) -> Option<OwningHandle<OwningRef<Rc<RefCell<V>>, RefCell<V>>, RefMut<'static, V>>> where
V: View,
fn find_id<V>(
&mut self,
id: &str
) -> Option<OwningHandle<OwningRef<Rc<RefCell<V>>, RefCell<V>>, RefMut<'static, V>>> where
V: View,
&mut self,
id: &str
) -> Option<OwningHandle<OwningRef<Rc<RefCell<V>>, RefCell<V>>, RefMut<'static, V>>> where
V: View,
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> IntoBoxedView for T where
T: View,
T: View,
fn as_boxed_view(self) -> Box<dyn View + 'static>
impl<T> Nameable for T where
T: View,
T: View,
fn with_name<S>(self, name: S) -> NamedView<Self> where
S: Into<String>,
S: Into<String>,
fn with_id<S>(self, id: S) -> NamedView<Self> where
S: Into<String>,
S: Into<String>,
impl<T> Resizable for T where
T: View,
T: View,
fn boxed(
self,
width: SizeConstraint,
height: SizeConstraint
) -> ResizedView<Self>
self,
width: SizeConstraint,
height: SizeConstraint
) -> ResizedView<Self>
fn resized(
self,
width: SizeConstraint,
height: SizeConstraint
) -> ResizedView<Self>
self,
width: SizeConstraint,
height: SizeConstraint
) -> ResizedView<Self>
fn fixed_size<S>(self, size: S) -> ResizedView<Self> where
S: Into<XY<usize>>,
S: Into<XY<usize>>,
fn fixed_width(self, width: usize) -> ResizedView<Self>
fn fixed_height(self, height: usize) -> ResizedView<Self>
fn full_screen(self) -> ResizedView<Self>
fn full_width(self) -> ResizedView<Self>
fn full_height(self) -> ResizedView<Self>
fn max_size<S>(self, size: S) -> ResizedView<Self> where
S: Into<XY<usize>>,
S: Into<XY<usize>>,
fn max_width(self, max_width: usize) -> ResizedView<Self>
fn max_height(self, max_height: usize) -> ResizedView<Self>
fn min_size<S>(self, size: S) -> ResizedView<Self> where
S: Into<XY<usize>>,
S: Into<XY<usize>>,
fn min_width(self, min_width: usize) -> ResizedView<Self>
fn min_height(self, min_height: usize) -> ResizedView<Self>
impl<T> Scrollable for T where
T: View,
T: View,
fn scrollable(self) -> ScrollView<Self>
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> View for T where
T: ViewWrapper,
T: ViewWrapper,
fn draw(&self, printer: &Printer<'_, '_>)
fn required_size(&mut self, req: XY<usize>) -> XY<usize>
fn on_event(&mut self, ch: Event) -> EventResult
fn layout(&mut self, size: XY<usize>)
fn take_focus(&mut self, source: Direction) -> bool
fn call_on_any(
&mut self,
selector: &Selector<'_>,
callback: &'a mut (dyn FnMut(&mut (dyn View + 'static)) + 'a)
)
&mut self,
selector: &Selector<'_>,
callback: &'a mut (dyn FnMut(&mut (dyn View + 'static)) + 'a)
)