Skip to content

Commit 573027d

Browse files
committed
feat: new app:theme action that hot-reload user themes/flavors (#3906)
1 parent 369c475 commit 573027d

105 files changed

Lines changed: 766 additions & 390 deletions

Some content is hidden

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

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/):
1818
- New `--in` for `search` action to set search directory ([#3696])
1919
- Hover cursor over the new file after copying/cutting/linking/hardlinking/extracting ([#3846], [#3854])
2020
- Multi-file spotter ([#3733])
21+
- New `app:theme` action that hot-reload user themes/flavors ([#3906])
2122
- Dynamic open/opener Lua API ([#3901])
2223
- Dynamic previewer Lua API ([#3891])
2324
- Vim-like `lua` action that runs an inline Lua snippet ([#3813])
@@ -1705,3 +1706,4 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/):
17051706
[#3891]: https://github.com/sxyazi/yazi/pull/3891
17061707
[#3894]: https://github.com/sxyazi/yazi/pull/3894
17071708
[#3901]: https://github.com/sxyazi/yazi/pull/3901
1709+
[#3906]: https://github.com/sxyazi/yazi/pull/3906

Cargo.lock

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

Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ license = "MIT"
1010
authors = [ "sxyazi <sxyazi@gmail.com>" ]
1111
homepage = "https://yazi-rs.github.io"
1212
repository = "https://github.com/sxyazi/yazi"
13-
rust-version = "1.92.0"
13+
rust-version = "1.95.0"
1414

1515
[profile.dev]
1616
debug = "line-tables-only"
@@ -63,7 +63,7 @@ percent-encoding = "2.3.2"
6363
rand = { version = "0.10.1", default-features = false, features = [ "std", "sys_rng" ] }
6464
ratatui = { version = "0.30.0", features = [ "serde", "unstable-rendered-line-info", "unstable-widget-ref" ] }
6565
regex = "1.12.3"
66-
russh = { version = "0.60.0", default-features = false, features = [ "ring", "rsa" ] }
66+
russh = { version = "0.60.1", default-features = false, features = [ "ring", "rsa" ] }
6767
scopeguard = "1.2.0"
6868
serde = { version = "1.0.228", features = [ "derive" ] }
6969
serde_json = "1.0.149"

flake.lock

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

yazi-actor/src/app/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ yazi_macro::mod_flat!(
1212
resize
1313
resume
1414
stop
15+
theme
1516
title
1617
update_progress
1718
);

yazi-actor/src/app/theme.rs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
use anyhow::Result;
2+
use yazi_actor::Ctx;
3+
use yazi_config::{THEME, build_flavor};
4+
use yazi_emulator::EMULATOR;
5+
use yazi_macro::{render, succ};
6+
use yazi_parser::VoidForm;
7+
use yazi_shared::data::Data;
8+
use yazi_shim::serde::Overlay;
9+
10+
use crate::Actor;
11+
12+
pub struct Theme;
13+
14+
impl Actor for Theme {
15+
type Form = VoidForm;
16+
17+
const NAME: &str = "theme";
18+
19+
fn act(_cx: &mut Ctx, _: Self::Form) -> Result<Data> {
20+
THEME.overlay(build_flavor(EMULATOR.light, true)?);
21+
yazi_plugin::theme::reset()?;
22+
23+
succ!(render!());
24+
}
25+
}

yazi-actor/src/lives/file.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use std::{ops::Deref, ptr};
22

33
use mlua::{AnyUserData, IntoLua, UserData, UserDataFields, UserDataMethods, Value};
44
use yazi_binding::{Range, Style, cached_field};
5-
use yazi_config::{Selectable, THEME};
5+
use yazi_config::THEME;
66
use yazi_shared::{path::AsPath, url::UrlLike};
77

88
use super::Lives;
@@ -111,7 +111,7 @@ impl UserData for File {
111111
methods.add_method("style", |lua, me, ()| {
112112
lua.named_registry_value::<AnyUserData>("cx")?.borrow_scoped(|core: &yazi_core::Core| {
113113
let mime = core.mgr.mimetype.get(&me.url).unwrap_or_default();
114-
THEME.filetype.iter().find(|&x| x.matches(me, mime)).map(|x| Style::from(x.style))
114+
THEME.filetype.match_style(me, mime).map(Style::from)
115115
})
116116
});
117117
methods.add_method("is_yanked", |lua, me, ()| {

yazi-actor/src/lives/lives.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use mlua::{AnyUserData, UserData};
55
use scopeguard::defer;
66
use tracing::error;
77
use yazi_plugin::LUA;
8-
use yazi_shared::RoCell;
8+
use yazi_shim::cell::RoCell;
99

1010
use super::{Core, PtrCell};
1111

yazi-actor/src/lives/preference.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ impl UserData for Preference {
3838
fn add_fields<F: UserDataFields<Self>>(fields: &mut F) {
3939
// Display
4040
cached_field!(fields, name, |lua, me| lua.create_string(&me.name));
41-
cached_field!(fields, linemode, |lua, me| lua.create_string(&me.linemode));
41+
cached_field!(fields, linemode, |lua, me| lua.create_string(&*me.linemode));
4242
fields.add_field_method_get("show_hidden", |_, me| Ok(me.show_hidden));
4343

4444
// Sorting

yazi-actor/src/mgr/linemode.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ impl Actor for Linemode {
1515
fn act(cx: &mut Ctx, form: Self::Form) -> Result<Data> {
1616
let tab = cx.tab_mut();
1717

18-
if form.new != tab.pref.linemode {
19-
tab.pref.linemode = form.new.into_owned();
18+
if form.new != *tab.pref.linemode {
19+
tab.pref.linemode = form.new.into();
2020
render!();
2121
}
2222

0 commit comments

Comments
 (0)