Skip to content

Commit

Permalink
feat: theme support for the spotter
Browse files Browse the repository at this point in the history
Allows changing the colors of sxyazi#1802.
Fixes sxyazi#1986.
  • Loading branch information
GrzegorzKozub committed Dec 6, 2024
1 parent fbf9b3d commit 18e9f99
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 5 deletions.
12 changes: 12 additions & 0 deletions yazi-config/preset/theme-dark.toml
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,18 @@ btn_labels = [ " [Y]es ", " (N)o " ]
# : }}}


# : Spot {{{

[spot]
border = { fg = "blue" }
title = { fg = "blue" }
headers = { fg = "green" }
keys = {}
values = { fg = "blue" }
selected = { fg = "yellow", reversed = true }

# : }}}

# : Completion {{{

[completion]
Expand Down
13 changes: 13 additions & 0 deletions yazi-config/preset/theme-light.toml
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,19 @@ btn_labels = [ " [Y]es ", " (N)o " ]
# : }}}


# : Spot {{{

[spot]
border = { fg = "blue" }
title = { fg = "blue" }
headers = { fg = "green" }
keys = {}
values = { fg = "blue" }
selected = { fg = "yellow", reversed = true }

# : }}}


# : Completion {{{

[completion]
Expand Down
11 changes: 11 additions & 0 deletions yazi-config/src/theme/theme.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ pub struct Theme {
status: Status,
pub input: Input,
pub confirm: Confirm,
pub spot: Spot,
pub pick: Pick,
pub completion: Completion,
pub tasks: Tasks,
Expand Down Expand Up @@ -127,6 +128,16 @@ pub struct Confirm {
pub btn_labels: [String; 2],
}

#[derive(Deserialize, Serialize)]
pub struct Spot {
pub border: Style,
pub title: Style,
pub headers: Style,
pub keys: Style,
pub values: Style,
pub selected: Style,
}

#[derive(Deserialize, Serialize)]
pub struct Pick {
pub border: Style,
Expand Down
4 changes: 2 additions & 2 deletions yazi-plugin/preset/plugins/file.lua
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ function M:spot(job)
:area(ui.Pos { "center", w = 60, h = 20 })
:row(1)
:col(1)
:col_style(ui.Style():fg("blue"))
:cell_style(ui.Style():fg("yellow"):reverse())
:col_style(THEME.spot.values)
:cell_style(THEME.spot.selected)
:widths { ui.Constraint.Length(14), ui.Constraint.Fill(1) }
)
end
Expand Down
6 changes: 3 additions & 3 deletions yazi-plugin/src/utils/spot.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use mlua::{AnyUserData, Function, Lua, Table};
use ratatui::style::Stylize;
use yazi_config::THEME;
use yazi_macro::emit;
use yazi_shared::{Layer, event::Cmd};

Expand Down Expand Up @@ -70,10 +70,10 @@ impl Utils {
area,
position: ratatui::widgets::Borders::ALL,
type_: ratatui::widgets::BorderType::Rounded,
style: ratatui::style::Style::default().blue(),
style: ratatui::style::Style::from(THEME.spot.border),
titles: vec![(
ratatui::widgets::block::Position::Top,
ratatui::text::Line::raw(lock.url.name().to_string_lossy().into_owned()).centered(),
ratatui::text::Line::raw(lock.url.name().to_string_lossy().into_owned()).centered().style(THEME.spot.title),
)],
}),
Renderable::Table(table),
Expand Down

0 comments on commit 18e9f99

Please sign in to comment.