mirror of
https://github.com/sxyazi/yazi.git
synced 2026-07-25 08:41:05 +00:00
feat!: extend the available styles for mode by separating mode from the separator styles (#1953)
This commit is contained in:
parent
ab04ce5d77
commit
5e48df5126
7 changed files with 74 additions and 51 deletions
|
|
@ -18,12 +18,12 @@ 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.
|
- 💪 **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++ and Chafa, covering almost all terminals.
|
- 🖼️ **Built-in Support for Multiple Image Protocols**: Also integrated with Überzug++ and Chafa, covering almost all terminals.
|
||||||
- 🌟 **Built-in Code Highlighting and Image Decoding**: Combined with the pre-loading mechanism, greatly accelerates image and normal file loading.
|
- 🌟 **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/preloader/fetcher; Just some pieces of Lua.
|
- 🔌 **Concurrent Plugin System**: UI plugins (rewriting most of the UI), functional plugins, custom previewer/preloader/spotter/fetcher; 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.
|
- 📡 **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 up to date, or pin them to a specific version.
|
- 📦 **Package Manager**: Install plugins and themes with one command, keeping them up to date, or pin them to a specific version.
|
||||||
- 🧰 Integration with ripgrep, fd, fzf, zoxide
|
- 🧰 Integration with ripgrep, fd, fzf, zoxide
|
||||||
- 💫 Vim-like input/pick/confirm/which/notify component, auto-completion for cd paths
|
- 💫 Vim-like input/pick/confirm/which/notify component, auto-completion for cd paths
|
||||||
- 🏷️ Multi-Tab Support, Cross-directory selection, Scrollable Preview (for videos, PDFs, archives, directories, code, etc.)
|
- 🏷️ Multi-Tab Support, Cross-directory selection, Scrollable Preview (for videos, PDFs, archives, code, directories, etc.)
|
||||||
- 🔄 Bulk Renaming, Visual Mode, File Chooser
|
- 🔄 Bulk Renaming, Visual Mode, File Chooser
|
||||||
- 🎨 Theme System, Mouse Support, Trash Bin, Custom Layouts, CSI u
|
- 🎨 Theme System, Mouse Support, Trash Bin, Custom Layouts, CSI u
|
||||||
- ... and more!
|
- ... and more!
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
# `theme+dark.toml` and `theme+light.toml` are additions to `theme.toml` and are considered part of it.
|
# If the user's terminal is in dark mode, Yazi will use the content from `theme-base.toml` + `theme+dark.toml` as the default theme;
|
||||||
# If your terminal is in dark mode, `theme+dark.toml` will be applied *after* `theme.toml`; if it's in light mode, then `theme+light.toml` instead.
|
# if it's in light mode, use `theme-base.toml` + `theme+light.toml` instead.
|
||||||
|
# Users can always override and adjust the default theme in their own `theme.toml` configuration file.
|
||||||
"$schema" = "https://yazi-rs.github.io/schemas/theme.json"
|
"$schema" = "https://yazi-rs.github.io/schemas/theme.json"
|
||||||
|
|
||||||
# vim:fileencoding=utf-8:foldmethod=marker
|
# vim:fileencoding=utf-8:foldmethod=marker
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
# `theme+dark.toml` and `theme+light.toml` are additions to `theme.toml` and are considered part of it.
|
# If the user's terminal is in dark mode, Yazi will use the content from `theme-base.toml` + `theme+dark.toml` as the default theme;
|
||||||
# If your terminal is in dark mode, `theme+dark.toml` will be applied *after* `theme.toml`; if it's in light mode, then `theme+light.toml` instead.
|
# if it's in light mode, use `theme-base.toml` + `theme+light.toml` instead.
|
||||||
|
# Users can always override and adjust the default theme in their own `theme.toml` configuration file.
|
||||||
"$schema" = "https://yazi-rs.github.io/schemas/theme.json"
|
"$schema" = "https://yazi-rs.github.io/schemas/theme.json"
|
||||||
|
|
||||||
# vim:fileencoding=utf-8:foldmethod=marker
|
# vim:fileencoding=utf-8:foldmethod=marker
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
# A TOML linter such as https://taplo.tamasfe.dev/ can use this schema to validate your config.
|
# If the user's terminal is in dark mode, Yazi will use the content from `theme-base.toml` + `theme+dark.toml` as the default theme;
|
||||||
# If you encounter any issues, please make an issue at https://github.com/yazi-rs/schemas.
|
# if it's in light mode, use `theme-base.toml` + `theme+light.toml` instead.
|
||||||
|
# Users can always override and adjust the default theme in their own `theme.toml` configuration file.
|
||||||
"$schema" = "https://yazi-rs.github.io/schemas/theme.json"
|
"$schema" = "https://yazi-rs.github.io/schemas/theme.json"
|
||||||
|
|
||||||
# vim:fileencoding=utf-8:foldmethod=marker
|
# vim:fileencoding=utf-8:foldmethod=marker
|
||||||
|
|
@ -51,17 +52,29 @@ syntect_theme = ""
|
||||||
# : }}}
|
# : }}}
|
||||||
|
|
||||||
|
|
||||||
# : Status {{{
|
# : Mode {{{
|
||||||
|
|
||||||
|
[mode]
|
||||||
|
|
||||||
|
normal_main = { bg = "blue", bold = true }
|
||||||
|
normal_alt = { fg = "blue", bg = "gray" }
|
||||||
|
|
||||||
|
# Select mode
|
||||||
|
select_main = { bg = "red", bold = true }
|
||||||
|
select_alt = { fg = "red", bg = "gray" }
|
||||||
|
|
||||||
|
# Unset mode
|
||||||
|
unset_main = { bg = "red", bold = true }
|
||||||
|
unset_alt = { fg = "red", bg = "gray" }
|
||||||
|
|
||||||
|
# : }}}
|
||||||
|
|
||||||
|
|
||||||
|
# : Status bar {{{
|
||||||
|
|
||||||
[status]
|
[status]
|
||||||
separator_open = ""
|
separator_open = ""
|
||||||
separator_close = ""
|
separator_close = ""
|
||||||
separator_style = { fg = "gray", bg = "gray" }
|
|
||||||
|
|
||||||
# Mode
|
|
||||||
mode_normal = { bg = "blue", bold = true }
|
|
||||||
mode_select = { bg = "red", bold = true }
|
|
||||||
mode_unset = { bg = "red", bold = true }
|
|
||||||
|
|
||||||
# Progress
|
# Progress
|
||||||
progress_label = { bold = true }
|
progress_label = { bold = true }
|
||||||
|
|
@ -69,11 +82,11 @@ progress_normal = { fg = "blue", bg = "black" }
|
||||||
progress_error = { fg = "red", bg = "black" }
|
progress_error = { fg = "red", bg = "black" }
|
||||||
|
|
||||||
# Permissions
|
# Permissions
|
||||||
permissions_t = { fg = "green" }
|
perm_sep = { fg = "darkgray" }
|
||||||
permissions_r = { fg = "yellow" }
|
perm_type = { fg = "green" }
|
||||||
permissions_w = { fg = "red" }
|
perm_read = { fg = "yellow" }
|
||||||
permissions_x = { fg = "cyan" }
|
perm_write = { fg = "red" }
|
||||||
permissions_s = { fg = "darkgray" }
|
perm_exec = { fg = "cyan" }
|
||||||
|
|
||||||
# : }}}
|
# : }}}
|
||||||
|
|
||||||
|
|
@ -11,6 +11,7 @@ use super::{Filetype, Flavor, Icons};
|
||||||
pub struct Theme {
|
pub struct Theme {
|
||||||
pub flavor: Flavor,
|
pub flavor: Flavor,
|
||||||
pub manager: Manager,
|
pub manager: Manager,
|
||||||
|
mode: Mode,
|
||||||
status: Status,
|
status: Status,
|
||||||
pub input: Input,
|
pub input: Input,
|
||||||
pub confirm: Confirm,
|
pub confirm: Confirm,
|
||||||
|
|
@ -77,16 +78,22 @@ pub struct Manager {
|
||||||
pub syntect_theme: PathBuf,
|
pub syntect_theme: PathBuf,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Deserialize, Serialize)]
|
||||||
|
struct Mode {
|
||||||
|
pub normal_main: Style,
|
||||||
|
pub normal_alt: Style,
|
||||||
|
|
||||||
|
pub select_main: Style,
|
||||||
|
pub select_alt: Style,
|
||||||
|
|
||||||
|
pub unset_main: Style,
|
||||||
|
pub unset_alt: Style,
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Deserialize, Serialize)]
|
#[derive(Deserialize, Serialize)]
|
||||||
struct Status {
|
struct Status {
|
||||||
pub separator_open: String,
|
pub separator_open: String,
|
||||||
pub separator_close: String,
|
pub separator_close: String,
|
||||||
pub separator_style: Style,
|
|
||||||
|
|
||||||
// Mode
|
|
||||||
pub mode_normal: Style,
|
|
||||||
pub mode_select: Style,
|
|
||||||
pub mode_unset: Style,
|
|
||||||
|
|
||||||
// Progress
|
// Progress
|
||||||
pub progress_label: Style,
|
pub progress_label: Style,
|
||||||
|
|
@ -94,11 +101,11 @@ struct Status {
|
||||||
pub progress_error: Style,
|
pub progress_error: Style,
|
||||||
|
|
||||||
// Permissions
|
// Permissions
|
||||||
pub permissions_t: Style,
|
pub perm_sep: Style,
|
||||||
pub permissions_r: Style,
|
pub perm_type: Style,
|
||||||
pub permissions_w: Style,
|
pub perm_read: Style,
|
||||||
pub permissions_x: Style,
|
pub perm_write: Style,
|
||||||
pub permissions_s: Style,
|
pub perm_exec: Style,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Deserialize, Serialize)]
|
#[derive(Deserialize, Serialize)]
|
||||||
|
|
|
||||||
|
|
@ -50,12 +50,12 @@ macro_rules! theme_preset {
|
||||||
".toml"
|
".toml"
|
||||||
))
|
))
|
||||||
.expect(concat!("Failed to read 'yazi-config/preset/theme+", $name, ".toml'"));
|
.expect(concat!("Failed to read 'yazi-config/preset/theme+", $name, ".toml'"));
|
||||||
std::borrow::Cow::from(format!("{}\n{append}", &$crate::config_preset!("theme")))
|
std::borrow::Cow::from(format!("{}\n{append}", &$crate::config_preset!("theme-base")))
|
||||||
}
|
}
|
||||||
#[cfg(not(debug_assertions))]
|
#[cfg(not(debug_assertions))]
|
||||||
{
|
{
|
||||||
std::borrow::Cow::from(concat!(
|
std::borrow::Cow::from(concat!(
|
||||||
include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/preset/theme.toml")),
|
include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/preset/theme-base.toml")),
|
||||||
"\n",
|
"\n",
|
||||||
include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/preset/theme+", $name, ".toml"))
|
include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/preset/theme+", $name, ".toml"))
|
||||||
))
|
))
|
||||||
|
|
|
||||||
|
|
@ -25,12 +25,13 @@ function Status:new(area, tab)
|
||||||
end
|
end
|
||||||
|
|
||||||
function Status:style()
|
function Status:style()
|
||||||
|
local m = THEME.mode
|
||||||
if self._tab.mode.is_select then
|
if self._tab.mode.is_select then
|
||||||
return THEME.status.mode_select
|
return { main = m.select_main, alt = m.select_alt }
|
||||||
elseif self._tab.mode.is_unset then
|
elseif self._tab.mode.is_unset then
|
||||||
return THEME.status.mode_unset
|
return { main = m.unset_main, alt = m.unset_alt }
|
||||||
else
|
else
|
||||||
return THEME.status.mode_normal
|
return { main = m.normal_main, alt = m.normal_alt }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
@ -39,9 +40,9 @@ 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.bg),
|
ui.Span(THEME.status.separator_open):fg(style.main.bg),
|
||||||
ui.Span(" " .. mode .. " "):style(style),
|
ui.Span(" " .. mode .. " "):style(style.main),
|
||||||
ui.Span(THEME.status.separator_close):fg(style.bg):bg(THEME.status.separator_style.fg),
|
ui.Span(THEME.status.separator_close):fg(style.main.bg):bg(style.alt.bg),
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
@ -53,8 +54,8 @@ function Status:size()
|
||||||
|
|
||||||
local style = self:style()
|
local style = self:style()
|
||||||
return ui.Line {
|
return ui.Line {
|
||||||
ui.Span(" " .. ya.readable_size(h:size() or h.cha.len) .. " "):fg(style.bg):bg(THEME.status.separator_style.bg),
|
ui.Span(" " .. ya.readable_size(h:size() or h.cha.len) .. " "):style(style.alt),
|
||||||
ui.Span(THEME.status.separator_close):fg(THEME.status.separator_style.fg),
|
ui.Span(THEME.status.separator_close):fg(style.alt.bg),
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
@ -81,15 +82,15 @@ function Status:perm()
|
||||||
local spans = {}
|
local spans = {}
|
||||||
for i = 1, #perm do
|
for i = 1, #perm do
|
||||||
local c = perm:sub(i, i)
|
local c = perm:sub(i, i)
|
||||||
local style = THEME.status.permissions_t
|
local style = THEME.status.perm_type
|
||||||
if c == "-" or c == "?" then
|
if c == "-" or c == "?" then
|
||||||
style = THEME.status.permissions_s
|
style = THEME.status.perm_sep
|
||||||
elseif c == "r" then
|
elseif c == "r" then
|
||||||
style = THEME.status.permissions_r
|
style = THEME.status.perm_read
|
||||||
elseif c == "w" then
|
elseif c == "w" then
|
||||||
style = THEME.status.permissions_w
|
style = THEME.status.perm_write
|
||||||
elseif c == "x" or c == "s" or c == "S" or c == "t" or c == "T" then
|
elseif c == "x" or c == "s" or c == "S" or c == "t" or c == "T" then
|
||||||
style = THEME.status.permissions_x
|
style = THEME.status.perm_exec
|
||||||
end
|
end
|
||||||
spans[i] = ui.Span(c):style(style)
|
spans[i] = ui.Span(c):style(style)
|
||||||
end
|
end
|
||||||
|
|
@ -114,8 +115,8 @@ function Status:percent()
|
||||||
|
|
||||||
local style = self:style()
|
local style = self:style()
|
||||||
return ui.Line {
|
return ui.Line {
|
||||||
ui.Span(" " .. THEME.status.separator_open):fg(THEME.status.separator_style.fg),
|
ui.Span(" " .. THEME.status.separator_open):fg(style.alt.bg),
|
||||||
ui.Span(percent):fg(style.bg):bg(THEME.status.separator_style.bg),
|
ui.Span(percent):style(style.alt),
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
@ -125,9 +126,9 @@ function Status:position()
|
||||||
|
|
||||||
local style = self:style()
|
local style = self:style()
|
||||||
return ui.Line {
|
return ui.Line {
|
||||||
ui.Span(THEME.status.separator_open):fg(style.bg):bg(THEME.status.separator_style.fg),
|
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),
|
ui.Span(string.format(" %2d/%-2d ", math.min(cursor + 1, length), length)):style(style.main),
|
||||||
ui.Span(THEME.status.separator_close):fg(style.bg),
|
ui.Span(THEME.status.separator_close):fg(style.main.bg),
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue