From 973f316bc040e7f7b24c36a2cc464a7aa6a656f7 Mon Sep 17 00:00:00 2001 From: aaron-jack-manning Date: Sun, 21 Aug 2022 11:09:22 +1000 Subject: [PATCH] discarded status given in task view --- src/colour.rs | 4 ++++ src/tasks.rs | 6 ++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/colour.rs b/src/colour.rs index a36368f..48705fc 100644 --- a/src/colour.rs +++ b/src/colour.rs @@ -30,3 +30,7 @@ pub fn id(text : &str) -> colored::ColoredString { text.truecolor(52, 152, 219) } +// Grey +pub fn greyed_out(text : &str) -> colored::ColoredString { + text.truecolor(99, 110, 114) +} diff --git a/src/tasks.rs b/src/tasks.rs index 4233807..224f094 100644 --- a/src/tasks.rs +++ b/src/tasks.rs @@ -199,9 +199,11 @@ impl Task { } let id = &self.data.id.to_string(); - let heading = format!("[{}] {} {}", if self.data.complete {"X"} else {" "}, colour::id(&id), colour::task_name(&self.data.name)); + let discarded = if self.data.discarded { String::from(" (discarded)") } else { String::new() }; + let heading = format!("[{}] {} {}{}", if self.data.complete {"X"} else {" "}, colour::id(&id), colour::task_name(&self.data.name), colour::greyed_out(&discarded)); println!("{}", heading); - line(5 + self.data.name.len() + id.len()); + + line(5 + self.data.name.chars().count() + id.chars().count() + discarded.chars().count()); println!("Priority: {}", self.data.priority.coloured()); println!("Tags: [{}]", format_hash_set(&self.data.tags)?); println!("Created: {}", self.data.created);