//! Organize layouted entries into a list of lines to display.
//!
//! Additional information, such as the mapping from numbers to entries, are
//! collected along the way. The lines are not yet rendered into strings.
use std::collections::HashMap;
use chrono::NaiveDate;
use crate::eval::{Entry, EntryKind};
use crate::files::primitives::Time;
use crate::files::Files;
use super::super::error::{Error, Result};
use super::day::{DayEntry, DayLayout};
#[derive(Debug, Clone, Copy)]
pub enum SpanStyle {
Solid,
Dashed,
Dotted,
}
impl SpanStyle {
fn from_indentation(index: usize) -> Self {
match index % 3 {
0 => Self::Solid,
1 => Self::Dashed,
2 => Self::Dotted,
_ => unreachable!(),
}
}
}
#[derive(Debug, Clone, Copy)]
pub enum SpanSegment {
Start(SpanStyle),
Middle(SpanStyle),
End(SpanStyle),
}
impl SpanSegment {
fn style(&self) -> SpanStyle {
match self {
SpanSegment::Start(s) => *s,
SpanSegment::Middle(s) => *s,
SpanSegment::End(s) => *s,
}
}
}
#[derive(Debug, Clone, Copy)]
pub enum Times {
Untimed,
At(Time),
FromTo(Time, Time),
}
#[derive(Debug, Clone, Copy)]
pub enum LineKind {
Task,
Done,
Note,
Birthday,
}
pub enum LineEntry {
Day {
spans: Vec