Skip to main content

Component

Trait Component 

Source
pub trait Component: Send {
    // Required methods
    fn measure(&mut self, width: u16) -> u16;
    fn render(&mut self, area: Rect, buf: &mut Buffer);
    fn handle_event(&mut self, event: &UiEvent) -> EventResult;
    fn invalidate(&mut self);
}
Expand description

Re-export of the pi-tui component contract for downstream callers. Height-for-width terminal component.

render must emit exactly the number of rows previously returned by Component::measure for the same width.

Required Methods§

Source

fn measure(&mut self, width: u16) -> u16

Measure the height required to render at width.

Source

fn render(&mut self, area: Rect, buf: &mut Buffer)

Render into area of buf.

Source

fn handle_event(&mut self, event: &UiEvent) -> EventResult

Handle an input event.

Source

fn invalidate(&mut self)

Drop width/theme-sensitive caches after resize or theme change.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl Component for SlotComponent

Source§

fn measure(&mut self, _width: u16) -> u16

Source§

fn render(&mut self, area: Rect, buf: &mut Buffer)

Source§

fn handle_event(&mut self, event: &UiEvent) -> EventResult

Source§

fn invalidate(&mut self)

Implementors§