Skip to content

Commit

Permalink
feat!: support passing arguments to previewer/preloader/spotter/fetch…
Browse files Browse the repository at this point in the history
…er (#1966)
  • Loading branch information
sxyazi committed Nov 29, 2024
1 parent 37292ad commit 43473db
Show file tree
Hide file tree
Showing 54 changed files with 631 additions and 438 deletions.
40 changes: 20 additions & 20 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ crossterm = { version = "0.28.1", features = [ "event-stream" ] }
dirs = "5.0.1"
futures = "0.3.31"
globset = "0.4.15"
libc = "0.2.164"
libc = "0.2.166"
md-5 = "0.10.6"
mlua = { version = "0.10.1", features = [ "anyhow", "async", "error-send", "lua54", "macros", "serialize" ] }
parking_lot = "0.12.3"
Expand All @@ -32,6 +32,6 @@ shell-words = "1.1.0"
tokio = { version = "1.41.1", features = [ "full" ] }
tokio-stream = "0.1.16"
tokio-util = "0.7.12"
tracing = { version = "0.1.40", features = [ "max_level_debug", "release_max_level_debug" ] }
tracing = { version = "0.1.41", features = [ "max_level_debug", "release_max_level_debug" ] }
unicode-width = "0.2.0"
uzers = "0.12.1"
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ https://github.com/sxyazi/yazi/assets/17523360/92ff23fa-0cd5-4f04-b387-894c12265
| [Tabby](https://github.com/Eugeny/tabby) | [Inline images protocol][iip] | ✅ Built-in |
| [VSCode](https://github.com/microsoft/vscode) | [Inline images protocol][iip] | ✅ Built-in |
| [Rio](https://github.com/raphamorim/rio) | [Inline images protocol][iip] | ❌ Rio doesn't correctly clear images (#1786) |
| [Mintty](https://github.com/mintty/mintty) (Git Bash) | [Inline images protocol][iip] | ✅ Built-in |
| [Black Box](https://gitlab.gnome.org/raggesilver/blackbox) | [Sixel graphics format][sixel] | ✅ Built-in |
| [Hyper](https://github.com/vercel/hyper) | [Inline images protocol][iip] | ✅ Built-in |
| X11 / Wayland | Window system protocol | ☑️ [Überzug++][ueberzug] required |
Expand Down
2 changes: 1 addition & 1 deletion yazi-boot/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,4 @@ clap = { workspace = true }
clap_complete = "4.5.38"
clap_complete_fig = "4.5.2"
clap_complete_nushell = "4.5.4"
vergen-gitcl = { version = "1.0.1", features = [ "build", "rustc" ] }
vergen-gitcl = { version = "1.0.2", features = [ "build", "rustc" ] }
2 changes: 1 addition & 1 deletion yazi-cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ clap_complete = "4.5.38"
clap_complete_fig = "4.5.2"
clap_complete_nushell = "4.5.4"
serde_json = { workspace = true }
vergen-gitcl = { version = "1.0.1", features = [ "build" ] }
vergen-gitcl = { version = "1.0.2", features = [ "build" ] }

[target.'cfg(target_os = "macos")'.dependencies]
crossterm = { workspace = true, features = [ "use-dev-tty", "libc" ] }
Expand Down
8 changes: 4 additions & 4 deletions yazi-config/src/keymap/cow.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use std::{collections::VecDeque, ops::Deref};
use std::ops::Deref;

use yazi_shared::event::CmdCow;

Expand Down Expand Up @@ -34,10 +34,10 @@ impl Default for ChordCow {
}

impl ChordCow {
pub fn into_seq(self) -> VecDeque<CmdCow> {
pub fn into_seq(self) -> Vec<CmdCow> {
match self {
Self::Owned(c) => c.run.into_iter().map(|c| c.into()).collect(),
Self::Borrowed(c) => c.run.iter().map(|c| c.into()).collect(),
Self::Owned(c) => c.run.into_iter().rev().map(|c| c.into()).collect(),
Self::Borrowed(c) => c.run.iter().rev().map(|c| c.into()).collect(),
}
}
}
13 changes: 0 additions & 13 deletions yazi-config/src/plugin/fetcher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,3 @@ impl Fetcher {
|| self.name.as_ref().is_some_and(|p| p.match_path(path, mime == MIME_DIR)))
}
}

#[derive(Debug, Clone)]
pub struct FetcherProps {
pub id: u8,
pub name: &'static str,
pub prio: Priority,
}

impl From<&'static Fetcher> for FetcherProps {
fn from(fetcher: &'static Fetcher) -> Self {
Self { id: fetcher.idx, name: &fetcher.run.name, prio: fetcher.prio }
}
}
13 changes: 0 additions & 13 deletions yazi-config/src/plugin/preloader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,3 @@ impl Preloader {
|| self.name.as_ref().is_some_and(|p| p.match_path(path, mime == MIME_DIR))
}
}

#[derive(Debug, Clone)]
pub struct PreloaderProps {
pub id: u8,
pub name: &'static str,
pub prio: Priority,
}

impl From<&'static Preloader> for PreloaderProps {
fn from(preloader: &'static Preloader) -> Self {
Self { id: preloader.idx, name: &preloader.run.name, prio: preloader.prio }
}
}
4 changes: 2 additions & 2 deletions yazi-core/src/manager/commands/open.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use yazi_fs::Folder;
use yazi_macro::emit;
use yazi_plugin::isolate;
use yazi_proxy::{ManagerProxy, TasksProxy, options::OpenDoOpt};
use yazi_shared::{MIME_DIR, event::{CmdCow, EventQuit}, fs::{File, Url}};
use yazi_shared::{MIME_DIR, event::{Cmd, CmdCow, EventQuit}, fs::{File, Url}};

use crate::{manager::Manager, tasks::Tasks};

Expand Down Expand Up @@ -65,7 +65,7 @@ impl Manager {
}

done.extend(files.iter().map(|f| (f.url_owned(), String::new())));
if let Err(e) = isolate::fetch("mime", files).await {
if let Err(e) = isolate::fetch(Cmd::new("mime").into(), files).await {
error!("Fetch `mime` failed in opening: {e}");
}

Expand Down
6 changes: 3 additions & 3 deletions yazi-core/src/manager/commands/update_mimes.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use std::collections::HashMap;
use std::{borrow::Cow, collections::HashMap};

use tracing::error;
use yazi_macro::render;
Expand All @@ -7,7 +7,7 @@ use yazi_shared::{event::CmdCow, fs::Url};
use crate::{manager::{LINKED, Manager}, tasks::Tasks};

pub struct Opt {
updates: HashMap<String, String>,
updates: HashMap<Cow<'static, str>, String>,
}

impl TryFrom<CmdCow> for Opt {
Expand All @@ -28,7 +28,7 @@ impl Manager {
let updates = opt
.updates
.into_iter()
.map(|(url, mime)| (Url::from(url), mime))
.map(|(url, mime)| (Url::from(url.into_owned()), mime))
.filter(|(url, mime)| self.mimetype.get(url) != Some(mime))
.fold(HashMap::new(), |mut map, (u, m)| {
for u in linked.from_file(&u) {
Expand Down
4 changes: 2 additions & 2 deletions yazi-core/src/manager/watcher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use tracing::error;
use yazi_fs::{Files, Folder};
use yazi_plugin::isolate;
use yazi_proxy::WATCHER;
use yazi_shared::{RoCell, fs::{Cha, File, FilesOp, Url, realname_unchecked}};
use yazi_shared::{RoCell, event::Cmd, fs::{Cha, File, FilesOp, Url, realname_unchecked}};

use super::Linked;

Expand Down Expand Up @@ -151,7 +151,7 @@ impl Watcher {
}

FilesOp::mutate(ops);
if let Err(e) = isolate::fetch("mime", reload).await {
if let Err(e) = isolate::fetch(Cmd::new("mime").into(), reload).await {
error!("Fetch `mime` failed in watcher: {e}");
}
}
Expand Down
2 changes: 1 addition & 1 deletion yazi-core/src/tab/commands/escape.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ bitflags! {
impl From<CmdCow> for Opt {
fn from(c: CmdCow) -> Self {
c.args.iter().fold(Opt::empty(), |acc, (k, v)| {
match (k.as_str(), v.as_bool().unwrap_or(false)) {
match (k.as_str().unwrap_or(""), v.as_bool().unwrap_or(false)) {
("all", true) => Self::all(),
("find", true) => acc | Self::FIND,
("visual", true) => acc | Self::VISUAL,
Expand Down
10 changes: 3 additions & 7 deletions yazi-core/src/tasks/plugin.rs
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
use yazi_shared::event::Data;
use yazi_proxy::options::PluginOpt;

use super::Tasks;

impl Tasks {
#[inline]
pub fn plugin_micro(&self, name: String, args: Vec<Data>) {
self.scheduler.plugin_micro(name, args);
}
pub fn plugin_micro(&self, opt: PluginOpt) { self.scheduler.plugin_micro(opt); }

#[inline]
pub fn plugin_macro(&self, name: String, args: Vec<Data>) {
self.scheduler.plugin_macro(name, args);
}
pub fn plugin_macro(&self, opt: PluginOpt) { self.scheduler.plugin_macro(opt); }
}
1 change: 1 addition & 0 deletions yazi-core/src/tasks/preload.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ impl Tasks {
let mime = if f.is_dir() { MIME_DIR } else { mimetype.get(&f.url).unwrap_or_default() };
let factors = |s: &str| match s {
"mime" => !mime.is_empty(),
"dummy" => f.cha.is_dummy(),
_ => false,
};

Expand Down
2 changes: 1 addition & 1 deletion yazi-dds/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ tokio-util = { workspace = true }
tracing = { workspace = true }

[build-dependencies]
vergen-gitcl = { version = "1.0.1", features = [ "build" ] }
vergen-gitcl = { version = "1.0.2", features = [ "build" ] }

[target."cfg(unix)".dependencies]
uzers = { workspace = true }
1 change: 1 addition & 0 deletions yazi-dds/src/body/yank.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ impl IntoLua for BodyYank<'static> {
}

// --- Iterator
#[derive(Clone)]
pub struct BodyYankIter {
pub cut: bool,
pub urls: Vec<Url>,
Expand Down
Loading

0 comments on commit 43473db

Please sign in to comment.