use std::cmp; use chrono::{Datelike, NaiveDate}; use colored::{ColoredString, Colorize}; use crate::files::primitives::{Time, Weekday}; use super::layout::line::{LineEntry, LineKind, LineLayout, SpanSegment, SpanStyle, Times}; struct ShowLines { num_width: usize, span_width: usize, result: String, } impl ShowLines { fn new(num_width: usize, span_width: usize) -> Self { Self { num_width, span_width, result: String::new(), } } fn display_line(&mut self, line: &LineEntry) { match line { LineEntry::Day { spans, date, today, has_log, } => self.display_line_date(spans, *date, *today, *has_log), LineEntry::Now { spans, time } => self.display_line_now(spans, *time), LineEntry::Entry { number, spans, time, kind, text, has_desc, extra, } => self.display_line_entry(*number, spans, *time, *kind, text, *has_desc, extra), } } fn display_line_date( &mut self, spans: &[Option], date: NaiveDate, today: bool, has_log: bool, ) { let weekday: Weekday = date.weekday().into(); let weekday = weekday.full_name(); let styled = |s: &str| { if today { s.bright_cyan().bold() } else { s.cyan() } }; // '=' symbols before the spans start let p1 = format!("{:=