Fix: wrong width for Unicode characters
This commit is contained in:
parent
34efe371ef
commit
7480d79603
7
Cargo.lock
generated
7
Cargo.lock
generated
@ -105,6 +105,7 @@ name = "gitea-timings"
|
|||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"serde",
|
"serde",
|
||||||
|
"unicode-width",
|
||||||
"ureq",
|
"ureq",
|
||||||
]
|
]
|
||||||
|
|
||||||
@ -485,6 +486,12 @@ dependencies = [
|
|||||||
"tinyvec",
|
"tinyvec",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "unicode-width"
|
||||||
|
version = "0.1.8"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "9337591893a19b88d8d87f2cec1e73fad5cdfd10e5a6f349f498ad6ea2ffb1e3"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "unicode-xid"
|
name = "unicode-xid"
|
||||||
version = "0.2.1"
|
version = "0.2.1"
|
||||||
|
@ -6,4 +6,5 @@ edition = "2018"
|
|||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
serde = "1.0.117"
|
serde = "1.0.117"
|
||||||
|
unicode-width = "0.1.8"
|
||||||
ureq = { version = "1.5.2", features = ["json"] }
|
ureq = { version = "1.5.2", features = ["json"] }
|
||||||
|
12
src/main.rs
12
src/main.rs
@ -2,6 +2,7 @@ use std::collections::HashMap;
|
|||||||
use std::fs;
|
use std::fs;
|
||||||
|
|
||||||
use serde::Deserialize;
|
use serde::Deserialize;
|
||||||
|
use unicode_width::UnicodeWidthStr;
|
||||||
|
|
||||||
#[derive(Deserialize)]
|
#[derive(Deserialize)]
|
||||||
struct TrackedTime {
|
struct TrackedTime {
|
||||||
@ -50,10 +51,9 @@ fn main() {
|
|||||||
times.sort_unstable_by(|a, b| a.0.cmp(&b.0).reverse().then(a.1.cmp(&b.1)));
|
times.sort_unstable_by(|a, b| a.0.cmp(&b.0).reverse().then(a.1.cmp(&b.1)));
|
||||||
|
|
||||||
println!(
|
println!(
|
||||||
"In the last 24 hours, you spent {} hours, {} minutes and {} seconds on {} issues{}",
|
"You spent {} hours and {} minutes on {} issues in the last 24 hours{}",
|
||||||
seconds / 3600,
|
seconds / 3600,
|
||||||
seconds / 60 % 60,
|
(seconds + 30) / 60 % 60,
|
||||||
seconds % 60,
|
|
||||||
times.len(),
|
times.len(),
|
||||||
if times.is_empty() { '.' } else { ':' }
|
if times.is_empty() { '.' } else { ':' }
|
||||||
);
|
);
|
||||||
@ -69,7 +69,11 @@ fn main() {
|
|||||||
time % 60,
|
time % 60,
|
||||||
title
|
title
|
||||||
);
|
);
|
||||||
println!("{}{}|", line, " ".repeat(separator.len() - line.len() - 1));
|
println!(
|
||||||
|
"{}{}|",
|
||||||
|
line,
|
||||||
|
" ".repeat(separator.len() - line.width() - 1)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
println!("{}", separator);
|
println!("{}", separator);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user