tabula rasa

This commit is contained in:
🪞👃🪞 2025-03-02 18:00:19 +02:00
commit 2b855f43d7
9 changed files with 1601 additions and 0 deletions

39
src/view.rs Normal file
View file

@ -0,0 +1,39 @@
use crate::*;
use pad::PadStr;
impl Content<TuiOut> for Taggart {
fn layout (&self, area: [u16;4]) -> [u16;4] {
[area.x(), area.y(), 20, area.h()]
}
fn render (&self, to: &mut TuiOut) {
let area = to.area();
for (i, y) in area.iter_y().enumerate() {
let i_offset = i + self.offset;
if let Some(entry) = self.paths.get(i_offset) {
if entry.depth > 0 {
for (index, fragment) in entry.path.iter().enumerate() {
if index == entry.depth - 1 {
let cursor = if self.cursor == i_offset { ">" } else { " " };
let icon = if entry.is_dir {"+"} else {" "};
let name = fragment.display();
let indent = "".pad_to_width((entry.depth - 1) * 2);
let label = format!("{cursor} {indent}{icon} {name}");
let label = format!("{label:80} ARTIST ALBUM TITLE");
to.blit(&label, area.x(), y, None);
}
}
}
} else {
break
}
}
}
}
fn depth_of (path: &PathBuf) -> usize {
let mut depth = 0;
for _ in path.iter() {
depth += 1;
}
depth
}