rapid_cli/
tui.rs

1use crate::constants::LOGO;
2use tiny_gradient::{GradientDisplay, GradientStr, RGB};
3
4/// Clears the console when called
5pub fn clean_console() {
6	print!("{esc}c", esc = 27 as char);
7}
8
9pub fn chevrons<'a>() -> GradientDisplay<'a, [RGB; 3]> {
10	GradientStr::gradient(
11		&">>>",
12		[RGB::new(9, 42, 208), RGB::new(26, 78, 96), RGB::new(9, 42, 208)],
13	)
14}
15
16
17/// Helper function for printing indentations to the console
18pub fn indent(amount: u32) -> String {
19	let mut new_amount = String::new();
20
21	for _ in 0..amount {
22		new_amount.push('\n');
23	}
24	new_amount
25}
26
27/// Logo with signs
28pub fn rapid_logo<'a>() -> &'static str {
29	// GradientStr::gradient(
30	// 	&">>> R A P I D",
31	// 	[RGB::new(9, 42, 208), RGB::new(26, 78, 96), RGB::new(9, 42, 208), RGB::new(14, 197, 255)],
32	// )
33	// precomputed string of above gradient
34	// this allows the use in Spinach spinners
35	"\x1b[38;2;9;42;208m>\x1b[0m\x1b[38;2;15;55;175m>\x1b[0m\x1b[38;2;20;65;140m>\x1b[0m\x1b[38;2;26;78;96m \x1b[0m\x1b[38;2;21;68;130mR\x1b[0m\x1b[38;2;17;60;158m \x1b[0m\x1b[38;2;14;52;184mA\x1b[0m\x1b[38;2;9;42;208m \x1b[0m\x1b[38;2;9;99;215mP\x1b[0m\x1b[38;2;10;130;223m \x1b[0m\x1b[38;2;11;155;233mI\x1b[0m\x1b[38;2;12;177;244m \x1b[0m\x1b[38;2;14;197;255mD\x1b[0m"
36}
37
38/// Normal Logo
39pub fn rapid_logo_small<'a>() -> GradientDisplay<'a, [RGB; 4]> {
40	GradientStr::gradient(
41		&"R A P I D",
42		[RGB::new(9, 42, 208), RGB::new(26, 78, 96), RGB::new(9, 42, 208), RGB::new(14, 197, 255)],
43	)
44}
45
46/// Large Ascii printed logo
47pub fn logo<'a>() -> GradientDisplay<'a, [RGB; 4]> {
48	GradientStr::gradient(
49		&LOGO,
50		[RGB::new(9, 42, 208), RGB::new(26, 78, 96), RGB::new(9, 42, 208), RGB::new(14, 197, 255)],
51	)
52}