fix jrnl not working anymore

This commit is contained in:
Schrottkatze 2024-10-11 08:49:54 +02:00
parent be22d9da42
commit 5c16f2df1b
Signed by: schrottkatze
SSH key fingerprint: SHA256:hXb3t1vINBFCiDCmhRABHX5ocdbLiKyCdKI4HK2Rbbc
4 changed files with 17 additions and 91 deletions

View file

@ -14,5 +14,5 @@ owo-colors = "4.0.0"
petgraph = "0.6.4"
ratatui = "0.26.2"
temp-file = "0.1.8"
termsize = "0.1.6"
termsize = "0.1.9"
inquire = "0.7.5"

View file

@ -7,13 +7,18 @@ pub fn list_entries(path: PathBuf) -> io::Result<()> {
let file = fs::read_to_string(path)?;
if let Some(doc) = Doc::new(&file) {
// TODO: testing, so this shit doesn't blow the fuck up in our face anymore
let termsize::Size { cols, .. } = termsize::get().unwrap();
assert!(cols > 0, "we don't have a terminal width.");
for (i, entry) in doc.entries.into_iter().enumerate() {
let n = format!("{:>2}", i + 1);
let r = format!(". {}", entry.title,);
let l = format!(" {} ", crate::utils::format_datetime(entry.timestamp));
let padding = " ".repeat(cols as usize - (n.len() + r.len() + l.len()));
let fuck_you_debugging = cols as usize - (n.len() + r.chars().count() + l.len());
dbg!(fuck_you_debugging);
let padding = " ".repeat(fuck_you_debugging);
println!("{}{r}{padding}{}", n.cyan(), l.white())
}