mirror of
https://github.com/sxyazi/yazi.git
synced 2026-07-25 08:41:05 +00:00
..
This commit is contained in:
parent
1bc6949a7c
commit
7ed302db6c
9 changed files with 29 additions and 29 deletions
|
|
@ -12,7 +12,7 @@ Yazi (means "duck") is a terminal file manager written in Rust, based on non-blo
|
|||
- 💪 **Powerful Async Task Scheduling and Management**: Provides real-time progress updates, task cancellation, and internal task priority assignment.
|
||||
- 🖼️ **Built-in Support for Multiple Image Protocols**: Also integrated with Überzug++, covering almost all terminals.
|
||||
- 🌟 **Built-in Code Highlighting and Image Decoding**: Combined with the pre-loading mechanism, greatly accelerates image and normal file loading.
|
||||
- 🔌 **Concurrent Plugin System**: UI plugins (rewriting most of the UI), functional plugins, custom previewer, and custom preloader; Just some pieces of Lua.
|
||||
- 🔌 **Concurrent Plugin System**: UI plugins (rewriting most of the UI), functional plugins, custom previewer/preloader/prefetcher; Just some pieces of Lua.
|
||||
- 📡 **Data Distribution Service**: Built on a client-server architecture (no additional server process required), integrated with a Lua-based publish-subscribe model, achieving cross-instance communication and state persistence.
|
||||
- 📦 **Package Manager**: Install plugins and themes with one command, keeping them always up to date, or pin them to a specific version.
|
||||
- 🧰 Integration with fd, rg, fzf, zoxide
|
||||
|
|
|
|||
|
|
@ -57,11 +57,11 @@ impl Default for Plugin {
|
|||
panic!("Prefetchers and preloaders exceed the limit of {MAX_PREWORKERS}");
|
||||
}
|
||||
|
||||
for (i, preloader) in shadow.prefetchers.iter_mut().enumerate() {
|
||||
preloader.id = i as u8;
|
||||
for (i, p) in shadow.prefetchers.iter_mut().enumerate() {
|
||||
p.id = i as u8;
|
||||
}
|
||||
for (i, preloader) in shadow.preloaders.iter_mut().enumerate() {
|
||||
preloader.id = shadow.prefetchers.len() as u8 + i as u8;
|
||||
for (i, p) in shadow.preloaders.iter_mut().enumerate() {
|
||||
p.id = shadow.prefetchers.len() as u8 + i as u8;
|
||||
}
|
||||
|
||||
Self {
|
||||
|
|
|
|||
|
|
@ -64,7 +64,7 @@ impl Manager {
|
|||
|
||||
done.extend(files.iter().map(|f| (f.url(), String::new())));
|
||||
if let Err(e) = isolate::prefetch("mime", files).await {
|
||||
error!("preload in open failed: {e}");
|
||||
error!("prefetch `mime` failed in opening: {e}");
|
||||
}
|
||||
|
||||
ManagerProxy::open_do(OpenDoOpt { hovered, targets: done, interactive: opt.interactive });
|
||||
|
|
|
|||
|
|
@ -118,7 +118,7 @@ impl Watcher {
|
|||
continue;
|
||||
}
|
||||
if let Err(e) = isolate::prefetch("mime", reload).await {
|
||||
error!("preload in watcher failed: {e}");
|
||||
error!("prefetch `mime` failed in watcher: {e}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -84,6 +84,6 @@ impl Tasks {
|
|||
loading.insert(target.clone());
|
||||
}
|
||||
|
||||
self.scheduler.preload_size(targets);
|
||||
self.scheduler.prework_size(targets);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ use crate::{file::FileOp, plugin::PluginOp, preload::PreworkOp};
|
|||
pub enum TaskOp {
|
||||
File(Box<FileOp>),
|
||||
Plugin(Box<PluginOp>),
|
||||
Preload(Box<PreworkOp>),
|
||||
Prework(Box<PreworkOp>),
|
||||
}
|
||||
|
||||
impl TaskOp {
|
||||
|
|
@ -12,7 +12,7 @@ impl TaskOp {
|
|||
match self {
|
||||
TaskOp::File(op) => op.id(),
|
||||
TaskOp::Plugin(op) => op.id(),
|
||||
TaskOp::Preload(op) => op.id(),
|
||||
TaskOp::Prework(op) => op.id(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -26,5 +26,5 @@ impl From<PluginOp> for TaskOp {
|
|||
}
|
||||
|
||||
impl From<PreworkOp> for TaskOp {
|
||||
fn from(op: PreworkOp) -> Self { Self::Preload(Box::new(op)) }
|
||||
fn from(op: PreworkOp) -> Self { Self::Prework(Box::new(op)) }
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,9 +5,9 @@ use yazi_shared::{fs::Url, Throttle};
|
|||
|
||||
#[derive(Debug)]
|
||||
pub enum PreworkOp {
|
||||
Fetch(PreloadOpFetch),
|
||||
Load(PreloadOpLoad),
|
||||
Size(PreloadOpSize),
|
||||
Fetch(PreworkOpFetch),
|
||||
Load(PreworkOpLoad),
|
||||
Size(PreworkOpSize),
|
||||
}
|
||||
|
||||
impl PreworkOp {
|
||||
|
|
@ -21,21 +21,21 @@ impl PreworkOp {
|
|||
}
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct PreloadOpFetch {
|
||||
pub struct PreworkOpFetch {
|
||||
pub id: usize,
|
||||
pub plugin: PrefetcherProps,
|
||||
pub targets: Vec<yazi_shared::fs::File>,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct PreloadOpLoad {
|
||||
pub struct PreworkOpLoad {
|
||||
pub id: usize,
|
||||
pub plugin: PreloaderProps,
|
||||
pub target: yazi_shared::fs::File,
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct PreloadOpSize {
|
||||
pub struct PreworkOpSize {
|
||||
pub id: usize,
|
||||
pub target: Url,
|
||||
pub throttle: Arc<Throttle<(Url, u64)>>,
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ use yazi_config::Priority;
|
|||
use yazi_plugin::isolate;
|
||||
use yazi_shared::fs::{calculate_size, FilesOp, Url};
|
||||
|
||||
use super::{PreloadOpFetch, PreloadOpLoad, PreloadOpSize, PreworkOp};
|
||||
use super::{PreworkOp, PreworkOpFetch, PreworkOpLoad, PreworkOpSize};
|
||||
use crate::{TaskOp, TaskProg, HIGH, NORMAL};
|
||||
|
||||
pub struct Prework {
|
||||
|
|
@ -86,7 +86,7 @@ impl Prework {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
pub async fn fetch(&self, task: PreloadOpFetch) -> Result<()> {
|
||||
pub async fn fetch(&self, task: PreworkOpFetch) -> Result<()> {
|
||||
let id = task.id;
|
||||
self.prog.send(TaskProg::New(id, 0))?;
|
||||
|
||||
|
|
@ -98,7 +98,7 @@ impl Prework {
|
|||
self.succ(id)
|
||||
}
|
||||
|
||||
pub async fn load(&self, task: PreloadOpLoad) -> Result<()> {
|
||||
pub async fn load(&self, task: PreworkOpLoad) -> Result<()> {
|
||||
let id = task.id;
|
||||
self.prog.send(TaskProg::New(id, 0))?;
|
||||
|
||||
|
|
@ -110,7 +110,7 @@ impl Prework {
|
|||
self.succ(id)
|
||||
}
|
||||
|
||||
pub async fn size(&self, task: PreloadOpSize) -> Result<()> {
|
||||
pub async fn size(&self, task: PreworkOpSize) -> Result<()> {
|
||||
let id = task.id;
|
||||
|
||||
self.prog.send(TaskProg::New(id, 0))?;
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ use yazi_dds::Pump;
|
|||
use yazi_shared::{event::Data, fs::{unique_path, Url}, Throttle};
|
||||
|
||||
use super::{Ongoing, TaskProg, TaskStage};
|
||||
use crate::{file::{File, FileOpDelete, FileOpLink, FileOpPaste, FileOpTrash}, plugin::{Plugin, PluginOpEntry}, preload::{PreloadOpFetch, PreloadOpLoad, PreloadOpSize, Prework}, process::{Process, ProcessOpBg, ProcessOpBlock, ProcessOpOrphan}, TaskKind, TaskOp, HIGH, LOW, NORMAL};
|
||||
use crate::{file::{File, FileOpDelete, FileOpLink, FileOpPaste, FileOpTrash}, plugin::{Plugin, PluginOpEntry}, preload::{Prework, PreworkOpFetch, PreworkOpLoad, PreworkOpSize}, process::{Process, ProcessOpBg, ProcessOpBlock, ProcessOpOrphan}, TaskKind, TaskOp, HIGH, LOW, NORMAL};
|
||||
|
||||
pub struct Scheduler {
|
||||
pub file: Arc<File>,
|
||||
|
|
@ -228,7 +228,7 @@ impl Scheduler {
|
|||
let prework = self.prework.clone();
|
||||
_ = self.micro.try_send(
|
||||
async move {
|
||||
prework.fetch(PreloadOpFetch { id, plugin, targets }).await.ok();
|
||||
prework.fetch(PreworkOpFetch { id, plugin, targets }).await.ok();
|
||||
}
|
||||
.boxed(),
|
||||
NORMAL,
|
||||
|
|
@ -244,14 +244,14 @@ impl Scheduler {
|
|||
let prework = self.prework.clone();
|
||||
_ = self.micro.try_send(
|
||||
async move {
|
||||
prework.load(PreloadOpLoad { id, plugin, target }).await.ok();
|
||||
prework.load(PreworkOpLoad { id, plugin, target }).await.ok();
|
||||
}
|
||||
.boxed(),
|
||||
NORMAL,
|
||||
);
|
||||
}
|
||||
|
||||
pub fn preload_size(&self, targets: Vec<&Url>) {
|
||||
pub fn prework_size(&self, targets: Vec<&Url>) {
|
||||
let throttle = Arc::new(Throttle::new(targets.len(), Duration::from_millis(300)));
|
||||
let mut ongoing = self.ongoing.lock();
|
||||
|
||||
|
|
@ -260,10 +260,10 @@ impl Scheduler {
|
|||
let target = target.clone();
|
||||
let throttle = throttle.clone();
|
||||
|
||||
let preload = self.prework.clone();
|
||||
let prework = self.prework.clone();
|
||||
_ = self.micro.try_send(
|
||||
async move {
|
||||
preload.size(PreloadOpSize { id, target, throttle }).await.ok();
|
||||
prework.size(PreworkOpSize { id, target, throttle }).await.ok();
|
||||
}
|
||||
.boxed(),
|
||||
NORMAL,
|
||||
|
|
@ -344,7 +344,7 @@ impl Scheduler {
|
|||
) -> JoinHandle<()> {
|
||||
let file = self.file.clone();
|
||||
let plugin = self.plugin.clone();
|
||||
let preload = self.prework.clone();
|
||||
let prework = self.prework.clone();
|
||||
|
||||
let prog = self.prog.clone();
|
||||
let ongoing = self.ongoing.clone();
|
||||
|
|
@ -364,7 +364,7 @@ impl Scheduler {
|
|||
let result = match op {
|
||||
TaskOp::File(op) => file.work(*op).await,
|
||||
TaskOp::Plugin(op) => plugin.work(*op).await,
|
||||
TaskOp::Preload(op) => preload.work(*op).await,
|
||||
TaskOp::Prework(op) => prework.work(*op).await,
|
||||
};
|
||||
|
||||
if let Err(e) = result {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue