1#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
5pub struct LineStyle {
6 pub horizontal: &'static str,
8 pub vertical: &'static str,
10 pub top_left: &'static str,
12 pub top_right: &'static str,
14 pub bottom_left: &'static str,
16 pub bottom_right: &'static str,
18 pub vertical_right: &'static str,
20 pub vertical_left: &'static str,
22 pub horizontal_down: &'static str,
24 pub horizontal_up: &'static str,
26 pub cross: &'static str,
28}
29
30pub const SIMPLE: LineStyle = LineStyle {
32 horizontal: "-",
33 vertical: "|",
34 top_left: "+",
35 top_right: "+",
36 bottom_left: "+",
37 bottom_right: "+",
38 vertical_right: "+",
39 vertical_left: "+",
40 horizontal_down: "+",
41 horizontal_up: "+",
42 cross: "+",
43};
44
45pub const NORMAL: LineStyle = LineStyle {
47 horizontal: "─",
48 vertical: "│",
49 top_left: "┌",
50 top_right: "┐",
51 bottom_left: "└",
52 bottom_right: "┘",
53 vertical_right: "├",
54 vertical_left: "┤",
55 horizontal_down: "┬",
56 horizontal_up: "┴",
57 cross: "┼",
58};
59
60pub const ROUNDED: LineStyle = LineStyle {
62 horizontal: "─",
63 vertical: "│",
64 top_left: "╭",
65 top_right: "╮",
66 bottom_left: "╰",
67 bottom_right: "╯",
68 vertical_right: "├",
69 vertical_left: "┤",
70 horizontal_down: "┬",
71 horizontal_up: "┴",
72 cross: "┼",
73};
74
75pub const DOUBLE: LineStyle = LineStyle {
77 horizontal: "═",
78 vertical: "║",
79 top_left: "╔",
80 top_right: "╗",
81 bottom_left: "╚",
82 bottom_right: "╝",
83 vertical_right: "╠",
84 vertical_left: "╣",
85 horizontal_down: "╦",
86 horizontal_up: "╩",
87 cross: "╬",
88};
89
90pub const THICK: LineStyle = LineStyle {
92 horizontal: "━",
93 vertical: "┃",
94 top_left: "┏",
95 top_right: "┓",
96 bottom_left: "┗",
97 bottom_right: "┛",
98 vertical_right: "┣",
99 vertical_left: "┫",
100 horizontal_down: "┳",
101 horizontal_up: "┻",
102 cross: "╋",
103};
104
105#[derive(Debug, Clone, Copy, PartialEq, Eq)]
107pub struct ScrollbarSymbols {
108 pub track: &'static str,
110 pub thumb: &'static str,
112 pub begin: &'static str,
114 pub end: &'static str,
116}
117
118pub const SCROLLBAR_DEFAULT: ScrollbarSymbols = ScrollbarSymbols {
120 track: "│",
121 thumb: "█",
122 begin: "▲",
123 end: "▼",
124};
125
126pub const SCROLLBAR_BLOCK: ScrollbarSymbols = ScrollbarSymbols {
128 track: "░",
129 thumb: "█",
130 begin: "▲",
131 end: "▼",
132};
133
134pub const BAR_FULL: &str = "█";
136pub const BAR_SEVEN_EIGHTHS: &str = "▉";
138pub const BAR_THREE_QUARTERS: &str = "▊";
140pub const BAR_FIVE_EIGHTHS: &str = "▋";
142pub const BAR_HALF: &str = "▌";
144pub const BAR_THREE_EIGHTHS: &str = "▍";
146pub const BAR_QUARTER: &str = "▎";
148pub const BAR_ONE_EIGHTH: &str = "▏";
150
151pub const BLOCKS: [&str; 9] = [
153 " ",
154 BAR_ONE_EIGHTH,
155 BAR_QUARTER,
156 BAR_THREE_EIGHTHS,
157 BAR_HALF,
158 BAR_FIVE_EIGHTHS,
159 BAR_THREE_QUARTERS,
160 BAR_SEVEN_EIGHTHS,
161 BAR_FULL,
162];
163
164pub const DOT: &str = "•";
166pub const BULLET: &str = "●";
168pub const CIRCLE: &str = "○";
170
171pub const MARKER_DOT: &str = "•";
173pub const MARKER_ARROW: &str = "→";
175pub const MARKER_ANGLE: &str = "❯";
177pub const MARKER_CHECK: &str = "✓";
179
180pub mod braille {
182 #[must_use]
192 pub fn char_from_bits(bits: u8) -> char {
193 char::from_u32(0x2800 + bits as u32).unwrap_or('?')
195 }
196}
197
198#[cfg(test)]
199mod tests {
200 use super::*;
201
202 #[test]
203 fn test_line_styles() {
204 assert_eq!(NORMAL.horizontal, "─");
205 assert_eq!(ROUNDED.top_left, "╭");
206 assert_eq!(DOUBLE.vertical, "║");
207 }
208
209 #[test]
210 fn test_braille() {
211 let c = braille::char_from_bits(0b11111111);
212 assert_eq!(c, '⣿');
213 }
214}