From fd81366de8cfc6762d4bcd95e12dfc74e8508275 Mon Sep 17 00:00:00 2001 From: XOR-op <17672363+XOR-op@users.noreply.github.com> Date: Thu, 26 Oct 2023 23:35:35 -0400 Subject: [PATCH] feat: theme configuration for completion --- yazi-config/preset/theme.toml | 9 +++++++++ yazi-config/src/theme/theme.rs | 22 +++++++++++++++------- yazi-fm/src/completion/completion.rs | 12 +++++------- 3 files changed, 29 insertions(+), 14 deletions(-) diff --git a/yazi-config/preset/theme.toml b/yazi-config/preset/theme.toml index 57a558cc..4d7f7b22 100644 --- a/yazi-config/preset/theme.toml +++ b/yazi-config/preset/theme.toml @@ -84,6 +84,15 @@ inactive = {} # : }}} +# : Completion {{{ + +[completion] +border = { fg = "blue" } +active = { fg = "lightcyan" } +inactive = {} + +# : }}} + # : Tasks {{{ diff --git a/yazi-config/src/theme/theme.rs b/yazi-config/src/theme/theme.rs index dc1558b5..3ee264a3 100644 --- a/yazi-config/src/theme/theme.rs +++ b/yazi-config/src/theme/theme.rs @@ -81,6 +81,13 @@ pub struct Select { pub inactive: Style, } +#[derive(Deserialize, Serialize)] +pub struct Completion { + pub border: Style, + pub active: Style, + pub inactive: Style, +} + #[derive(Deserialize, Serialize)] pub struct Tasks { pub border: Style, @@ -111,13 +118,14 @@ pub struct Help { #[derive(Deserialize, Serialize)] pub struct Theme { - pub manager: Manager, - status: Status, - pub input: Input, - pub select: Select, - pub tasks: Tasks, - pub which: Which, - pub help: Help, + pub manager: Manager, + status: Status, + pub input: Input, + pub select: Select, + pub completion: Completion, + pub tasks: Tasks, + pub which: Which, + pub help: Help, // File-specific styles #[serde(rename = "filetype", deserialize_with = "Filetype::deserialize", skip_serializing)] diff --git a/yazi-fm/src/completion/completion.rs b/yazi-fm/src/completion/completion.rs index 9e048853..01b879b6 100644 --- a/yazi-fm/src/completion/completion.rs +++ b/yazi-fm/src/completion/completion.rs @@ -35,11 +35,10 @@ impl<'a> Widget for Completion<'a> { } else { s.split_at(max_width - 1).0.to_string() + "…" }) - // todo .style(if completion.cursor() == idx { - THEME.select.active.into() + THEME.completion.active.into() } else { - THEME.select.inactive.into() + THEME.completion.inactive.into() }), ); } @@ -47,10 +46,9 @@ impl<'a> Widget for Completion<'a> { Table::new(table) .block( Block::new() - .borders(Borders::ALL) - .border_type(BorderType::Double) - // todo - .border_style(THEME.select.border.into()), + .borders(Borders::ALL) + .border_type(BorderType::Double) + .border_style(THEME.completion.border.into()), ) .widths(&constraint) };