mirror of
https://codeberg.org/unspeaker/perch.git
synced 2025-12-06 09:36:42 +01:00
properly trimmed columns, only a bit misaligned
This commit is contained in:
parent
53132da551
commit
c67d3c8803
2 changed files with 40 additions and 49 deletions
2
Justfile
2
Justfile
|
|
@ -16,3 +16,5 @@ doc:
|
||||||
|
|
||||||
build-release:
|
build-release:
|
||||||
time cargo build -j4 --release
|
time cargo build -j4 --release
|
||||||
|
run:
|
||||||
|
cargo run -- -j16 ~/Music
|
||||||
|
|
|
||||||
87
src/view.rs
87
src/view.rs
|
|
@ -1,5 +1,6 @@
|
||||||
use crate::*;
|
use crate::*;
|
||||||
use tengri::tui::ratatui::{style::{Color, Style}, prelude::Stylize};
|
use tengri::tui::ratatui::{style::{Color, Style}, prelude::Stylize};
|
||||||
|
use std::sync::atomic::{AtomicU16, Ordering::Relaxed};
|
||||||
pub(crate) use pad::PadStr;
|
pub(crate) use pad::PadStr;
|
||||||
|
|
||||||
mod column; pub use self::column::*;
|
mod column; pub use self::column::*;
|
||||||
|
|
@ -18,58 +19,46 @@ impl Content<TuiOut> for Taggart {
|
||||||
struct TreeTable<'a>(&'a Taggart);
|
struct TreeTable<'a>(&'a Taggart);
|
||||||
|
|
||||||
impl<'a> Content<TuiOut> for TreeTable<'a> {
|
impl<'a> Content<TuiOut> for TreeTable<'a> {
|
||||||
fn content (&self) -> impl Render<TuiOut> {
|
fn render (&self, to: &mut TuiOut) {
|
||||||
|
let area = to.area();
|
||||||
let Taggart { offset, paths, cursor, column, .. } = self.0;
|
let Taggart { offset, paths, cursor, column, .. } = self.0;
|
||||||
let mut dy = 0;
|
let (x, w) = self.0.columns.xw(*column);
|
||||||
let offset = *offset;
|
to.fill_bg([area.x() + x, area.y(), w, area.h()], Color::Rgb(0, 0, 0));
|
||||||
let height = self.0.size.h();
|
for (i, y) in area.iter_y().enumerate() {
|
||||||
Map::new(
|
let i_offset = i + offset;
|
||||||
move||offset..(offset + height),
|
let selected = *cursor == i_offset;
|
||||||
move|row, y: usize|{
|
let mut x = area.x();
|
||||||
let mut dx = 0;
|
if let Some(entry) = paths.get(i_offset) {
|
||||||
map_south(y as u16, 1, Map::new(
|
for (index, _fragment) in entry.path.iter().enumerate() {
|
||||||
move||self.0.columns.0.iter(),
|
if index == entry.depth - 1 {
|
||||||
move|column: &Column<_>, x: usize|{
|
let _cursor = if selected { ">" } else { " " };
|
||||||
dx = dx + column.width;
|
to.area[1] = y;
|
||||||
map_east((dx - column.width) as u16, 1, "test")
|
for Column { width, value, .. } in self.0.columns.0.iter() {
|
||||||
|
to.area[0] = x;
|
||||||
|
if let Some(value) = value(entry) {
|
||||||
|
Content::render(&TrimStringRef(*width as u16, &value), to);
|
||||||
|
}
|
||||||
|
x += *width as u16;
|
||||||
|
}
|
||||||
|
if selected {
|
||||||
|
let fill = [area.x(), y, area.w(), 1];
|
||||||
|
to.fill_fg(fill, Color::Rgb(0, 0, 0));
|
||||||
|
to.fill_bg(fill, Color::Rgb(192, 128, 0));
|
||||||
|
let fill = [area.x() + x as u16, y, w, 1];
|
||||||
|
to.fill_bg(fill, Color::Rgb(224, 192, 0));
|
||||||
|
if let Some((_index, value)) = &self.0.editing {
|
||||||
|
let x = area.x() + if x > 0 { x + 1 } else { x } as u16;
|
||||||
|
to.blit(&value, x, y, None)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
))
|
}
|
||||||
})
|
} else {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
to.area = area;
|
||||||
}
|
}
|
||||||
|
|
||||||
//fn render (&self, to: &mut TuiOut) {
|
|
||||||
////let area = to.area();
|
|
||||||
////let Taggart { offset, paths, cursor, column, .. } = self.0;
|
|
||||||
////let (x, w) = self.0.columns.xw(*column);
|
|
||||||
////to.fill_bg([area.x() + x, area.y(), w, area.h()], Color::Rgb(0, 0, 0));
|
|
||||||
////for (i, y) in area.iter_y().enumerate() {
|
|
||||||
////let i_offset = i + offset;
|
|
||||||
////let selected = *cursor == i_offset;
|
|
||||||
////if let Some(entry) = paths.get(i_offset) {
|
|
||||||
////for (index, _fragment) in entry.path.iter().enumerate() {
|
|
||||||
////if index == entry.depth - 1 {
|
|
||||||
////let _cursor = if selected { ">" } else { " " };
|
|
||||||
////let label = self.0.columns.row_content(&entry);
|
|
||||||
//////Content::render(&label)
|
|
||||||
////to.blit(&label, area.x(), y, entry.style());
|
|
||||||
////if selected {
|
|
||||||
////let fill = [area.x(), y, area.w(), 1];
|
|
||||||
////to.fill_fg(fill, Color::Rgb(0, 0, 0));
|
|
||||||
////to.fill_bg(fill, Color::Rgb(192, 128, 0));
|
|
||||||
////let fill = [area.x() + x as u16, y, w, 1];
|
|
||||||
////to.fill_bg(fill, Color::Rgb(224, 192, 0));
|
|
||||||
////if let Some((_index, value)) = &self.0.editing {
|
|
||||||
////let x = area.x() + if x > 0 { x + 1 } else { x } as u16;
|
|
||||||
////to.blit(&value, x, y, None)
|
|
||||||
////}
|
|
||||||
////}
|
|
||||||
////}
|
|
||||||
////}
|
|
||||||
////} else {
|
|
||||||
////break
|
|
||||||
////}
|
|
||||||
////}
|
|
||||||
//}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Entry {
|
impl Entry {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue