work on progress bar :3
This commit is contained in:
@@ -14,7 +14,7 @@ use crate::{
|
|||||||
|
|
||||||
static DOWNLOAD_CHAR: LazyLock<String> = LazyLock::new(|| "-".blue().bold().to_string());
|
static DOWNLOAD_CHAR: LazyLock<String> = LazyLock::new(|| "-".blue().bold().to_string());
|
||||||
static DONE_CHAR: LazyLock<String> = LazyLock::new(|| "#".green().bold().to_string());
|
static DONE_CHAR: LazyLock<String> = LazyLock::new(|| "#".green().bold().to_string());
|
||||||
const INFO_WIDTH: usize = 13;
|
static INPROGRESS_CHAR: LazyLock<String> = LazyLock::new(|| "-".purple().bold().to_string());
|
||||||
|
|
||||||
pub struct CopyPathsHandler;
|
pub struct CopyPathsHandler;
|
||||||
|
|
||||||
@@ -86,6 +86,12 @@ impl SubstitutionStatusHandler {
|
|||||||
.map(|&[_, expected, ..]| expected)
|
.map(|&[_, expected, ..]| expected)
|
||||||
.sum()
|
.sum()
|
||||||
}
|
}
|
||||||
|
fn get_running_copy(&self) -> u64 {
|
||||||
|
self.state_copy
|
||||||
|
.values()
|
||||||
|
.map(|&[_, expected, ..]| expected)
|
||||||
|
.sum()
|
||||||
|
}
|
||||||
|
|
||||||
fn get_unpacked(&self) -> u64 {
|
fn get_unpacked(&self) -> u64 {
|
||||||
self.state_copy.values().map(|&[done, ..]| done).sum()
|
self.state_copy.values().map(|&[done, ..]| done).sum()
|
||||||
@@ -97,13 +103,17 @@ impl SubstitutionStatusHandler {
|
|||||||
}
|
}
|
||||||
let dl_percent = ((self.get_done() as f64 / self.max_transfer as f64) * 100.0) as u64;
|
let dl_percent = ((self.get_done() as f64 / self.max_transfer as f64) * 100.0) as u64;
|
||||||
let ex_percent = ((self.get_unpacked() as f64 / self.max_copy as f64) * 100.0) as u64;
|
let ex_percent = ((self.get_unpacked() as f64 / self.max_copy as f64) * 100.0) as u64;
|
||||||
let expected = ((self.get_running() as f64 / self.get_done() as f64) * 100.0) as u64;
|
let expected = (((self.get_running() + self.get_running_copy()) as f64
|
||||||
|
/ (self.max_transfer + self.max_copy) as f64)
|
||||||
|
* 100.0) as u64;
|
||||||
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 exp = expected.saturating_sub(min + dl);
|
||||||
let mbar = MultiBar([
|
let mbar = MultiBar([
|
||||||
BarSegment::Dynamic(&DONE_CHAR, min),
|
BarSegment::Dynamic(&DONE_CHAR, min),
|
||||||
BarSegment::Dynamic(&DOWNLOAD_CHAR, dl),
|
BarSegment::Dynamic(&DOWNLOAD_CHAR, dl),
|
||||||
BarSegment::Dynamic(" ", 100 - min - dl),
|
BarSegment::Dynamic(&INPROGRESS_CHAR, exp),
|
||||||
|
BarSegment::Dynamic(" ", 100 - min - dl - exp),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
let work_per_sec = if self.get_done() < self.max_transfer {
|
let work_per_sec = if self.get_done() < self.max_transfer {
|
||||||
@@ -127,8 +137,8 @@ impl SubstitutionStatusHandler {
|
|||||||
StyledString::new(Cow::Owned("Downloading".to_string()), Style::new()),
|
StyledString::new(Cow::Owned("Downloading".to_string()), Style::new()),
|
||||||
StyledString::new(
|
StyledString::new(
|
||||||
Cow::Owned(format!(
|
Cow::Owned(format!(
|
||||||
"{}/{} {}",
|
"{}/{} {min} {dl} {expected}",
|
||||||
self.state_self[0], self.state_self[1], expected
|
self.state_self[0], self.state_self[1]
|
||||||
)),
|
)),
|
||||||
Style::new().purple(),
|
Style::new().purple(),
|
||||||
),
|
),
|
||||||
|
|||||||
Reference in New Issue
Block a user