Skip to content

Commit

Permalink
feat(statusline): make 0% and 100% percent format configurable
Browse files Browse the repository at this point in the history
  • Loading branch information
PFiS1737 committed Feb 10, 2025
1 parent 0e0268a commit a144cd8
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion yazi-config/preset/theme-dark.toml
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ separator_left = [ "", "" ]
separator_right = [ "", "" ]

# Format
format_percent = "%2d%%"
format_percent = [ "Top", "%2d%%", "Bot" ]
format_position = "%2d/%-2d"
format_mode = "%.3s"

Expand Down
2 changes: 1 addition & 1 deletion yazi-config/preset/theme-light.toml
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ separator_left = [ "", "" ]
separator_right = [ "", "" ]

# Format
format_percent = "%2d%%"
format_percent = [ "Top", "%2d%%", "Bot" ]
format_position = "%2d/%-2d"
format_mode = "%.3s"

Expand Down
2 changes: 1 addition & 1 deletion yazi-config/src/theme/theme.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ struct Status {
pub separator_right: (String, String),

// Format
pub format_percent: String,
pub format_percent: (String, String, String),
pub format_position: String,
pub format_mode: String,

Expand Down
8 changes: 4 additions & 4 deletions yazi-plugin/preset/components/status.lua
Original file line number Diff line number Diff line change
Expand Up @@ -106,17 +106,17 @@ function Status:percent()
end

if percent == 0 then
percent = " Top "
percent = string.format(THEME.status.format_percent[1], percent)
elseif percent == 100 then
percent = " Bot "
percent = string.format(THEME.status.format_percent[3], percent)
else
percent = string.format(" " .. THEME.status.format_percent .. " ", percent)
percent = string.format(THEME.status.format_percent[2], percent)
end

local style = self:style()
return ui.Line {
ui.Span(" " .. THEME.status.separator_right[1]):fg(style.alt.bg),
ui.Span(percent):style(style.alt),
ui.Span(" " .. percent .. " "):style(style.alt),
}
end

Expand Down

0 comments on commit a144cd8

Please sign in to comment.