diff options
author | Canop <cano.petrole@gmail.com> | 2020-11-26 21:25:08 +0100 |
---|---|---|
committer | Canop <cano.petrole@gmail.com> | 2020-11-26 21:25:08 +0100 |
commit | d0780bc4560e050a04293b941f1e44cb067eefc0 (patch) | |
tree | 347ac149dd010bacae70b03d00c602e2d5f501f9 /src/image/image_view.rs | |
parent | 9785535f80573a9b00d2ce738f0c5a8df81db392 (diff) |
high definition preview images on kitty
Diffstat (limited to 'src/image/image_view.rs')
-rw-r--r-- | src/image/image_view.rs | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/src/image/image_view.rs b/src/image/image_view.rs index 1c2290b..a9fa3ff 100644 --- a/src/image/image_view.rs +++ b/src/image/image_view.rs @@ -70,18 +70,25 @@ impl ImageView { area: &Area, con: &AppContext, ) -> Result<(), ProgramError> { + let styles = &panel_skin.styles; + let bg = styles.preview.get_bg() + .or_else(|| styles.default.get_bg()) + .unwrap_or(Color::AnsiValue(238)); #[cfg(unix)] if let Some(renderer) = kitty::image_renderer() { let mut renderer = renderer.lock().unwrap(); w.queue(cursor::MoveTo(area.left, area.top))?; - renderer.print_with_chunks( + renderer.print_with_temp_file( w, &self.source_img, area.width, area.height, )?; - // TODO clean area below (using z-index?) + for y in area.top..area.top+area.height { + w.queue(cursor::MoveTo(area.left, y))?; + fill_bg(w, area.width as usize, bg)?; + } return Ok(()); } @@ -108,10 +115,6 @@ impl ImageView { let (width, height) = img.dimensions(); debug!("resized image dimensions: {},{}", width, height); debug_assert!(width <= area.width as u32); - let styles = &panel_skin.styles; - let bg = styles.preview.get_bg() - .or_else(|| styles.default.get_bg()) - .unwrap_or(Color::AnsiValue(238)); let mut double_line = DoubleLine::new(width as usize, con.true_colors); let mut y = area.top; let margin = area.width as usize - width as usize; @@ -133,7 +136,7 @@ impl ImageView { w.queue(SetBackgroundColor(bg))?; for y in y..area.top+area.height { w.queue(cursor::MoveTo(area.left, y))?; - fill_bg(w,area.width as usize, bg)?; + fill_bg(w, area.width as usize, bg)?; } Ok(()) } |