use crate::*; mod column; pub use self::column::*; mod entry; pub use self::entry::*; mod metadata; pub use self::metadata::*; mod task; pub use self::task::*; /// The application state. pub struct Taggart { pub _root: PathBuf, pub entries: Vec, pub cursor: usize, pub offset: usize, pub column: usize, pub columns: ColumnsOption>, fn(&mut [Entry], usize, &str)>, pub display: Measure, pub tasks: Vec, pub mode: Option, } #[derive(Debug)] pub enum Mode { Help, Edit { value: String, index: usize, }, Apply { value: bool, }, Unsaved { value: u8 }, } impl Taggart { pub fn new (root: &impl AsRef, entries: Vec) -> Usually { Ok(Self { _root: root.as_ref().into(), cursor: 0, offset: 0, column: 2, display: Measure::new(), mode: None, columns: Columns::default(), tasks: vec![], entries, }) } } pub(crate) fn entries_under ( entries: &mut [Entry], index: usize ) -> Option>>> { let path = if let Some(Entry { path, info, .. }) = entries.get(index) && let Metadata::Directory { .. } = &*info.read().unwrap() { Some(path.clone()) } else { None }; if let Some(path) = path { let mut others = vec![]; for other in entries.iter_mut() { if other.path.starts_with(&path) && !other.is_directory() { others.push(other.info.clone()); } } Some(others) } else { None } }