Expand description
termstyle: create and test the style and formatting for the text in your terminal applications
termstyle is a library that aims to make it easy to build formatted and styled command line applications.
§Examples
extern crate serde_yaml;
use termstyle::{Color, El, Text};
// example raw yaml file
let example = r#"
- ["plain ", {t: "and bold", b: true}]
- ["plain ", {t: "and red", c: red}]
"#;
// deserialize as yaml (you can use `serde_json::from_str` for json, etc).
let els = termstyle::from_str(serde_yaml::from_str, example).unwrap();
// This could have also been programmatically constructed like this
let expected = vec![
El::plain("plain ".into()),
El::Text(Text::new("and bold".into()).bold()),
El::plain("plain ".into()),
El::Text(Text::new("and red".into()).color(Color::Red)),
];
assert_eq!(els, expected);
// Render directly to stdout. Can also use `El::paint` to
// do one at a time.
termstyle::paint(&mut ::std::io::stdout(), &els).unwrap();
§Styled Tables
See the documentation for Table
Structs§
- A paintable Table
- Raw
Table
type, used only for deserializing. - A piece of text, may be colored, etc
Enums§
- Possible Terminal Colors
- A Element that can be rendered as styled+formatted text using
paint()
. - Raw
El
type, used only for deserializing. - Raw
Text
type, used only for deserializing. - Raw
Text
type, used so you can specify"foo bar"
or["foo ", "bar"]
Functions§
- Helper function to make tests easier for others.
- Print the byte representation directly to stderr.
- Convert a string into
Vec<El>
using the given deserializer. - Paint the given elements into the writer.
- Helper function to make tests easier for others.
- Helper function to make tests easier for others.