3 releases (1 stable)
Uses new Rust 2024
new 1.0.0 | Apr 19, 2025 |
---|---|
0.1.1 | Apr 15, 2025 |
0.1.0 | Apr 14, 2025 |
#415 in Command-line interface
172 downloads per month
34KB
547 lines
boxy-cli
A Crate to create boxes in command-line interfaces with Rust
Dual-licensed under Apache 2.0 or MIT.
About:
boxy-cli is a crate to create simple textboxes in command-line interfaces, with a simple and easy-to-use design.
How to use:
First import the crate into the current scope, using:
use boxy_cli::prelude::*;
Next you create a new boxy struct with either the new
method:
let mut box1 = Boxy::new(BoxType::Double,"#00ffff");
or the macro:
let mut box2 = boxy!(type: BoxType::Double, color:"#00ffff");
for more info on the macro, view the macro documentation
Next, we just add in text sections:
box1.add_text_sgmt("Lorem ipsum dolor sit amet", "#fffff");
Add some more text to the same segment (or the latest segment):
box1.add_text_line("consectetur adipiscing elit");
or to a segment with a particular index:
box1.add_text_line_indx(" consectetur adipiscing elit", 0);
Once you are done, just display the TextBox:
box1.display();
the text colour is a required argument, and will be implemented into a usable feature in the very near future. But for now, it does not work
Examples:
Example 1
use boxy_cli::prelude::*;
fn main() {
let mut box1 = Boxy::new(BoxType::Double,"#bfff00");
box1.add_text_sgmt("Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur", "#ffff");
box1.add_text_sgmt("Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo.", "#ffff");
box1.add_text_sgmt("Hello Theree", "#ffff");
box1.display();
}
Example 2 (with the macro)
use boxy_cli::prelude::*;
fn main() {
let mut box2 = boxy!(type: BoxType::Double, color:"#00ffff");
box2.add_text_sgmt("Hello There Mateojablij trhwesoiuethj 0piswe hjgtgoise jgtowie3thj q3o-oitujpwiej toiq 0iweeh gt owjtpiewrwh WOKWRHJ JRQWE4IHYNE5R bfg oiwhf apeih aepih aepih aepihetm wf[ohgwlMRF [POWQWRF]] [OJTQEA [OJ]]OJBDGISUDBG SIUGRG OGUFOSIJGOSN SOGUIHSGIORNGR ORIRHGOSJRNGOIJRG OPIFGHRPGNPERIJG ORIRGRPIGNERPGOSJH ", "#ffff");
box2.add_text_line("Hello Theree");
box2.display();
}
Dependencies
~0.2–7MB
~35K SLoC