Arteiii / zenity

Rust CLIs with spinner animations, progress bars, and multiline support, plus user input validation
https://crates.io/crates/zenity
Other
51 stars 0 forks source link

Spinners overwrite several lines of existing terminal output #35

Closed toadslop closed 4 months ago

toadslop commented 4 months ago

Hey, great library! The spinners are beautiful and its pretty easy to use. When trying to integrate it into a CLI at work though, we found a bug that unfortunately makes it unusable in a production application. The problem is that the spinners overwrite some lines of existing terminal output, which might be important to the user. It would be great if you could fix this because we would love to use this library otherwise.

toadslop commented 4 months ago

Screencast from 2024年06月27日 09時55分20秒.webm

Arteiii commented 4 months ago

i have a few ideas and will take a look asap :3

thx for the report <3

Arteiii commented 4 months ago

Screencast_06_27_2024_12:35:18_PM.webm

added .clear method

Sets the number of rows to clear in the terminal before starting the animation. If no value is provided, the terminal will clear all rows by default, effectively clearing the screen without deleting old content, which might leave empty rows.

Example

use zenity::spinner::MultiSpinner;
use zenity::spinner::Frames;

let spinner = MultiSpinner::new();

// Clear with the default number of rows (entire terminal)
spinner.add(Frames::default());

// Clear with a specified number of rows (12)
spinner.clear(Some(12));

// Dont Clean anything
spinner.clear(None);

spinner.run_all()

Parameters

rows: An optional u16 specifying the number of rows to clear. If None, no rows will be cleared.

Arteiii commented 4 months ago

does this new method resolve your issue?

if not, please lmk