pub struct ImageWidget { /* private fields */ }Expand description
A widget that displays an inline terminal image.
The component renders placeholder text lines that reserve the same number
of cells the terminal will use for the image, and emits an
ImageCommand so the renderer can upload
the image using the selected terminal graphics protocol (Kitty or iTerm2).
Implementations§
Source§impl ImageWidget
impl ImageWidget
Sourcepub fn new(
data: Vec<u8>,
mime_type: impl Into<String>,
placeholder: Option<String>,
) -> Self
pub fn new( data: Vec<u8>, mime_type: impl Into<String>, placeholder: Option<String>, ) -> Self
Create a new image widget.
data is the raw image bytes. placeholder defaults to "[image]".
The widget is assigned a unique image id and uses the Kitty protocol by
default. The display size in cells is inferred from the image’s pixel
dimensions when possible, falling back to 20×10 cells.
Sourcepub fn with_protocol(self, protocol: ImageProtocol) -> Self
pub fn with_protocol(self, protocol: ImageProtocol) -> Self
Override the terminal image protocol used by this widget.
Trait Implementations§
Source§impl Component for ImageWidget
impl Component for ImageWidget
Source§fn render(&self, width: u16) -> Result<Rendered, RenderError>
fn render(&self, width: u16) -> Result<Rendered, RenderError>
Render this component into lines of text at the given width. Read more
Source§fn render_rect(&self, rect: Rect) -> Result<Rendered, RenderError>
fn render_rect(&self, rect: Rect) -> Result<Rendered, RenderError>
Render this component into a specific rectangular area. Read more
Source§fn handle_input(&mut self, _event: &Event) -> InputResult
fn handle_input(&mut self, _event: &Event) -> InputResult
Handle an input event (key press, resize, mouse, etc.). Read more
Source§fn wants_key_release(&self) -> bool
fn wants_key_release(&self) -> bool
Returns
true if this component wants to receive
KeyEventKind::Release events in addition to Press / Repeat. Read moreAuto Trait Implementations§
impl Freeze for ImageWidget
impl RefUnwindSafe for ImageWidget
impl Send for ImageWidget
impl Sync for ImageWidget
impl Unpin for ImageWidget
impl UnsafeUnpin for ImageWidget
impl UnwindSafe for ImageWidget
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