1use std::io::stdout;
3use crossterm::{
4 execute,
5 cursor::{SavePosition, RestorePosition, MoveTo},
6 style::{Color, Print, ResetColor, SetBackgroundColor, SetForegroundColor}
7};
8
9pub fn printch(x: u16, y: u16, symbol: &char) {
11
12 let _ = execute!(
13 stdout(),
14
15 SavePosition,
16 MoveTo(x, y),
17 Print(symbol),
18 RestorePosition,
19 );
20}
21
22pub fn printmsg(x: u16, y: u16, msg: &str) {
24
25 let _ = execute!(
26 stdout(),
27
28 SavePosition,
29 MoveTo(x, y),
30 Print(msg),
31 RestorePosition
32 );
33}
34
35pub fn print_hello() {
37
38 set_color(Color::Black, Color::Red);
39 Print(" Powered by ");
40
41 set_color(Color::Red, Color::Black);
42 Print(" CastleCore ");
43
44 reset_color();
45}
46
47pub fn mv_print_hello(x: u16, y: u16) {
49
50 set_color(Color::Black, Color::White);
51 printmsg(x, y, " Powered by ");
52
53 set_color(Color::White, Color::Black);
54 printmsg(x + 12, y, " CastleCore ");
55
56 reset_color();
57}
58
59pub fn set_color(fg_color: Color, bg_color: Color) {
61
62 let _ = execute!( stdout(),
64 SetForegroundColor(fg_color),
65 SetBackgroundColor(bg_color));
66}
67
68pub fn reset_color() {
70
71 let _ = execute!( stdout(),
73 ResetColor);
74}