feat: new overall option under [status] to allow specifying the overall style of the status bar (#2321)

This commit is contained in:
三咲雅 · Misaki Masa 2025-02-11 16:56:46 +08:00 committed by GitHub
parent 498623191a
commit 89d4ceb5bb
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 22 additions and 13 deletions

20
Cargo.lock generated
View file

@ -283,9 +283,9 @@ dependencies = [
[[package]] [[package]]
name = "built" name = "built"
version = "0.7.5" version = "0.7.6"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c360505aed52b7ec96a3636c3f039d99103c37d1d9b4f7a8c743d3ea9ffcd03b" checksum = "73848a43c5d63a1251d17adf6c2bf78aa94830e60a335a95eeea45d6ba9e1e4d"
[[package]] [[package]]
name = "bumpalo" name = "bumpalo"
@ -334,9 +334,9 @@ dependencies = [
[[package]] [[package]]
name = "cc" name = "cc"
version = "1.2.12" version = "1.2.13"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "755717a7de9ec452bf7f3f1a3099085deabd7f2962b861dae91ecd7a365903d2" checksum = "c7777341816418c02e033934a09f20dc0ccaf65a5201ef8a450ae0105a573fda"
dependencies = [ dependencies = [
"jobserver", "jobserver",
"libc", "libc",
@ -803,9 +803,9 @@ dependencies = [
[[package]] [[package]]
name = "filedescriptor" name = "filedescriptor"
version = "0.8.2" version = "0.8.3"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7199d965852c3bac31f779ef99cbb4537f80e952e2d6aa0ffeb30cce00f4f46e" checksum = "e40758ed24c9b2eeb76c35fb0aebc66c626084edd827e07e1552279814c6682d"
dependencies = [ dependencies = [
"libc", "libc",
"thiserror 1.0.69", "thiserror 1.0.69",
@ -2712,9 +2712,9 @@ dependencies = [
[[package]] [[package]]
name = "toml_edit" name = "toml_edit"
version = "0.22.23" version = "0.22.24"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "02a8b472d1a3d7c18e2d61a489aee3453fd9031c33e4f55bd533f4a7adca1bee" checksum = "17b4795ff5edd201c7cd6dca065ae59972ce77d1b80fa0a84d94950ece7d1474"
dependencies = [ dependencies = [
"indexmap", "indexmap",
"serde", "serde",
@ -3288,9 +3288,9 @@ checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec"
[[package]] [[package]]
name = "winnow" name = "winnow"
version = "0.7.1" version = "0.7.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "86e376c75f4f43f44db463cf729e0d3acbf954d13e22c51e26e4c264b4ab545f" checksum = "59690dea168f2198d1a3b0cac23b8063efcd11012f10ae4698f284808c8ef603"
dependencies = [ dependencies = [
"memchr", "memchr",
] ]

View file

@ -76,6 +76,7 @@ unset_alt = { fg = "red", bg = "gray" }
# : Status bar {{{ # : Status bar {{{
[status] [status]
overall = {}
separator_open = "" separator_open = ""
separator_close = "" separator_close = ""

View file

@ -76,6 +76,7 @@ unset_alt = { fg = "red", bg = "gray" }
# : Status bar {{{ # : Status bar {{{
[status] [status]
overall = {}
separator_open = "" separator_open = ""
separator_close = "" separator_close = ""

View file

@ -93,6 +93,7 @@ struct Mode {
#[derive(Deserialize, Serialize)] #[derive(Deserialize, Serialize)]
struct Status { struct Status {
pub overall: Style,
pub separator_open: String, pub separator_open: String,
pub separator_close: String, pub separator_close: String,

View file

@ -40,7 +40,7 @@ function Status:mode()
local style = self:style() local style = self:style()
return ui.Line { 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(" " .. mode .. " "):style(style.main),
ui.Span(THEME.status.separator_close):fg(style.main.bg):bg(style.alt.bg), ui.Span(THEME.status.separator_close):fg(style.main.bg):bg(style.alt.bg),
} }
@ -128,7 +128,7 @@ function Status:position()
return ui.Line { return ui.Line {
ui.Span(THEME.status.separator_open):fg(style.main.bg):bg(style.alt.bg), 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(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 end
@ -141,6 +141,7 @@ function Status:redraw()
local right_width = right:width() local right_width = right:width()
return { return {
ui.Text(""):area(self._area):style(THEME.status.overall),
ui.Text(left):area(self._area), ui.Text(left):area(self._area),
ui.Text(right):area(self._area):align(ui.Text.RIGHT), ui.Text(right):area(self._area):align(ui.Text.RIGHT),
table.unpack(ya.redraw_with(Progress:new(self._area, right_width))), table.unpack(ya.redraw_with(Progress:new(self._area, right_width))),

View file

@ -58,6 +58,11 @@ impl UserData for Rect {
fields.add_field_method_get("w", |_, me| Ok(me.width)); fields.add_field_method_get("w", |_, me| Ok(me.width));
fields.add_field_method_get("h", |_, me| Ok(me.height)); 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("left", |_, me| Ok(me.left()));
fields.add_field_method_get("right", |_, me| Ok(me.right())); fields.add_field_method_get("right", |_, me| Ok(me.right()));
fields.add_field_method_get("top", |_, me| Ok(me.top())); fields.add_field_method_get("top", |_, me| Ok(me.top()));

View file

@ -65,7 +65,7 @@ impl Loader {
yazi_proxy::AppProxy::notify(yazi_proxy::options::NotifyOpt { yazi_proxy::AppProxy::notify(yazi_proxy::options::NotifyOpt {
title: "Deprecated entry file".to_owned(), title: "Deprecated entry file".to_owned(),
content: format!( 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`." Please run `ya pack -m` to automatically migrate all plugins, or manually rename your `{name}.yazi/init.lua` to `{name}.yazi/main.lua`."
), ),