color_output/macro/
macro.rs1#[macro_export]
7macro_rules! output_macro {
8 ($($output:expr),*) => {
9 $(
10 $output.output();
11 )*
12 };
13}
14
15#[macro_export]
25macro_rules! __print_message_common {
26 ($color:expr, $bg_color:expr, $($data:expr),*) => {{
27 use crate::*;
28 let binding: String = format!("[{}]", time());
29 let mut time_output_builder: OutputBuilder<'_> = OutputBuilder::new();
30 let time_output: Output<'_> = time_output_builder
31 .text(&binding)
32 .blod(true)
33 .color($color)
34 .bg_color($bg_color)
35 .build();
36 let mut text_output_builder: OutputBuilder<'_> = OutputBuilder::new();
37 let mut text: String = String::new();
38 $(
39 text.push_str(&$data.to_string());
40 )*
41 let mut lines_iter = text.lines().peekable();
42 while let Some(line) = lines_iter.next() {
43 let mut output_list_builder = OutputListBuilder::new();
44 output_list_builder.add(time_output.clone());
45 let text_output: Output<'_> = text_output_builder
46 .text(&line)
47 .blod(true)
48 .endl(true)
49 .build();
50 output_list_builder.add(text_output);
51 output_list_builder.run();
52 }
53 }};
54}
55
56#[macro_export]
58macro_rules! println_success {
59 ($($data:expr),*) => {
60 crate::__print_message_common!(ColorType::Use(Color::White), ColorType::Use(Color::Green), $($data),*);
61 };
62}
63
64#[macro_export]
66macro_rules! println_warning {
67 ($($data:expr),*) => {
68 crate::__print_message_common!(ColorType::Use(Color::White), ColorType::Use(Color::Yellow), $($data),*);
69 };
70}
71
72#[macro_export]
74macro_rules! println_error {
75 ($($data:expr),*) => {
76 crate::__print_message_common!(ColorType::Use(Color::White), ColorType::Use(Color::Red), $($data),*);
77 };
78}