Commit 88a82b92 authored by Moritz Sokoll's avatar Moritz Sokoll 🦀
Browse files

fixed coloring

parent a68c920c
[package]
name = "btui"
version = "0.1.0"
version = "0.1.1"
edition = "2018"
authors = ["Moritz Sokoll <moritz@sokoll.com>"]
license-file = "COPYING"
......
......@@ -5,5 +5,5 @@
## Usage
Add this to your `Cargo.toml` dependency list:
```toml
btui = "0.1.0"
btui = "0.1.1"
```
......@@ -25,8 +25,8 @@ pub mod colors {
}
pub mod formatting {
use crate::Variant;
use crate::ft::colors::*;
use crate::Variant;
/// format text with colors to be printed
///
......@@ -42,34 +42,31 @@ pub mod formatting {
for elm in text {
let add: String = match elm {
Variant::One(n) => {
match n {
ColoredText::Black(p) => format!("\033[30m{}", p),
ColoredText::Red(p) => format!("\033[31m{}", p),
ColoredText::Green(p) => format!("\033[32m{}", p),
ColoredText::Yellow(p) => format!("\033[33m{}", p),
ColoredText::Blue(p) => format!("\033[34m{}", p),
ColoredText::Magenta(p) => format!("\033[35m{}", p),
ColoredText::Cyan(p) => format!("\033[36m{}", p),
ColoredText::White(p) => format!("\033[37m{}", p),
}
}
Variant::Two(n) => {
match n {
ColoredBg::Black => String::from("\033[40m"),
ColoredBg::Red => String::from("\033[41m"),
ColoredBg::Green => String::from("\033[42m"),
ColoredBg::Yellow => String::from("\033[43m"),
ColoredBg::Blue => String::from("\033[44m"),
ColoredBg::Magenta => String::from("\033[45m"),
ColoredBg::Cyan => String::from("\033[46m"),
ColoredBg::White => String::from("\033[47m"),
}
Variant::One(n) => match n {
ColoredText::Black(p) => format!("\x1b[30m{}", p),
ColoredText::Red(p) => format!("\x1b[31m{}", p),
ColoredText::Green(p) => format!("\x1b[32m{}", p),
ColoredText::Yellow(p) => format!("\x1b[33m{}", p),
ColoredText::Blue(p) => format!("\x1b[34m{}", p),
ColoredText::Magenta(p) => format!("\x1b[35m{}", p),
ColoredText::Cyan(p) => format!("\x1b[36m{}", p),
ColoredText::White(p) => format!("\x1b[37m{}", p),
},
Variant::Two(n) => match n {
ColoredBg::Black => String::from("\x1b[40m"),
ColoredBg::Red => String::from("\x1b[41m"),
ColoredBg::Green => String::from("\x1b[42m"),
ColoredBg::Yellow => String::from("\x1b[43m"),
ColoredBg::Blue => String::from("\x1b[44m"),
ColoredBg::Magenta => String::from("\x1b[45m"),
ColoredBg::Cyan => String::from("\x1b[46m"),
ColoredBg::White => String::from("\x1b[47m"),
},
};
out.push_str(add.as_str());
}
out.push_str("\x1b[0m");
out
}
}
......@@ -4,7 +4,7 @@
//! with btui you can create beautiful text user interfaces for the terminal.
//! To get started add `btui` as a dependency to your project:
//! ```toml
//! btui = "0.1.0"
//! btui = "0.1.1"
//! ```
pub mod ft;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment