Crates.io | borderline |
lib.rs | borderline |
version | 1.0.0 |
source | src |
created_at | 2023-11-08 18:48:03.456388 |
updated_at | 2023-11-08 18:48:03.456388 |
description | A simple crate to use borders in your terminal. |
homepage | https://devops.tsommer.org/open-source/rust/crates/borderline |
repository | https://devops.tsommer.org/open-source/rust/crates/borderline |
max_upload_size | |
id | 1029268 |
size | 15,842 |
Borderline is a Crate to render borders to the terminal. You can place text or progress bars inside the borders. The usage is as simple as:
use borderline::LineBuilder;
// Create a line builder:
let mut lb = LineBuilder::new();
// Print the header first:
borderline::print_header("Borderline Test-Drive");
// Now, we are able to attach as many "line" as we want.
// Every line must be started with a call to `line_begin`
// and ended with a call to `line_end`:
lb.line_begin("- Loading...");
// perform other actions here...
// When ending a line, you can specify the second part
// of the line, which will be printed on the right side:
lb.line_end("done.");
// You can also print a progress bar:
lb.line_begin("- Loading many files:");
// Set up the progress bar using the total number of steps:
lb.progress_bar_setup(1_000);
// Do some work and update the progress bar:
for i in 0..1_000 {
sleep(std::time::Duration::from_millis(50));
lb.progress_bar_update(i);
}
// End the progress bar:
lb.progressbar_end();
// End the line and print the second text part:
lb.line_end("done.");
// At the end, we can print the closing border:
borderline::print_border();
While the progress bar is active:
When the program is done:
In case that the given text is too long, it gets wrapped at word boundaries. When this is not possible, the text is wrapped at the given width.