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)
This commit is contained in:
+5
-1
@@ -745,7 +745,11 @@ fn io_table(input: &str, output: &str, theme: &Theme, color: bool) -> String {
|
|||||||
line.push_str(&"─".repeat(w + 2));
|
line.push_str(&"─".repeat(w + 2));
|
||||||
}
|
}
|
||||||
line.push(right);
|
line.push(right);
|
||||||
dim(&line, theme, color)
|
if color {
|
||||||
|
theme.frame(&line)
|
||||||
|
} else {
|
||||||
|
line
|
||||||
|
}
|
||||||
};
|
};
|
||||||
let row = |cells: &[&str], bold: bool| -> String {
|
let row = |cells: &[&str], bold: bool| -> String {
|
||||||
let mut line = String::from("│");
|
let mut line = String::from("│");
|
||||||
|
|||||||
+1
-1
@@ -201,7 +201,7 @@ pub fn kv_table(
|
|||||||
"─".repeat(val_w + 2)
|
"─".repeat(val_w + 2)
|
||||||
);
|
);
|
||||||
if color {
|
if color {
|
||||||
theme.dimmed(&line)
|
theme.frame(&line)
|
||||||
} else {
|
} else {
|
||||||
line
|
line
|
||||||
}
|
}
|
||||||
|
|||||||
+17
-8
@@ -340,7 +340,7 @@ impl Highlighter for AmCompleter {
|
|||||||
use std::borrow::Cow;
|
use std::borrow::Cow;
|
||||||
let _ = completion;
|
let _ = completion;
|
||||||
match candidate.chars().next() {
|
match candidate.chars().next() {
|
||||||
Some('╭') | Some('╰') | Some('├') => Cow::Owned(self.theme.dimmed(candidate)),
|
Some('╭') | Some('╰') | Some('├') => Cow::Owned(self.theme.frame(candidate)),
|
||||||
Some('│') => {
|
Some('│') => {
|
||||||
let cells: Vec<&str> = candidate.split('│').collect();
|
let cells: Vec<&str> = candidate.split('│').collect();
|
||||||
if cells.len() >= 4 {
|
if cells.len() >= 4 {
|
||||||
@@ -461,8 +461,16 @@ pub fn banner_box(
|
|||||||
let mut rows: Vec<String> = Vec::new();
|
let mut rows: Vec<String> = Vec::new();
|
||||||
let inner = |content: String| format!("│ {} │", pad_visible(content, w));
|
let inner = |content: String| format!("│ {} │", pad_visible(content, w));
|
||||||
let blank = || inner(" ".to_string());
|
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 = format!(" Agent Manager v{version} · shell gateway ");
|
||||||
let title = if color {
|
let title = if color {
|
||||||
theme.hdr(&title)
|
theme.hdr(&title)
|
||||||
@@ -472,11 +480,12 @@ pub fn banner_box(
|
|||||||
let fill = w + 2 - visible_len(&title);
|
let fill = w + 2 - visible_len(&title);
|
||||||
let left = fill / 2;
|
let left = fill / 2;
|
||||||
let right = fill - left;
|
let right = fill - left;
|
||||||
rows.push(dim(
|
rows.push(frame(&format!(
|
||||||
&format!("╭{}{}{}╮", "─".repeat(left), title, "─".repeat(right)),
|
"╭{}{}{}╮",
|
||||||
theme,
|
"─".repeat(left),
|
||||||
color,
|
title,
|
||||||
));
|
"─".repeat(right)
|
||||||
|
)));
|
||||||
|
|
||||||
// Block-art title, painted in the theme accent color.
|
// Block-art title, painted in the theme accent color.
|
||||||
for art in banner_art() {
|
for art in banner_art() {
|
||||||
@@ -587,7 +596,7 @@ pub fn banner_box(
|
|||||||
theme,
|
theme,
|
||||||
color,
|
color,
|
||||||
)));
|
)));
|
||||||
rows.push(dim(&format!("╰{}╯", "─".repeat(w + 2)), theme, color));
|
rows.push(frame(&format!("╰{}╯", "─".repeat(w + 2))));
|
||||||
|
|
||||||
rows.join("\n")
|
rows.join("\n")
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -177,7 +177,7 @@ impl DataTable {
|
|||||||
return s.to_string();
|
return s.to_string();
|
||||||
}
|
}
|
||||||
match theme {
|
match theme {
|
||||||
Some(t) => t.dimmed(s),
|
Some(t) => t.frame(s),
|
||||||
None => s.dimmed().to_string(),
|
None => s.dimmed().to_string(),
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
+21
-1
@@ -19,8 +19,10 @@ pub struct Theme {
|
|||||||
pub accent: &'static str,
|
pub accent: &'static str,
|
||||||
/// Secondary color: types, values, status "installed".
|
/// Secondary color: types, values, status "installed".
|
||||||
pub info: &'static str,
|
pub info: &'static str,
|
||||||
/// Faint: borders, search terms, "not-installed".
|
/// Faint: search terms, secondary text, "not-installed".
|
||||||
pub dim: &'static str,
|
pub dim: &'static str,
|
||||||
|
/// Frame color: the borders of tables and boxes (list, version, ls...).
|
||||||
|
pub border: &'static str,
|
||||||
/// Warnings and "external" status.
|
/// Warnings and "external" status.
|
||||||
pub warn: &'static str,
|
pub warn: &'static str,
|
||||||
/// Errors and "not-installable".
|
/// Errors and "not-installable".
|
||||||
@@ -41,6 +43,7 @@ pub static THEMES: &[Theme] = &[
|
|||||||
accent: "1;32",
|
accent: "1;32",
|
||||||
info: "36",
|
info: "36",
|
||||||
dim: "2",
|
dim: "2",
|
||||||
|
border: "36",
|
||||||
warn: "33",
|
warn: "33",
|
||||||
error: "31",
|
error: "31",
|
||||||
ok: "1;32",
|
ok: "1;32",
|
||||||
@@ -54,6 +57,7 @@ pub static THEMES: &[Theme] = &[
|
|||||||
accent: "1;38;5;81",
|
accent: "1;38;5;81",
|
||||||
info: "38;5;117",
|
info: "38;5;117",
|
||||||
dim: "2",
|
dim: "2",
|
||||||
|
border: "38;5;75",
|
||||||
warn: "38;5;221",
|
warn: "38;5;221",
|
||||||
error: "38;5;203",
|
error: "38;5;203",
|
||||||
ok: "1;38;5;81",
|
ok: "1;38;5;81",
|
||||||
@@ -67,6 +71,7 @@ pub static THEMES: &[Theme] = &[
|
|||||||
accent: "1;38;5;215",
|
accent: "1;38;5;215",
|
||||||
info: "38;5;213",
|
info: "38;5;213",
|
||||||
dim: "2",
|
dim: "2",
|
||||||
|
border: "38;5;209",
|
||||||
warn: "38;5;221",
|
warn: "38;5;221",
|
||||||
error: "38;5;203",
|
error: "38;5;203",
|
||||||
ok: "1;38;5;215",
|
ok: "1;38;5;215",
|
||||||
@@ -80,6 +85,7 @@ pub static THEMES: &[Theme] = &[
|
|||||||
accent: "1;38;5;107",
|
accent: "1;38;5;107",
|
||||||
info: "38;5;72",
|
info: "38;5;72",
|
||||||
dim: "2",
|
dim: "2",
|
||||||
|
border: "38;5;71",
|
||||||
warn: "38;5;179",
|
warn: "38;5;179",
|
||||||
error: "38;5;167",
|
error: "38;5;167",
|
||||||
ok: "1;38;5;107",
|
ok: "1;38;5;107",
|
||||||
@@ -93,6 +99,7 @@ pub static THEMES: &[Theme] = &[
|
|||||||
accent: "1;38;5;84",
|
accent: "1;38;5;84",
|
||||||
info: "38;5;117",
|
info: "38;5;117",
|
||||||
dim: "2",
|
dim: "2",
|
||||||
|
border: "38;5;141",
|
||||||
warn: "38;5;228",
|
warn: "38;5;228",
|
||||||
error: "38;5;203",
|
error: "38;5;203",
|
||||||
ok: "1;38;5;84",
|
ok: "1;38;5;84",
|
||||||
@@ -106,6 +113,7 @@ pub static THEMES: &[Theme] = &[
|
|||||||
accent: "",
|
accent: "",
|
||||||
info: "",
|
info: "",
|
||||||
dim: "",
|
dim: "",
|
||||||
|
border: "",
|
||||||
warn: "",
|
warn: "",
|
||||||
error: "",
|
error: "",
|
||||||
ok: "1",
|
ok: "1",
|
||||||
@@ -164,6 +172,10 @@ impl Theme {
|
|||||||
self.paint(self.dim, text)
|
self.paint(self.dim, text)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn frame(&self, text: &str) -> String {
|
||||||
|
self.paint(self.border, text)
|
||||||
|
}
|
||||||
|
|
||||||
pub fn warn(&self, text: &str) -> String {
|
pub fn warn(&self, text: &str) -> String {
|
||||||
self.paint(self.warn, text)
|
self.paint(self.warn, text)
|
||||||
}
|
}
|
||||||
@@ -228,4 +240,12 @@ mod tests {
|
|||||||
assert!(!t.title.is_empty(), "{}: missing title", t.name);
|
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("[38;5;75m"));
|
||||||
|
assert_eq!(find("mono").unwrap().frame("x"), "x");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user