Skip to content

Commit 60a2382

Browse files
committed
refactor: switch to actor model (#2986)
1 parent 6366e46 commit 60a2382

File tree

337 files changed

+4137
-3024
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

337 files changed

+4137
-3024
lines changed

Cargo.lock

Lines changed: 50 additions & 27 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ syntect = { version = "5.2.0", default-features = false, features =
4848
tokio = { version = "1.46.1", features = [ "full" ] }
4949
tokio-stream = "0.1.17"
5050
tokio-util = "0.7.15"
51-
toml = { version = "0.9.1" }
51+
toml = { version = "0.9.2" }
5252
tracing = { version = "0.1.41", features = [ "max_level_debug", "release_max_level_debug" ] }
5353
twox-hash = { version = "2.1.1", default-features = false, features = [ "std", "random", "xxhash3_128" ] }
5454
unicode-width = { version = "0.2.0", default-features = false }

yazi-actor/Cargo.toml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
[package]
2+
name = "yazi-actor"
3+
version = "25.6.11"
4+
edition = "2024"
5+
license = "MIT"
6+
authors = [ "sxyazi <[email protected]>" ]
7+
description = "Yazi actor model"
8+
homepage = "https://yazi-rs.github.io"
9+
repository = "https://github.com/sxyazi/yazi"
10+
11+
[dependencies]
12+
yazi-boot = { path = "../yazi-boot", version = "25.6.11" }
13+
yazi-config = { path = "../yazi-config", version = "25.6.11" }
14+
yazi-core = { path = "../yazi-core", version = "25.6.11" }
15+
yazi-dds = { path = "../yazi-dds", version = "25.6.11" }
16+
yazi-fs = { path = "../yazi-fs", version = "25.6.11" }
17+
yazi-macro = { path = "../yazi-macro", version = "25.6.11" }
18+
yazi-parser = { path = "../yazi-parser", version = "25.6.11" }
19+
yazi-plugin = { path = "../yazi-plugin", version = "25.6.11" }
20+
yazi-proxy = { path = "../yazi-proxy", version = "25.6.11" }
21+
yazi-shared = { path = "../yazi-shared", version = "25.6.11" }
22+
yazi-term = { path = "../yazi-term", version = "25.6.11" }
23+
yazi-widgets = { path = "../yazi-widgets", version = "25.6.11" }
24+
25+
# External dependencies
26+
anyhow = { workspace = true }
27+
crossterm = { workspace = true }
28+
futures = { workspace = true }
29+
paste = { workspace = true }
30+
scopeguard = { workspace = true }
31+
tokio = { workspace = true }
32+
tokio-stream = { workspace = true }
33+
tracing = { workspace = true }
34+
35+
[target."cfg(unix)".dependencies]
36+
libc = { workspace = true }
37+
38+
[target.'cfg(target_os = "macos")'.dependencies]
39+
crossterm = { workspace = true, features = [ "use-dev-tty", "libc" ] }

yazi-actor/src/actor.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
use anyhow::Result;
2+
use yazi_shared::event::Data;
3+
4+
use crate::Ctx;
5+
6+
pub trait Actor {
7+
type Options;
8+
9+
const NAME: &'static str;
10+
11+
fn act(cx: &mut Ctx, opt: Self::Options) -> Result<Data>;
12+
}

yazi-actor/src/cmp/arrow.rs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
use anyhow::Result;
2+
use yazi_macro::{render, succ};
3+
use yazi_parser::ArrowOpt;
4+
use yazi_shared::event::Data;
5+
use yazi_widgets::Scrollable;
6+
7+
use crate::{Actor, Ctx};
8+
9+
pub struct Arrow;
10+
11+
impl Actor for Arrow {
12+
type Options = ArrowOpt;
13+
14+
const NAME: &'static str = "arrow";
15+
16+
fn act(cx: &mut Ctx, opt: Self::Options) -> Result<Data> {
17+
succ!(render!(cx.cmp.scroll(opt.step)));
18+
}
19+
}

yazi-actor/src/cmp/close.rs

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
use std::mem;
2+
3+
use anyhow::Result;
4+
use yazi_macro::{act, render, succ};
5+
use yazi_parser::{cmp::CloseOpt, input::CompleteOpt};
6+
use yazi_shared::event::Data;
7+
8+
use crate::{Actor, Ctx};
9+
10+
pub struct Close;
11+
12+
impl Actor for Close {
13+
type Options = CloseOpt;
14+
15+
const NAME: &'static str = "close";
16+
17+
fn act(cx: &mut Ctx, opt: Self::Options) -> Result<Data> {
18+
let cmp = &mut cx.core.cmp;
19+
if let Some(item) = cmp.selected().filter(|_| opt.submit).cloned() {
20+
return act!(complete, cx.core.input, CompleteOpt { item, _ticket: cmp.ticket });
21+
}
22+
23+
cmp.caches.clear();
24+
succ!(render!(mem::replace(&mut cmp.visible, false)));
25+
}
26+
}
File renamed without changes.

0 commit comments

Comments
 (0)