radicle_term/
format.rs

1use crate::Paint;
2
3pub fn default<D: std::fmt::Display>(msg: D) -> Paint<D> {
4    Paint::new(msg)
5}
6
7pub fn wrap<D: std::fmt::Display>(msg: D) -> Paint<D> {
8    Paint::wrapping(msg)
9}
10
11pub fn negative<D: std::fmt::Display>(msg: D) -> Paint<D> {
12    Paint::red(msg)
13}
14
15pub fn positive<D: std::fmt::Display>(msg: D) -> Paint<D> {
16    Paint::green(msg)
17}
18
19pub fn primary<D: std::fmt::Display>(msg: D) -> Paint<D> {
20    Paint::magenta(msg)
21}
22
23pub fn secondary<D: std::fmt::Display>(msg: D) -> Paint<D> {
24    Paint::blue(msg)
25}
26
27pub fn tertiary<D: std::fmt::Display>(msg: D) -> Paint<D> {
28    Paint::cyan(msg)
29}
30
31pub fn yellow<D: std::fmt::Display>(msg: D) -> Paint<D> {
32    Paint::yellow(msg)
33}
34
35pub fn hint<D: std::fmt::Display>(msg: D) -> Paint<D> {
36    Paint::yellow(msg)
37}
38
39pub fn faint<D: std::fmt::Display>(msg: D) -> Paint<D> {
40    Paint::fixed(236, msg)
41}
42
43pub fn highlight<D: std::fmt::Debug + std::fmt::Display>(input: D) -> Paint<D> {
44    Paint::green(input).bold()
45}
46
47pub fn badge_primary<D: std::fmt::Display>(input: D) -> Paint<String> {
48    if Paint::is_enabled() {
49        Paint::magenta(format!(" {input} ")).invert()
50    } else {
51        Paint::new(format!("❲{input}❳"))
52    }
53}
54
55pub fn badge_yellow<D: std::fmt::Display>(input: D) -> Paint<String> {
56    if Paint::is_enabled() {
57        Paint::yellow(format!(" {input} ")).invert()
58    } else {
59        Paint::new(format!("❲{input}❳"))
60    }
61}
62
63pub fn badge_positive<D: std::fmt::Display>(input: D) -> Paint<String> {
64    if Paint::is_enabled() {
65        Paint::green(format!(" {input} ")).invert()
66    } else {
67        Paint::new(format!("❲{input}❳"))
68    }
69}
70
71pub fn badge_negative<D: std::fmt::Display>(input: D) -> Paint<String> {
72    if Paint::is_enabled() {
73        Paint::red(format!(" {input} ")).invert()
74    } else {
75        Paint::new(format!("❲{input}❳"))
76    }
77}
78
79pub fn badge_secondary<D: std::fmt::Display>(input: D) -> Paint<String> {
80    if Paint::is_enabled() {
81        Paint::blue(format!(" {input} ")).invert()
82    } else {
83        Paint::new(format!("❲{input}❳"))
84    }
85}
86
87pub fn bold<D: std::fmt::Display>(input: D) -> Paint<D> {
88    Paint::new(input).bold()
89}
90
91pub fn dim<D: std::fmt::Display>(input: D) -> Paint<D> {
92    Paint::new(input).dim()
93}
94
95pub fn italic<D: std::fmt::Display>(input: D) -> Paint<D> {
96    Paint::new(input).italic().dim()
97}