ImageWidget

Struct ImageWidget 

Source
pub struct ImageWidget {
    pub images: Vec<PathBuf>,
    pub visible: bool,
    pub max_width: u32,
    pub max_height: u32,
    pub show_metadata: bool,
    pub use_ascii_placeholder: bool,
}
Expand description

Image widget for displaying images in the terminal

Provides:

  • Single and multiple image display
  • Metadata rendering (format, size, dimensions)
  • ASCII placeholder fallback
  • Automatic resizing to fit terminal bounds
  • Vertical organization with separators

§Requirements

  • Req 5.1: Display images in terminal using ricecoder-images ImageDisplay
  • Req 5.2: Show metadata (format, size, dimensions)
  • Req 5.3: ASCII placeholder for unsupported terminals
  • Req 5.4: Resize to fit terminal bounds (max 80x30)
  • Req 5.5: Organize multiple images vertically with separators

Fields§

§images: Vec<PathBuf>

Image file paths to display

§visible: bool

Whether the widget is visible

§max_width: u32

Maximum width for display (characters)

§max_height: u32

Maximum height for display (characters)

§show_metadata: bool

Whether to show metadata

§use_ascii_placeholder: bool

Whether to use ASCII placeholder

Implementations§

Source§

impl ImageWidget

Source

pub fn new() -> Self

Create a new image widget

Source

pub fn with_dimensions(width: u32, height: u32) -> Self

Create a new image widget with specific dimensions

Source

pub fn add_image(&mut self, path: PathBuf)

Add an image to the widget

§Arguments
  • path - Path to the image file
§Requirements
  • Req 5.1: Add image to widget for display
Source

pub fn add_images(&mut self, paths: Vec<PathBuf>)

Add multiple images to the widget

§Arguments
  • paths - Paths to the image files
§Requirements
  • Req 5.5: Organize multiple images vertically with separators
Source

pub fn remove_image(&mut self, path: &PathBuf) -> bool

Remove an image from the widget

§Arguments
  • path - Path to the image to remove
§Returns

True if image was removed, false if not found

Source

pub fn clear_images(&mut self)

Clear all images from the widget

Source

pub fn image_count(&self) -> usize

Get the number of images in the widget

Source

pub fn has_images(&self) -> bool

Check if the widget has any images

Source

pub fn get_images(&self) -> &[PathBuf]

Get the images in the widget

Source

pub fn show(&mut self)

Show the widget

Source

pub fn hide(&mut self)

Hide the widget

Source

pub fn toggle_visibility(&mut self)

Toggle widget visibility

Source

pub fn set_dimensions(&mut self, width: u32, height: u32)

Set the maximum display dimensions

§Arguments
  • width - Maximum width in characters
  • height - Maximum height in characters
§Requirements
  • Req 5.4: Resize to fit terminal bounds (max 80x30)
Source

pub fn enable_metadata(&mut self)

Enable metadata display

Source

pub fn disable_metadata(&mut self)

Disable metadata display

Source

pub fn enable_ascii_placeholder(&mut self)

Enable ASCII placeholder

Source

pub fn disable_ascii_placeholder(&mut self)

Disable ASCII placeholder

Source

pub fn render(&self) -> String

Render the widget as a string

§Returns

Rendered widget string

§Requirements
  • Req 5.1: Display images in terminal using ricecoder-images ImageDisplay
  • Req 5.2: Show metadata (format, size, dimensions)
  • Req 5.3: ASCII placeholder for unsupported terminals
  • Req 5.4: Resize to fit terminal bounds (max 80x30)
  • Req 5.5: Organize multiple images vertically with separators

Trait Implementations§

Source§

impl Clone for ImageWidget

Source§

fn clone(&self) -> ImageWidget

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for ImageWidget

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for ImageWidget

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. 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.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more