simple_terminal_app/
lib.rs1pub mod app;
3
4pub mod scene;
6
7pub mod commands {
9
10 pub mod cursor {
12
13 pub use termion::cursor::{
14 BlinkingBar, BlinkingBlock, BlinkingUnderline, Down, Hide, HideCursor, Left, Restore,
15 Right, Save, Show, SteadyBar, SteadyBlock, SteadyUnderline, Up,
16 };
17
18 use crate::Point;
19
20 use std::fmt::Display;
21
22 pub struct Goto(pub Point);
23
24 impl Display for Goto {
25 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
26 write!(f, "{}", termion::cursor::Goto(self.0.x + 1, self.0.y + 1))
27 }
28 }
29 }
30
31 pub mod color {
33 pub use termion::color::{
34 AnsiValue, Bg, Black, Blue, Cyan, Fg, Green, LightBlack, LightBlue, LightCyan,
35 LightGreen, LightMagenta, LightRed, LightWhite, LightYellow, Magenta, Red, Reset,
36 White, Yellow,
37 };
38 }
39
40 pub use termion::{clear, style};
41}
42
43#[derive(Clone, Copy)]
45pub struct Point {
46 pub x: u16,
47
48 pub y: u16,
49}
50
51impl Point {
52 pub fn new(x: u16, y: u16) -> Self {
54 Self { x, y }
55 }
56}
57
58use std::fmt::Display;
59
60impl Display for Point {
61 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
62 write!(f, "({}, {})", self.x, self.y)
63 }
64}
65
66pub use termion::event;