feat: theme support for the spotter

Allows changing the colors of https://github.com/sxyazi/yazi/pull/1802.
Fixes #1986.
This commit is contained in:
greg 2024-12-06 07:12:32 +01:00
parent fbf9b3d1ed
commit 345dd93522
No known key found for this signature in database
GPG key ID: F49061714C719E6D
4 changed files with 27 additions and 3 deletions

View file

@ -128,6 +128,14 @@ btn_labels = [ " [Y]es ", " (N)o " ]
# : }}} # : }}}
# : Spot {{{
[spot]
border = { fg = "blue" }
title = { fg = "blue" }
# : }}}
# : Completion {{{ # : Completion {{{
[completion] [completion]

View file

@ -128,6 +128,15 @@ btn_labels = [ " [Y]es ", " (N)o " ]
# : }}} # : }}}
# : Spot {{{
[spot]
border = { fg = "blue" }
title = { fg = "blue" }
# : }}}
# : Completion {{{ # : Completion {{{
[completion] [completion]

View file

@ -15,6 +15,7 @@ pub struct Theme {
status: Status, status: Status,
pub input: Input, pub input: Input,
pub confirm: Confirm, pub confirm: Confirm,
pub spot: Spot,
pub pick: Pick, pub pick: Pick,
pub completion: Completion, pub completion: Completion,
pub tasks: Tasks, pub tasks: Tasks,
@ -127,6 +128,12 @@ pub struct Confirm {
pub btn_labels: [String; 2], pub btn_labels: [String; 2],
} }
#[derive(Deserialize, Serialize)]
pub struct Spot {
pub border: Style,
pub title: Style,
}
#[derive(Deserialize, Serialize)] #[derive(Deserialize, Serialize)]
pub struct Pick { pub struct Pick {
pub border: Style, pub border: Style,

View file

@ -1,5 +1,5 @@
use mlua::{AnyUserData, Function, Lua, Table}; use mlua::{AnyUserData, Function, Lua, Table};
use ratatui::style::Stylize; use yazi_config::THEME;
use yazi_macro::emit; use yazi_macro::emit;
use yazi_shared::{Layer, event::Cmd}; use yazi_shared::{Layer, event::Cmd};
@ -70,10 +70,10 @@ impl Utils {
area, area,
position: ratatui::widgets::Borders::ALL, position: ratatui::widgets::Borders::ALL,
type_: ratatui::widgets::BorderType::Rounded, type_: ratatui::widgets::BorderType::Rounded,
style: ratatui::style::Style::default().blue(), style: ratatui::style::Style::from(THEME.spot.border),
titles: vec![( titles: vec![(
ratatui::widgets::block::Position::Top, 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), Renderable::Table(table),