mirror of
https://github.com/sxyazi/yazi.git
synced 2026-07-23 15:51:03 +00:00
feat: allow to customize status section separator (#30)
This commit is contained in:
parent
4b8c1ade07
commit
ab5ff057c4
4 changed files with 21 additions and 7 deletions
|
|
@ -22,10 +22,12 @@ impl<'a> Widget for Left<'a> {
|
|||
let secondary = mode.color(&THEME.status.secondary);
|
||||
let body = mode.color(&THEME.status.body);
|
||||
|
||||
let mut spans = vec![];
|
||||
// Separator
|
||||
let separator = &THEME.status.separator;
|
||||
|
||||
// Mode
|
||||
spans.push(Span::styled("", primary.fg()));
|
||||
let mut spans = vec![];
|
||||
spans.push(Span::styled(&separator.opening, primary.fg()));
|
||||
spans.push(Span::styled(
|
||||
format!(" {mode} "),
|
||||
primary.bg().fg(**secondary).add_modifier(Modifier::BOLD),
|
||||
|
|
@ -35,7 +37,7 @@ impl<'a> Widget for Left<'a> {
|
|||
// Length
|
||||
if let Some(len) = h.length {
|
||||
spans.push(Span::styled(format!(" {} ", readable_size(len)), body.bg().fg(**primary)));
|
||||
spans.push(Span::styled("", body.fg()));
|
||||
spans.push(Span::styled(&separator.closing, body.fg()));
|
||||
}
|
||||
|
||||
// Filename
|
||||
|
|
|
|||
|
|
@ -41,12 +41,16 @@ impl<'a> Right<'a> {
|
|||
let secondary = mode.color(&THEME.status.secondary);
|
||||
let body = mode.color(&THEME.status.body);
|
||||
|
||||
// Separator
|
||||
let separator = &THEME.status.separator;
|
||||
|
||||
let cursor = self.cx.manager.current().cursor();
|
||||
let length = self.cx.manager.current().files.len();
|
||||
let percent = if cursor == 0 || length == 0 { 0 } else { (cursor + 1) * 100 / length };
|
||||
|
||||
vec![
|
||||
Span::styled(" ", body.fg()),
|
||||
Span::raw(" "),
|
||||
Span::styled(&separator.opening, body.fg()),
|
||||
Span::styled(
|
||||
if percent == 0 { " Top ".to_string() } else { format!(" {:>3}% ", percent) },
|
||||
body.bg().fg(**primary),
|
||||
|
|
@ -55,7 +59,7 @@ impl<'a> Right<'a> {
|
|||
format!(" {:>2}/{:<2} ", (cursor + 1).min(length), length),
|
||||
primary.bg().fg(**secondary),
|
||||
),
|
||||
Span::styled("", primary.fg()),
|
||||
Span::styled(&separator.closing, primary.fg()),
|
||||
]
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,15 +3,16 @@ active = { fg = "#1E2031", bg = "#80AEFA" }
|
|||
inactive = { fg = "#C8D3F8", bg = "#484D66" }
|
||||
|
||||
[status]
|
||||
primary = { normal = "#80AEFA", select = "#CD9EFC", unset = "#FFA577" }
|
||||
primary = { normal = "#80AEFA", select = "#CD9EFC", unset = "#FFA577" }
|
||||
secondary = { normal = "#1E2031", select = "#23273B", unset = "#23273B" }
|
||||
tertiary = { normal = "#6D738F", select = "#6D738F", unset = "#6D738F" }
|
||||
tertiary = { normal = "#6D738F", select = "#6D738F", unset = "#6D738F" }
|
||||
body = { normal = "#484D66", select = "#484D66", unset = "#484D66" }
|
||||
emphasis = { normal = "#C8D3F8", select = "#C8D3F8", unset = "#C8D3F8" }
|
||||
info = { normal = "#7AD9E5", select = "#7AD9E5", unset = "#7AD9E5" }
|
||||
success = { normal = "#97DC8D", select = "#97DC8D", unset = "#97DC8D" }
|
||||
warning = { normal = "#F3D398", select = "#F3D398", unset = "#F3D398" }
|
||||
danger = { normal = "#FA7F94", select = "#FA7F94", unset = "#FA7F94" }
|
||||
separator = { opening = "", closing = "" }
|
||||
|
||||
[progress]
|
||||
gauge = { fg = "#FFA577", bg = "#484D66" }
|
||||
|
|
|
|||
|
|
@ -23,6 +23,13 @@ pub struct Status {
|
|||
pub success: ColorGroup,
|
||||
pub warning: ColorGroup,
|
||||
pub danger: ColorGroup,
|
||||
pub separator: StatusSeparator,
|
||||
}
|
||||
|
||||
#[derive(Deserialize)]
|
||||
pub struct StatusSeparator {
|
||||
pub opening: String,
|
||||
pub closing: String,
|
||||
}
|
||||
|
||||
#[derive(Deserialize)]
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue