diff --git a/cspell.json b/cspell.json index 314adb1a..b4f2d024 100644 --- a/cspell.json +++ b/cspell.json @@ -1 +1 @@ -{"version":"0.2","language":"en","words":["Punct","KEYMAP","splitn","crossterm","YAZI","peekable","ratatui","syntect","pbpaste","pbcopy","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","indexmap","indexmap","unwatch","canonicalize","serde","fsevent","Ueberzug","iterm","wezterm","sixel","chafa","ueberzugpp","Konsole","Überzug","pkgs","pdftoppm","poppler","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","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","cwds","tcsi","Hyprland","Wayfire","SWAYSOCK","btime","nsec","codegen","gethostname","fchmod","fdfind","Rustc","rustc","ffprobe","vframes","luma","obase","outln","errln","tmtheme","twox","cfgs","fstype","objc","rdev","runloop","exfat","rclone","DECRQSS","DECSCUSR","libvterm","Uninit","lockin","rposition"],"flagWords":[]} \ No newline at end of file +{"version":"0.2","language":"en","flagWords":[],"words":["Punct","KEYMAP","splitn","crossterm","YAZI","peekable","ratatui","syntect","pbpaste","pbcopy","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","indexmap","indexmap","unwatch","canonicalize","serde","fsevent","Ueberzug","iterm","wezterm","sixel","chafa","ueberzugpp","Konsole","Überzug","pkgs","pdftoppm","poppler","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","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","cwds","tcsi","Hyprland","Wayfire","SWAYSOCK","btime","nsec","codegen","gethostname","fchmod","fdfind","Rustc","rustc","ffprobe","vframes","luma","obase","outln","errln","tmtheme","twox","cfgs","fstype","objc","rdev","runloop","exfat","rclone","DECRQSS","DECSCUSR","libvterm","Uninit","lockin","rposition","resvg"]} \ No newline at end of file diff --git a/yazi-boot/src/actions/debug.rs b/yazi-boot/src/actions/debug.rs index c6e4fcde..07ae04dd 100644 --- a/yazi-boot/src/actions/debug.rs +++ b/yazi-boot/src/actions/debug.rs @@ -93,6 +93,7 @@ impl Actions { writeln!(s, " zoxide : {}", Self::process_output("zoxide", "--version"))?; #[rustfmt::skip] writeln!(s, " 7zz/7z : {} / {}", Self::process_output("7zz", "i"), Self::process_output("7z", "i"))?; + writeln!(s, " resvg : {}", Self::process_output("resvg", "--version"))?; writeln!(s, " jq : {}", Self::process_output("jq", "--version"))?; writeln!(s, "\nClipboard")?; diff --git a/yazi-core/src/mgr/commands/hover.rs b/yazi-core/src/mgr/commands/hover.rs deleted file mode 100644 index a94dda8c..00000000 --- a/yazi-core/src/mgr/commands/hover.rs +++ /dev/null @@ -1,50 +0,0 @@ -use yazi_dds::Pubsub; -use yazi_macro::render; -use yazi_shared::{Id, event::{CmdCow, Data}, url::{Url, Urn}}; - -use crate::mgr::Mgr; - -struct Opt { - url: Option, - tab: Option, -} - -impl From for Opt { - fn from(mut c: CmdCow) -> Self { - Self { url: c.take_first_url(), tab: c.get("tab").and_then(Data::as_id) } - } -} -impl From> for Opt { - fn from(url: Option) -> Self { Self { url, tab: None } } -} - -impl Mgr { - #[yazi_codegen::command] - pub fn hover(&mut self, opt: Opt) { - if let Some(u) = opt.url { - self.hover_do(u, opt.tab); - } else { - self.current_or_mut(opt.tab).arrow(0); - } - - // Refresh watcher - self.watch(()); - - // Publish through DDS - Pubsub::pub_from_hover(self.active().id, self.hovered().map(|h| &h.url)); - } - - fn hover_do(&mut self, url: Url, tab: Option) { - // Hover on the file - if let Ok(p) = url.strip_prefix(&self.current_or(tab).url) { - render!(self.current_or_mut(tab).hover(Urn::new(p))); - } - - // Turn on tracing - if self.current_or(tab).hovered().is_some_and(|h| h.url == url) { - // `hover(Some)` occurs after user actions, such as create, rename, reveal, etc. - // At this point, it's intuitive to track the location of the file regardless. - self.current_or_mut(tab).trace = Some(url.urn_owned()); - } - } -} diff --git a/yazi-core/src/mgr/commands/mod.rs b/yazi-core/src/mgr/commands/mod.rs index 6e673412..cf2735f8 100644 --- a/yazi-core/src/mgr/commands/mod.rs +++ b/yazi-core/src/mgr/commands/mod.rs @@ -3,7 +3,6 @@ yazi_macro::mod_flat!( close create hardlink - hover link open paste diff --git a/yazi-core/src/mgr/commands/refresh.rs b/yazi-core/src/mgr/commands/refresh.rs index cb165df3..12826927 100644 --- a/yazi-core/src/mgr/commands/refresh.rs +++ b/yazi-core/src/mgr/commands/refresh.rs @@ -21,8 +21,8 @@ impl Mgr { self.watcher.trigger_dirs(&[self.current()]); } - self.watch(()); self.peek(false); + self.watch(()); self.update_paged((), tasks); tasks.prework_sorted(&self.current().files); diff --git a/yazi-core/src/mgr/commands/update_files.rs b/yazi-core/src/mgr/commands/update_files.rs index cfd9dde0..e8754c93 100644 --- a/yazi-core/src/mgr/commands/update_files.rs +++ b/yazi-core/src/mgr/commands/update_files.rs @@ -30,10 +30,12 @@ impl Mgr { } render!(self.yanked.catchup_revision(false)); + self.active_mut().apply_files_attrs(); + if revision != self.current().files.revision { - self.active_mut().apply_files_attrs(); - self.hover(None); + self.active_mut().hover(None); self.peek(false); + self.watch(()); self.update_paged((), tasks); } } diff --git a/yazi-core/src/tab/commands/arrow.rs b/yazi-core/src/tab/commands/arrow.rs index b6f2c492..16ac035b 100644 --- a/yazi-core/src/tab/commands/arrow.rs +++ b/yazi-core/src/tab/commands/arrow.rs @@ -36,8 +36,10 @@ impl Tab { } } - MgrProxy::hover(None, self.id); + self.hover(None); MgrProxy::peek(false); + MgrProxy::watch(); + render!(); } } diff --git a/yazi-core/src/tab/commands/filter_do.rs b/yazi-core/src/tab/commands/filter_do.rs index b28de7a5..fefd4b5e 100644 --- a/yazi-core/src/tab/commands/filter_do.rs +++ b/yazi-core/src/tab/commands/filter_do.rs @@ -27,8 +27,9 @@ impl Tab { self.current.repos(hovered.as_ref()); if self.hovered().map(|f| f.urn()) != hovered.as_ref().map(|u| u.as_urn()) { - MgrProxy::hover(None, self.id); + self.hover(None); MgrProxy::peek(false); + MgrProxy::watch(); } render!(); diff --git a/yazi-core/src/tab/commands/hidden.rs b/yazi-core/src/tab/commands/hidden.rs index f199e25d..4af36605 100644 --- a/yazi-core/src/tab/commands/hidden.rs +++ b/yazi-core/src/tab/commands/hidden.rs @@ -15,8 +15,9 @@ impl Tab { self.apply_files_attrs(); if hovered.as_ref() != self.hovered().map(|f| &f.url) { - MgrProxy::hover(hovered, self.id); + self.hover(hovered); MgrProxy::peek(false); + MgrProxy::watch(); } else if self.hovered().is_some_and(|f| f.is_dir()) { MgrProxy::peek(true); } diff --git a/yazi-core/src/tab/commands/hover.rs b/yazi-core/src/tab/commands/hover.rs new file mode 100644 index 00000000..074dce9d --- /dev/null +++ b/yazi-core/src/tab/commands/hover.rs @@ -0,0 +1,44 @@ +use yazi_dds::Pubsub; +use yazi_macro::render; +use yazi_shared::{event::CmdCow, url::{Url, Urn}}; + +use crate::tab::Tab; + +struct Opt { + url: Option, +} + +impl From for Opt { + fn from(mut c: CmdCow) -> Self { Self { url: c.take_first_url() } } +} +impl From> for Opt { + fn from(url: Option) -> Self { Self { url } } +} + +impl Tab { + #[yazi_codegen::command] + pub fn hover(&mut self, opt: Opt) { + if let Some(u) = opt.url { + self.hover_do(u); + } else { + self.current.arrow(0); + } + + // Publish through DDS + Pubsub::pub_from_hover(self.id, self.hovered().map(|h| &h.url)); + } + + fn hover_do(&mut self, url: Url) { + // Hover on the file + if let Ok(p) = url.strip_prefix(self.cwd()) { + render!(self.current.hover(Urn::new(p))); + } + + // Turn on tracing + if self.hovered().is_some_and(|h| h.url == url) { + // `hover(Some)` occurs after user actions, such as create, rename, reveal, etc. + // At this point, it's intuitive to track the location of the file regardless. + self.current.trace = Some(url.urn_owned()); + } + } +} diff --git a/yazi-core/src/tab/commands/mod.rs b/yazi-core/src/tab/commands/mod.rs index 08f9a65d..e5f9291c 100644 --- a/yazi-core/src/tab/commands/mod.rs +++ b/yazi-core/src/tab/commands/mod.rs @@ -10,8 +10,10 @@ yazi_macro::mod_flat!( find find_arrow find_do + follow forward hidden + hover leave linemode reveal @@ -23,5 +25,4 @@ yazi_macro::mod_flat!( update_peeked update_spotted visual_mode - follow, ); diff --git a/yazi-core/src/tab/commands/reveal.rs b/yazi-core/src/tab/commands/reveal.rs index 1dcd6890..2578e002 100644 --- a/yazi-core/src/tab/commands/reveal.rs +++ b/yazi-core/src/tab/commands/reveal.rs @@ -25,14 +25,20 @@ impl From for Opt { impl Tab { #[yazi_codegen::command] pub fn reveal(&mut self, opt: Opt) { - let Some(parent) = opt.target.parent_url() else { + let Some((parent, child)) = opt.target.pair() else { return; }; self.cd(parent.clone()); - // TODO - FilesOp::Creating(parent, vec![File::from_dummy(opt.target.clone(), None)]).emit(); - MgrProxy::hover(Some(opt.target), self.id); + self.current.hover(child.as_urn()); + + if self.hovered().is_none_or(|f| &child != f.urn()) { + let op = FilesOp::Creating(parent, vec![File::from_dummy(opt.target.clone(), None)]); + self.current.update_pub(self.id, op); + } + + self.hover(Some(opt.target)); MgrProxy::peek(false); + MgrProxy::watch(); } } diff --git a/yazi-core/src/tab/commands/sort.rs b/yazi-core/src/tab/commands/sort.rs index d7d7fc17..a7abe2b5 100644 --- a/yazi-core/src/tab/commands/sort.rs +++ b/yazi-core/src/tab/commands/sort.rs @@ -19,11 +19,11 @@ impl Tab { pref.sort_translit = c.maybe_bool("translit").unwrap_or(pref.sort_translit); self.apply_files_attrs(); - - MgrProxy::hover(None, self.id); - MgrProxy::peek(false); - MgrProxy::update_paged(); - + self.hover(None); tasks.prework_sorted(&self.current.files); + + MgrProxy::peek(false); + MgrProxy::watch(); + MgrProxy::update_paged(); } } diff --git a/yazi-fm/src/app/commands/resize.rs b/yazi-fm/src/app/commands/resize.rs index e327f11b..2d2b2d5a 100644 --- a/yazi-fm/src/app/commands/resize.rs +++ b/yazi-fm/src/app/commands/resize.rs @@ -19,7 +19,7 @@ impl App { self.reflow(()); self.cx.current_mut().sync_page(true); - self.cx.mgr.hover(None); + self.cx.current_mut().arrow(0); self.cx.mgr.peek(false); self.cx.mgr.parent_mut().map(|f| f.arrow(0)); } diff --git a/yazi-fm/src/executor.rs b/yazi-fm/src/executor.rs index 1a0af89c..98119342 100644 --- a/yazi-fm/src/executor.rs +++ b/yazi-fm/src/executor.rs @@ -77,7 +77,6 @@ impl<'a> Executor<'a> { on!(MGR, update_mimes, &self.app.cx.tasks); on!(MGR, update_paged, &self.app.cx.tasks); on!(MGR, update_yanked); - on!(MGR, hover); on!(MGR, watch); on!(MGR, peek); on!(MGR, seek); diff --git a/yazi-proxy/src/mgr.rs b/yazi-proxy/src/mgr.rs index 793a75dd..7f7891da 100644 --- a/yazi-proxy/src/mgr.rs +++ b/yazi-proxy/src/mgr.rs @@ -1,5 +1,5 @@ use yazi_macro::emit; -use yazi_shared::{Id, event::Cmd, url::Url}; +use yazi_shared::{event::Cmd, url::Url}; use crate::options::OpenDoOpt; @@ -16,11 +16,6 @@ impl MgrProxy { emit!(Call(Cmd::new("mgr:peek").with_bool("force", force))); } - #[inline] - pub fn hover(url: Option, tab: Id) { - emit!(Call(Cmd::args("mgr:hover", &url.map_or_else(Vec::new, |u| vec![u])).with("tab", tab))); - } - #[inline] pub fn watch() { emit!(Call(Cmd::new("mgr:watch")));