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: boolWhether the widget is visible
max_width: u32Maximum width for display (characters)
max_height: u32Maximum height for display (characters)
show_metadata: boolWhether to show metadata
use_ascii_placeholder: boolWhether to use ASCII placeholder
Implementations§
Source§impl ImageWidget
impl ImageWidget
Sourcepub fn with_dimensions(width: u32, height: u32) -> Self
pub fn with_dimensions(width: u32, height: u32) -> Self
Create a new image widget with specific dimensions
Sourcepub fn add_images(&mut self, paths: Vec<PathBuf>)
pub fn add_images(&mut self, paths: Vec<PathBuf>)
Sourcepub fn remove_image(&mut self, path: &PathBuf) -> bool
pub fn remove_image(&mut self, path: &PathBuf) -> bool
Sourcepub fn clear_images(&mut self)
pub fn clear_images(&mut self)
Clear all images from the widget
Sourcepub fn image_count(&self) -> usize
pub fn image_count(&self) -> usize
Get the number of images in the widget
Sourcepub fn has_images(&self) -> bool
pub fn has_images(&self) -> bool
Check if the widget has any images
Sourcepub fn get_images(&self) -> &[PathBuf]
pub fn get_images(&self) -> &[PathBuf]
Get the images in the widget
Sourcepub fn toggle_visibility(&mut self)
pub fn toggle_visibility(&mut self)
Toggle widget visibility
Sourcepub fn set_dimensions(&mut self, width: u32, height: u32)
pub fn set_dimensions(&mut self, width: u32, height: u32)
Sourcepub fn enable_metadata(&mut self)
pub fn enable_metadata(&mut self)
Enable metadata display
Sourcepub fn disable_metadata(&mut self)
pub fn disable_metadata(&mut self)
Disable metadata display
Sourcepub fn enable_ascii_placeholder(&mut self)
pub fn enable_ascii_placeholder(&mut self)
Enable ASCII placeholder
Sourcepub fn disable_ascii_placeholder(&mut self)
pub fn disable_ascii_placeholder(&mut self)
Disable ASCII placeholder
Sourcepub fn render(&self) -> String
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
impl Clone for ImageWidget
Source§fn clone(&self) -> ImageWidget
fn clone(&self) -> ImageWidget
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for ImageWidget
impl Debug for ImageWidget
Auto Trait Implementations§
impl Freeze for ImageWidget
impl RefUnwindSafe for ImageWidget
impl Send for ImageWidget
impl Sync for ImageWidget
impl Unpin 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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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