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 min = dl_percent.min(ex_percent);
|
||||||
let dl = dl_percent.saturating_sub(min);
|
let dl = dl_percent.saturating_sub(min);
|
||||||
let bar = MultiBar([
|
let len = total_length as u16;
|
||||||
BarSegment::Dynamic(&DONE_CHAR, min),
|
// if width <= len {
|
||||||
BarSegment::Dynamic(&DOWNLOAD_CHAR, dl),
|
// self.bar.set_message(format!(
|
||||||
BarSegment::Dynamic(" ", 100 - min - dl),
|
// "{}: {}/{}",
|
||||||
])
|
// name,
|
||||||
.scale((width - total_length as u16) as u64);
|
// total_done,
|
||||||
|
// if total_expected == 0 {
|
||||||
|
// "-".to_string()
|
||||||
|
// } else {
|
||||||
|
// total_expected.to_string()
|
||||||
|
// }
|
||||||
|
// ));
|
||||||
|
// self.bar.tick();
|
||||||
|
// return;
|
||||||
|
// }
|
||||||
let msg = match width {
|
let msg = match width {
|
||||||
0..50 => {
|
0..60 => {
|
||||||
format!(
|
format!(
|
||||||
"{}: {}/{}",
|
"{}: {}/{}",
|
||||||
name,
|
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);
|
self.bar.set_message(msg);
|
||||||
|
|||||||
Reference in New Issue
Block a user