mirror of
https://github.com/sxyazi/yazi.git
synced 2026-07-21 23:01:05 +00:00
feat: support transparent images along with Sixel being used (#14)
This commit is contained in:
parent
cdb6ad1724
commit
5998d5cef6
7 changed files with 12 additions and 7 deletions
|
|
@ -40,7 +40,7 @@ impl Sixel {
|
|||
let nq = NeuQuant::new(10, 256 - alpha as usize, &img);
|
||||
|
||||
let mut buf: Vec<u8> = Vec::with_capacity(1 << 16);
|
||||
write!(buf, "\x1bP0;0;8q\"1;1;{};{}", img.width(), img.height())?;
|
||||
write!(buf, "\x1bP0;1;8q\"1;1;{};{}", img.width(), img.height())?;
|
||||
|
||||
// Palette
|
||||
for (i, c) in nq.color_map_rgba().chunks(4).enumerate() {
|
||||
|
|
|
|||
|
|
@ -67,6 +67,7 @@ impl App {
|
|||
|
||||
fn dispatch_resize(&mut self) {
|
||||
self.cx.manager.current_mut().set_page(true);
|
||||
self.cx.manager.active_mut().preview_reset_image();
|
||||
self.cx.manager.preview(self.cx.image_layer());
|
||||
emit!(Render);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,12 +22,12 @@ impl Default for PreviewAdaptor {
|
|||
}
|
||||
match env::var("TERM").unwrap_or_default().as_str() {
|
||||
"xterm-kitty" => return Self::Kitty,
|
||||
"wezterm" => return Self::Kitty,
|
||||
"foot" => return Self::Sixel,
|
||||
_ => {}
|
||||
}
|
||||
match env::var("TERM_PROGRAM").unwrap_or_default().as_str() {
|
||||
"iTerm.app" => return Self::Iterm2,
|
||||
"WezTerm" => return Self::Kitty,
|
||||
"Hyper" => return Self::Sixel,
|
||||
_ => {}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -59,7 +59,7 @@ impl Manager {
|
|||
};
|
||||
|
||||
if !show_image {
|
||||
self.active_mut().preview.reset_image();
|
||||
self.active_mut().preview_reset_image();
|
||||
}
|
||||
|
||||
if hovered.meta.is_dir() {
|
||||
|
|
|
|||
|
|
@ -221,6 +221,7 @@ impl Tab {
|
|||
drop(mem::replace(&mut self.current, rep));
|
||||
}
|
||||
|
||||
self.preview_reset_image();
|
||||
emit!(Refresh);
|
||||
true
|
||||
}
|
||||
|
|
@ -279,4 +280,7 @@ impl Tab {
|
|||
|
||||
#[inline]
|
||||
pub fn preview(&self) -> &Preview { &self.preview }
|
||||
|
||||
#[inline]
|
||||
pub fn preview_reset_image(&mut self) -> bool { self.preview.reset_image() }
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,9 +14,8 @@ pub struct Tabs {
|
|||
|
||||
impl Tabs {
|
||||
pub fn new() -> Self {
|
||||
let tabs = Self { idx: 0, items: vec![Tab::new(&MANAGER.cwd)] };
|
||||
|
||||
emit!(Refresh);
|
||||
let mut tabs = Self { idx: usize::MAX, items: vec![Tab::new(&MANAGER.cwd)] };
|
||||
tabs.set_idx(0);
|
||||
tabs
|
||||
}
|
||||
|
||||
|
|
@ -78,6 +77,7 @@ impl Tabs {
|
|||
#[inline]
|
||||
fn set_idx(&mut self, idx: usize) {
|
||||
self.idx = idx;
|
||||
self.active_mut().preview_reset_image();
|
||||
emit!(Refresh);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
{"flagWords":[],"words":["Punct","KEYMAP","splitn","crossterm","YAZI","unar","peekable","ratatui","syntect","pbpaste","pbcopy","ffmpegthumbnailer","oneshot","Posix","Lsar","XADDOS","zoxide","cands","Deque","precache","imageops","IFBLK","IFCHR","IFDIR","IFIFO","IFLNK","IFMT","IFSOCK","IRGRP","IROTH","IRUSR","ISGID","ISUID","ISVTX","IWGRP","IWOTH","IWUSR","IXGRP","IXOTH","IXUSR","libc","winsize","TIOCGWINSZ","xpixel","ypixel","ioerr","appender","Catppuccin","macchiato","gitmodules","Dotfiles","bashprofile","vimrc","flac","webp","exiftool","mediainfo","ripgrep","nvim","indexmap","indexmap","unwatch","canonicalize","serde","fsevent","Ueberzug","iterm","wezterm","sixel","chafa","ueberzugpp","️ Überzug","️ Überzug","Konsole","Alacritty"],"version":"0.2","language":"en"}
|
||||
{"language":"en","flagWords":[],"words":["Punct","KEYMAP","splitn","crossterm","YAZI","unar","peekable","ratatui","syntect","pbpaste","pbcopy","ffmpegthumbnailer","oneshot","Posix","Lsar","XADDOS","zoxide","cands","Deque","precache","imageops","IFBLK","IFCHR","IFDIR","IFIFO","IFLNK","IFMT","IFSOCK","IRGRP","IROTH","IRUSR","ISGID","ISUID","ISVTX","IWGRP","IWOTH","IWUSR","IXGRP","IXOTH","IXUSR","libc","winsize","TIOCGWINSZ","xpixel","ypixel","ioerr","appender","Catppuccin","macchiato","gitmodules","Dotfiles","bashprofile","vimrc","flac","webp","exiftool","mediainfo","ripgrep","nvim","indexmap","indexmap","unwatch","canonicalize","serde","fsevent","Ueberzug","iterm","wezterm","sixel","chafa","ueberzugpp","️ Überzug","️ Überzug","Konsole","Alacritty","Überzug"],"version":"0.2"}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue