make bar disappear on smaller terminals
This commit is contained in:
@@ -166,15 +166,23 @@ impl DownloadHandler {
|
||||
|
||||
let min = dl_percent.min(ex_percent);
|
||||
let dl = dl_percent.saturating_sub(min);
|
||||
let bar = MultiBar([
|
||||
BarSegment::Dynamic(&DONE_CHAR, min),
|
||||
BarSegment::Dynamic(&DOWNLOAD_CHAR, dl),
|
||||
BarSegment::Dynamic(" ", 100 - min - dl),
|
||||
])
|
||||
.scale((width - total_length as u16) as u64);
|
||||
|
||||
let len = total_length as u16;
|
||||
// if width <= len {
|
||||
// self.bar.set_message(format!(
|
||||
// "{}: {}/{}",
|
||||
// name,
|
||||
// total_done,
|
||||
// if total_expected == 0 {
|
||||
// "-".to_string()
|
||||
// } else {
|
||||
// total_expected.to_string()
|
||||
// }
|
||||
// ));
|
||||
// self.bar.tick();
|
||||
// return;
|
||||
// }
|
||||
let msg = match width {
|
||||
0..50 => {
|
||||
0..60 => {
|
||||
format!(
|
||||
"{}: {}/{}",
|
||||
name,
|
||||
@@ -187,7 +195,19 @@ impl DownloadHandler {
|
||||
)
|
||||
}
|
||||
_ => {
|
||||
format!("{status} {display} [{bar}]",)
|
||||
let bar = MultiBar([
|
||||
BarSegment::Dynamic(&DONE_CHAR, min),
|
||||
BarSegment::Dynamic(&DOWNLOAD_CHAR, dl),
|
||||
BarSegment::Dynamic(" ", 100 - min - dl),
|
||||
])
|
||||
.scale((width.saturating_sub(total_length as u16)) as u64);
|
||||
let bar = if width > display_length as u16 + status_len as u16 {
|
||||
format!("[{}]", bar)
|
||||
} else {
|
||||
String::new()
|
||||
};
|
||||
|
||||
format!("{status} {display} {bar}",)
|
||||
}
|
||||
};
|
||||
self.bar.set_message(msg);
|
||||
|
||||
Reference in New Issue
Block a user