This commit is contained in:
sxyazi 2024-08-05 17:12:28 +08:00
parent 87406b1122
commit d16c3515d9
No known key found for this signature in database
10 changed files with 34 additions and 39 deletions

View File

@ -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","Überzug","pkgs","paru","unarchiver","pdftoppm","poppler","prebuild","singlefile","jpegopt","EXIF","rustfmt","mktemp","nanos","xclip","xsel","natord","Mintty","nixos","nixpkgs","SIGTSTP","SIGCONT","SIGCONT","mlua","nonstatic","userdata","metatable","natsort","backstack","luajit","Succ","Succ","cand","fileencoding","foldmethod","lightgreen","darkgray","lightred","lightyellow","lightcyan","nushell","msvc","aarch","linemode","sxyazi","rsplit","ZELLIJ","bitflags","bitflags","USERPROFILE","Neovim","vergen","gitcl","Renderable","preloaders","prec","imagesize","Upserting","prio","Ghostty","Catmull","Lanczos","cmds","unyank","scrolloff","headsup","unsub","uzers","scopeguard","SPDLOG","globset","filetime","magick","magick","prefetcher","Prework","prefetchers","PREWORKERS","conds","translit","rxvt","Urxvt","realpath","realname","REPARSE","hardlink","hardlinking","nlink","nlink","linemodes","SIGSTOP","sevenzip","rsplitn","replacen","DECSET","DECRQM"],"language":"en","version":"0.2"}
{"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","pkgs","paru","unarchiver","pdftoppm","poppler","prebuild","singlefile","jpegopt","EXIF","rustfmt","mktemp","nanos","xclip","xsel","natord","Mintty","nixos","nixpkgs","SIGTSTP","SIGCONT","SIGCONT","mlua","nonstatic","userdata","metatable","natsort","backstack","luajit","Succ","Succ","cand","fileencoding","foldmethod","lightgreen","darkgray","lightred","lightyellow","lightcyan","nushell","msvc","aarch","linemode","sxyazi","rsplit","ZELLIJ","bitflags","bitflags","USERPROFILE","Neovim","vergen","gitcl","Renderable","preloaders","prec","imagesize","Upserting","prio","Ghostty","Catmull","Lanczos","cmds","unyank","scrolloff","headsup","unsub","uzers","scopeguard","SPDLOG","globset","filetime","magick","magick","prefetcher","Prework","prefetchers","PREWORKERS","conds","translit","rxvt","Urxvt","realpath","realname","REPARSE","hardlink","hardlinking","nlink","nlink","linemodes","SIGSTOP","sevenzip","rsplitn","replacen","DECSET","DECRQM","repeek"],"version":"0.2","language":"en","flagWords":[]}

View File

@ -92,7 +92,7 @@ fetchers = [
]
preloaders = [
# Image
{ mime = "image/{avif,heic,jxl,svg+xml}", run = "magick" },
{ mime = "image/{avif,hei?,jxl,svg+xml}", run = "magick" },
{ mime = "image/*", run = "image" },
# Video
{ mime = "video/*", run = "video" },
@ -110,7 +110,7 @@ previewers = [
# JSON
{ mime = "application/{json,x-ndjson}", run = "json" },
# Image
{ mime = "image/{avif,heic,jxl,svg+xml}", run = "magick" },
{ mime = "image/{avif,hei?,jxl,svg+xml}", run = "magick" },
{ mime = "image/*", run = "image" },
# Video
{ mime = "video/*", run = "video" },

View File

@ -28,7 +28,7 @@ impl Manager {
self.current_mut().tracing = true;
}
// Re-peek
// Repeek
self.peek(false);
// Refresh watcher

View File

@ -50,9 +50,12 @@ impl Manager {
.cloned()
.collect();
let repeek = self.hovered().is_some_and(|f| updates.contains_key(&f.url));
self.mimetype.extend(updates);
self.peek(false);
if repeek {
self.peek(false);
}
tasks.prework_affected(&affected, &self.mimetype);
render!();
}

View File

@ -111,7 +111,7 @@ impl Watcher {
async fn fan_out(rx: UnboundedReceiver<Url>) {
// TODO: revert this once a new notification is implemented
let rx = UnboundedReceiverStream::new(rx).chunks_timeout(1000, Duration::from_millis(50));
let rx = UnboundedReceiverStream::new(rx).chunks_timeout(1000, Duration::from_millis(100));
pin!(rx);
while let Some(chunk) = rx.next().await {

View File

@ -89,25 +89,11 @@ impl Preview {
matches!(self.lock, Some(ref lock) if lock.url == *url)
}
#[inline]
fn content_unchanged(&self, url: &Url, cha: &Cha) -> bool {
let Some(lock) = &self.lock else {
return false;
};
*url == lock.url
&& self.skip == lock.skip
&& cha.len == lock.cha.len
&& cha.mtime == lock.cha.mtime
&& cha.kind == lock.cha.kind
&& {
#[cfg(unix)]
{
cha.perm == lock.cha.perm
}
#[cfg(windows)]
{
true
}
}
match &self.lock {
Some(l) => *url == l.url && self.skip == l.skip && cha.hits(l.cha),
None => false,
}
}
}

View File

@ -264,19 +264,18 @@ impl Files {
macro_rules! go {
($dist:expr, $src:expr, $inc:literal) => {
let mut b = false;
let mut b = true;
for i in 0..$dist.len() {
if let Some(f) = $src.remove(&$dist[i].url) {
if $dist[i] != f {
b = true;
$dist[i] = f;
}
b &= $dist[i].cha.hits(f.cha);
$dist[i] = f;
if $src.is_empty() {
break;
}
}
}
self.revision += if b { $inc } else { 0 };
self.revision += if b { 0 } else { $inc };
};
}

View File

@ -24,11 +24,11 @@ function M:preload()
"-density",
"200",
tostring(self.file.url),
"-auto-orient",
"-resize",
string.format("%dx%d^", PREVIEW.max_width, PREVIEW.max_height),
"-quality",
tostring(PREVIEW.image_quality),
"-auto-orient",
"JPG:" .. tostring(cache),
}):spawn()

View File

@ -120,6 +120,20 @@ impl Cha {
self.kind |= kind;
self
}
#[inline]
pub fn hits(self, c: Self) -> bool {
self.len == c.len && self.mtime == c.mtime && self.ctime == c.ctime && self.kind == c.kind && {
#[cfg(unix)]
{
self.perm == c.perm
}
#[cfg(windows)]
{
true
}
}
}
}
impl Cha {

View File

@ -25,13 +25,6 @@ impl AsRef<File> for File {
fn as_ref(&self) -> &File { self }
}
impl PartialEq for File {
#[inline]
fn eq(&self, other: &Self) -> bool {
self.cha == other.cha && self.url == other.url && self.link_to == other.link_to
}
}
impl File {
#[inline]
pub async fn from(url: Url) -> Result<Self> {