borderline

Crates.ioborderline
lib.rsborderline
version1.0.0
sourcesrc
created_at2023-11-08 18:48:03.456388
updated_at2023-11-08 18:48:03.456388
descriptionA simple crate to use borders in your terminal.
homepagehttps://devops.tsommer.org/open-source/rust/crates/borderline
repositoryhttps://devops.tsommer.org/open-source/rust/crates/borderline
max_upload_size
id1029268
size15,842
Thorsten Sommer (SommerEngineering)

documentation

README

Borderline

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: progressbar.png

When the program is done: done.png

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.

Changelog

Version 1.0.0

  • Initial release
Commit count: 0

cargo fmt