From 89d4ceb5bb94ddaae74b2f8c8042e4fdcdbb1877 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=89=E5=92=B2=E9=9B=85=20=C2=B7=20Misaki=20Masa?= Date: Tue, 11 Feb 2025 16:56:46 +0800 Subject: [PATCH] feat: new `overall` option under `[status]` to allow specifying the overall style of the status bar (#2321) --- Cargo.lock | 20 ++++++++++---------- yazi-config/preset/theme-dark.toml | 1 + yazi-config/preset/theme-light.toml | 1 + yazi-config/src/theme/theme.rs | 1 + yazi-plugin/preset/components/status.lua | 5 +++-- yazi-plugin/src/elements/rect.rs | 5 +++++ yazi-plugin/src/loader/loader.rs | 2 +- 7 files changed, 22 insertions(+), 13 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index ef31a48a..1b984b5a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -283,9 +283,9 @@ dependencies = [ [[package]] name = "built" -version = "0.7.5" +version = "0.7.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c360505aed52b7ec96a3636c3f039d99103c37d1d9b4f7a8c743d3ea9ffcd03b" +checksum = "73848a43c5d63a1251d17adf6c2bf78aa94830e60a335a95eeea45d6ba9e1e4d" [[package]] name = "bumpalo" @@ -334,9 +334,9 @@ dependencies = [ [[package]] name = "cc" -version = "1.2.12" +version = "1.2.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "755717a7de9ec452bf7f3f1a3099085deabd7f2962b861dae91ecd7a365903d2" +checksum = "c7777341816418c02e033934a09f20dc0ccaf65a5201ef8a450ae0105a573fda" dependencies = [ "jobserver", "libc", @@ -803,9 +803,9 @@ dependencies = [ [[package]] name = "filedescriptor" -version = "0.8.2" +version = "0.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7199d965852c3bac31f779ef99cbb4537f80e952e2d6aa0ffeb30cce00f4f46e" +checksum = "e40758ed24c9b2eeb76c35fb0aebc66c626084edd827e07e1552279814c6682d" dependencies = [ "libc", "thiserror 1.0.69", @@ -2712,9 +2712,9 @@ dependencies = [ [[package]] name = "toml_edit" -version = "0.22.23" +version = "0.22.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "02a8b472d1a3d7c18e2d61a489aee3453fd9031c33e4f55bd533f4a7adca1bee" +checksum = "17b4795ff5edd201c7cd6dca065ae59972ce77d1b80fa0a84d94950ece7d1474" dependencies = [ "indexmap", "serde", @@ -3288,9 +3288,9 @@ checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" [[package]] name = "winnow" -version = "0.7.1" +version = "0.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "86e376c75f4f43f44db463cf729e0d3acbf954d13e22c51e26e4c264b4ab545f" +checksum = "59690dea168f2198d1a3b0cac23b8063efcd11012f10ae4698f284808c8ef603" dependencies = [ "memchr", ] diff --git a/yazi-config/preset/theme-dark.toml b/yazi-config/preset/theme-dark.toml index d2075321..3f78337d 100644 --- a/yazi-config/preset/theme-dark.toml +++ b/yazi-config/preset/theme-dark.toml @@ -76,6 +76,7 @@ unset_alt = { fg = "red", bg = "gray" } # : Status bar {{{ [status] +overall = {} separator_open = "" separator_close = "" diff --git a/yazi-config/preset/theme-light.toml b/yazi-config/preset/theme-light.toml index e7fd295f..5178746f 100644 --- a/yazi-config/preset/theme-light.toml +++ b/yazi-config/preset/theme-light.toml @@ -76,6 +76,7 @@ unset_alt = { fg = "red", bg = "gray" } # : Status bar {{{ [status] +overall = {} separator_open = "" separator_close = "" diff --git a/yazi-config/src/theme/theme.rs b/yazi-config/src/theme/theme.rs index cb7ddfd3..c2da1434 100644 --- a/yazi-config/src/theme/theme.rs +++ b/yazi-config/src/theme/theme.rs @@ -93,6 +93,7 @@ struct Mode { #[derive(Deserialize, Serialize)] struct Status { + pub overall: Style, pub separator_open: String, pub separator_close: String, diff --git a/yazi-plugin/preset/components/status.lua b/yazi-plugin/preset/components/status.lua index d4727bf0..8eb289d8 100644 --- a/yazi-plugin/preset/components/status.lua +++ b/yazi-plugin/preset/components/status.lua @@ -40,7 +40,7 @@ function Status:mode() local style = self:style() return ui.Line { - ui.Span(THEME.status.separator_open):fg(style.main.bg), + ui.Span(THEME.status.separator_open):fg(style.main.bg):bg("reset"), ui.Span(" " .. mode .. " "):style(style.main), ui.Span(THEME.status.separator_close):fg(style.main.bg):bg(style.alt.bg), } @@ -128,7 +128,7 @@ function Status:position() return ui.Line { ui.Span(THEME.status.separator_open):fg(style.main.bg):bg(style.alt.bg), ui.Span(string.format(" %2d/%-2d ", math.min(cursor + 1, length), length)):style(style.main), - ui.Span(THEME.status.separator_close):fg(style.main.bg), + ui.Span(THEME.status.separator_close):fg(style.main.bg):bg("reset"), } end @@ -141,6 +141,7 @@ function Status:redraw() local right_width = right:width() return { + ui.Text(""):area(self._area):style(THEME.status.overall), ui.Text(left):area(self._area), ui.Text(right):area(self._area):align(ui.Text.RIGHT), table.unpack(ya.redraw_with(Progress:new(self._area, right_width))), diff --git a/yazi-plugin/src/elements/rect.rs b/yazi-plugin/src/elements/rect.rs index cf78df1f..d0d16db0 100644 --- a/yazi-plugin/src/elements/rect.rs +++ b/yazi-plugin/src/elements/rect.rs @@ -58,6 +58,11 @@ impl UserData for Rect { fields.add_field_method_get("w", |_, me| Ok(me.width)); fields.add_field_method_get("h", |_, me| Ok(me.height)); + fields.add_field_method_set("x", |_, me, x| Ok(me.0.x = x)); + fields.add_field_method_set("y", |_, me, y| Ok(me.0.y = y)); + fields.add_field_method_set("w", |_, me, w| Ok(me.0.width = w)); + fields.add_field_method_set("h", |_, me, h| Ok(me.0.height = h)); + fields.add_field_method_get("left", |_, me| Ok(me.left())); fields.add_field_method_get("right", |_, me| Ok(me.right())); fields.add_field_method_get("top", |_, me| Ok(me.top())); diff --git a/yazi-plugin/src/loader/loader.rs b/yazi-plugin/src/loader/loader.rs index 07f8c6bd..99dcb43a 100644 --- a/yazi-plugin/src/loader/loader.rs +++ b/yazi-plugin/src/loader/loader.rs @@ -65,7 +65,7 @@ impl Loader { yazi_proxy::AppProxy::notify(yazi_proxy::options::NotifyOpt { title: "Deprecated entry file".to_owned(), content: format!( - "The plugin entry file `init.lua` has been deprecated in v0.4.3 in favor of the new `main.lua`, and it will be fully removed in the next major version 0.5. + "The plugin's entry file `init.lua` has been deprecated in favor of the new `main.lua` (user's own `init.lua` remains unchanged). Please run `ya pack -m` to automatically migrate all plugins, or manually rename your `{name}.yazi/init.lua` to `{name}.yazi/main.lua`." ),