From 4b0f02a7c402442977c685ef2cc02c4830d1d8d3 Mon Sep 17 00:00:00 2001 From: Bruno Charest Date: Sun, 16 Aug 2026 13:17:07 -0400 Subject: [PATCH] v0.2.14 : cadres aux couleurs du theme - bordures des tableaux (list, search, status, doctor, ls, dir, ps, help), version, menu d autocompletion et banniere colorees par theme (border) --- src/help.rs | 6 +++++- src/output.rs | 2 +- src/repl.rs | 25 +++++++++++++++++-------- src/tables.rs | 2 +- src/theme.rs | 22 +++++++++++++++++++++- 5 files changed, 45 insertions(+), 12 deletions(-) diff --git a/src/help.rs b/src/help.rs index 8e73b5f..5e9cb22 100644 --- a/src/help.rs +++ b/src/help.rs @@ -745,7 +745,11 @@ fn io_table(input: &str, output: &str, theme: &Theme, color: bool) -> String { line.push_str(&"─".repeat(w + 2)); } line.push(right); - dim(&line, theme, color) + if color { + theme.frame(&line) + } else { + line + } }; let row = |cells: &[&str], bold: bool| -> String { let mut line = String::from("│"); diff --git a/src/output.rs b/src/output.rs index 95e23df..b6d7078 100644 --- a/src/output.rs +++ b/src/output.rs @@ -201,7 +201,7 @@ pub fn kv_table( "─".repeat(val_w + 2) ); if color { - theme.dimmed(&line) + theme.frame(&line) } else { line } diff --git a/src/repl.rs b/src/repl.rs index c162140..950500b 100644 --- a/src/repl.rs +++ b/src/repl.rs @@ -340,7 +340,7 @@ impl Highlighter for AmCompleter { use std::borrow::Cow; let _ = completion; match candidate.chars().next() { - Some('╭') | Some('╰') | Some('├') => Cow::Owned(self.theme.dimmed(candidate)), + Some('╭') | Some('╰') | Some('├') => Cow::Owned(self.theme.frame(candidate)), Some('│') => { let cells: Vec<&str> = candidate.split('│').collect(); if cells.len() >= 4 { @@ -461,8 +461,16 @@ pub fn banner_box( let mut rows: Vec = Vec::new(); let inner = |content: String| format!("│ {} │", pad_visible(content, w)); let blank = || inner(" ".to_string()); + let frame = |s: &str| -> String { + if color { + theme.frame(s) + } else { + s.to_string() + } + }; - // Top border with the centered header (title in the theme header color). + // Top border with the centered header (title in the theme header color, + // border in the theme frame color). let title = format!(" Agent Manager v{version} · shell gateway "); let title = if color { theme.hdr(&title) @@ -472,11 +480,12 @@ pub fn banner_box( let fill = w + 2 - visible_len(&title); let left = fill / 2; let right = fill - left; - rows.push(dim( - &format!("╭{}{}{}╮", "─".repeat(left), title, "─".repeat(right)), - theme, - color, - )); + rows.push(frame(&format!( + "╭{}{}{}╮", + "─".repeat(left), + title, + "─".repeat(right) + ))); // Block-art title, painted in the theme accent color. for art in banner_art() { @@ -587,7 +596,7 @@ pub fn banner_box( theme, color, ))); - rows.push(dim(&format!("╰{}╯", "─".repeat(w + 2)), theme, color)); + rows.push(frame(&format!("╰{}╯", "─".repeat(w + 2)))); rows.join("\n") } diff --git a/src/tables.rs b/src/tables.rs index 3aebd14..4a26c38 100644 --- a/src/tables.rs +++ b/src/tables.rs @@ -177,7 +177,7 @@ impl DataTable { return s.to_string(); } match theme { - Some(t) => t.dimmed(s), + Some(t) => t.frame(s), None => s.dimmed().to_string(), } }; diff --git a/src/theme.rs b/src/theme.rs index a31202b..6460ef4 100644 --- a/src/theme.rs +++ b/src/theme.rs @@ -19,8 +19,10 @@ pub struct Theme { pub accent: &'static str, /// Secondary color: types, values, status "installed". pub info: &'static str, - /// Faint: borders, search terms, "not-installed". + /// Faint: search terms, secondary text, "not-installed". pub dim: &'static str, + /// Frame color: the borders of tables and boxes (list, version, ls...). + pub border: &'static str, /// Warnings and "external" status. pub warn: &'static str, /// Errors and "not-installable". @@ -41,6 +43,7 @@ pub static THEMES: &[Theme] = &[ accent: "1;32", info: "36", dim: "2", + border: "36", warn: "33", error: "31", ok: "1;32", @@ -54,6 +57,7 @@ pub static THEMES: &[Theme] = &[ accent: "1;38;5;81", info: "38;5;117", dim: "2", + border: "38;5;75", warn: "38;5;221", error: "38;5;203", ok: "1;38;5;81", @@ -67,6 +71,7 @@ pub static THEMES: &[Theme] = &[ accent: "1;38;5;215", info: "38;5;213", dim: "2", + border: "38;5;209", warn: "38;5;221", error: "38;5;203", ok: "1;38;5;215", @@ -80,6 +85,7 @@ pub static THEMES: &[Theme] = &[ accent: "1;38;5;107", info: "38;5;72", dim: "2", + border: "38;5;71", warn: "38;5;179", error: "38;5;167", ok: "1;38;5;107", @@ -93,6 +99,7 @@ pub static THEMES: &[Theme] = &[ accent: "1;38;5;84", info: "38;5;117", dim: "2", + border: "38;5;141", warn: "38;5;228", error: "38;5;203", ok: "1;38;5;84", @@ -106,6 +113,7 @@ pub static THEMES: &[Theme] = &[ accent: "", info: "", dim: "", + border: "", warn: "", error: "", ok: "1", @@ -164,6 +172,10 @@ impl Theme { self.paint(self.dim, text) } + pub fn frame(&self, text: &str) -> String { + self.paint(self.border, text) + } + pub fn warn(&self, text: &str) -> String { self.paint(self.warn, text) } @@ -228,4 +240,12 @@ mod tests { assert!(!t.title.is_empty(), "{}: missing title", t.name); } } + + #[test] + fn frame_paints_with_the_theme_border_color() { + let t = find("ocean").unwrap(); + let s = t.frame("╭──╮"); + assert!(s.starts_with("")); + assert_eq!(find("mono").unwrap().frame("x"), "x"); + } }