zui_core/lib.rs
1#![warn(clippy::all, clippy::cargo)]
2#![allow(clippy::should_implement_trait)]
3
4//! # zui
5//!
6//! `zui` is a terminal UI library in Rust. It works on Unix-like platforms and ANSI terminals, with Windows support
7//! planned. It has features like dynamic resizing, async stdin, and more
8//!
9//! `zui` is very simple, yet powerful. To see examples on how to use `zui`, visit:
10//! <https://git.dumrich.com/zui/tree/examples>
11
12// Define Modules
13pub mod color;
14pub mod key;
15pub mod style;
16pub mod term;
17
18// Imports
19use std::fmt;
20
21// Define Ansi struct
22/// Define ANSI struct. Meant for private use
23#[derive(Debug, Clone)]
24pub struct Ansi {
25 pub value: String,
26}
27
28impl Ansi {
29 // Associated method
30 pub fn from_str(input: String) -> Ansi {
31 Ansi { value: input }
32 }
33}
34
35// Allow displaying Ansi struct
36impl fmt::Display for Ansi {
37 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
38 write!(f, "{}", self.value)
39 }
40}
41
42/// Convert string to Ansi type
43pub trait ToAnsi {
44 fn to_ansi(&self) -> Ansi;
45}