Crates.io | text_box |
lib.rs | text_box |
version | 0.2.4 |
source | src |
created_at | 2020-01-17 19:22:13.08871 |
updated_at | 2020-01-18 20:57:39.414589 |
description | Create useful messages in console with text boxes using 'termion'. |
homepage | |
repository | https://github.com/DaFox416/text_box.git |
max_upload_size | |
id | 199451 |
size | 14,242 |
In order to use this crate you have to add to deps list in Cargo.toml
.
...
[dependencies]
text_box = "*"
...
Now you can import crate and features with:
extern crate text_box;
use text_box::TextBox;
use text_box::utils::{clear_screen, goto};
A complete usage example.
extern crate text_box;
use text_box::TextBox;
use text_box::utils::{clear_screen, goto};
fn main() {
clear_screen();
let box1 = TextBox::new(
30, 10,
15, 6,
2,
"Box 1",
"This box have a border type 2. A first level message, must be checked quickly."
).unwrap();
let box2 = TextBox::new(
10, 10,
15, 6,
0,
"Box 2",
"This box have a border type 0. Normal boxed text for alingment."
).unwrap();
let box3 = TextBox::new(
10, 2,
35, 6,
1,
"Box 3",
"This box have a border type 1. A second level message. \n You can create multiple boxes, just be careful with console window size."
).unwrap();
let box4 = TextBox::new(
47, 2,
15, 14,
2,
"Box 4",
"If you want a new line inside a box you need to put it between spaces like \n this: ' \\n '. Formatter identifies this as a new line word, so it can be printed. \n \n Right?"
).unwrap();
println!("{}{}{}{}", box1, box2, box3, box4);
goto(1, 40);
}
This example should print out:
┌Box 3──────────────────────────────┐╔Box 4══════════╗
│This box have a border type 1. A │║If you want a ║
│second level message. │║new line inside║
│You can create multiple boxes, just│║a box you need ║
│be careful with console window │║to put it ║
│size. │║between spaces ║
│ │║like ║
└───────────────────────────────────┘║this: ' \n '. ║
Box 2 ╔Box 1══════════╗║Formatter ║
This box have a ║This box have a║║identifies this║
border type 0. ║border type 2. ║║as a new line ║
Normal boxed ║A first level ║║word, so it can║
text for ║message, must ║║be printed. ║
alingment. ║be checked ║║ ║
║quickly. ║║Right? ║
╚═══════════════╝╚═══════════════╝
Licensed under either of
at your option.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.