mirror of
https://codeberg.org/unspeaker/perch.git
synced 2025-12-06 17:46:42 +01:00
tabula rasa
This commit is contained in:
commit
2b855f43d7
9 changed files with 1601 additions and 0 deletions
39
src/view.rs
Normal file
39
src/view.rs
Normal 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
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue