12个版本
0.2.4 | 2020年1月18日 |
---|---|
0.2.3 | 2020年1月18日 |
0.1.11 | 2020年1月18日 |
#34 in #tty
每月 24 次下载
11KB
115 行
Cargo.toml
为了使用此包,您需要在 Cargo.toml
中的依赖项列表中添加它。
...
[dependencies]
text_box = "*"
...
导入
现在您可以使用以下方式导入包和功能
extern crate text_box;
use text_box::TextBox;
use text_box::utils::{clear_screen, goto};
完整示例
完整的用法示例。
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);
}
此示例应输出
┌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? ║
╚═══════════════╝╚═══════════════╝
许可证
根据您的选择,许可协议为以下之一
- Apache许可证第2版,(LICENSE-APACHE 或 https://apache.ac.cn/licenses/LICENSE-2.0)
- MIT许可证 (LICENSE-MIT 或 http://opensource.org/licenses/MIT)
。
许可
除非您明确声明,否则任何有意提交以包含在作品中的贡献,根据Apache-2.0许可证的定义,均应双许可如上所述,不附加任何额外条款或条件。
依赖项
~170KB