Skip to main content

Html

Struct Html 

Source
pub struct Html { /* private fields */ }
Expand description

A view that renders an HTML fragment to its area.

Html view demo

The standalone counterpart to attaching an HtmlRenderer to markdown: same engine, but the whole area is HTML. Prose wraps to the width, <pre> stays verbatim, and tables are fitted — recomputed each frame, so one fragment covers every terminal size.

use tuika::prelude::*;
use tuika_html::Html;
let page = Html::new("<h1>Release notes</h1><ul><li>Faster</li></ul>");
// `page` is a `View`: render it via `tuika::paint` or embed it in a `Flex`.

cargo run -p tuika-html --example html_view is the scene above.

Implementations§

Source§

impl Html

Source

pub fn new(source: impl Into<String>) -> Self

A view over source.

Examples found in repository?
examples/html_view/main.rs (line 21)
20fn scene() -> Element {
21    let page = Boxed::new(element(Html::new(PAGE)))
22        .title(" ada.html ")
23        .padding(Padding::symmetric(2, 1));
24    let hints = KeyHints::new([("q", "quit")]);
25    view! {
26        col(padding = Padding::all(1), gap = 1) {
27            grow(1) { node(page) }
28            fixed(1) { node(hints) }
29        }
30    }
31}
Source

pub fn limits(self, limits: Limits) -> Self

Bound this view’s rendering; see Limits.

Trait Implementations§

Source§

impl View for Html

Source§

fn measure(&self, available: Size, ctx: &RenderCtx<'_>) -> Size

Report the intrinsic content size wanted given available and ctx.
Source§

fn render(&self, area: Rect, surface: &mut Surface<'_>, ctx: &RenderCtx<'_>)

Paint the view into the assigned area through surface.
Source§

fn measure_request(&self, request: MeasureRequest, ctx: &RenderCtx<'_>) -> Size

Answer a measurement request with optional known axes and intrinsic sizing modes. Read more

Auto Trait Implementations§

§

impl Freeze for Html

§

impl RefUnwindSafe for Html

§

impl Send for Html

§

impl Sync for Html

§

impl Unpin for Html

§

impl UnsafeUnpin for Html

§

impl UnwindSafe for Html

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.