mirror of
https://codeberg.org/unspeaker/perch.git
synced 2025-12-07 01:56:45 +01:00
add hash column; update tengri
This commit is contained in:
parent
c3f826a7d4
commit
72bd6148d6
4 changed files with 46 additions and 32 deletions
34
src/view.rs
34
src/view.rs
|
|
@ -2,13 +2,16 @@ use crate::*;
|
|||
use tek_tui::ratatui::{style::{Color, Style}, prelude::Stylize};
|
||||
use pad::PadStr;
|
||||
|
||||
fn table_row (label: &str, artist: &str, album: &str, track: &str, title: &str) -> String {
|
||||
let label = label.pad_to_width(COLUMN_WIDTHS[0] as usize);
|
||||
let artist = artist.pad_to_width(COLUMN_WIDTHS[1] as usize);
|
||||
let album = album.pad_to_width(COLUMN_WIDTHS[2] as usize);
|
||||
let track = track.pad_to_width(COLUMN_WIDTHS[3] as usize);
|
||||
let title = title.pad_to_width(COLUMN_WIDTHS[4] as usize);
|
||||
format!("{label}│{artist}╎{album}╎{track}╎{title}")
|
||||
fn table_row (
|
||||
hash: Option<&str>, label: &str, artist: &str, album: &str, track: &str, title: &str
|
||||
) -> String {
|
||||
let hash = hash.unwrap_or("").pad_to_width(COLUMN_WIDTHS[0] as usize);
|
||||
let label = label.pad_to_width(COLUMN_WIDTHS[1] as usize);
|
||||
let artist = artist.pad_to_width(COLUMN_WIDTHS[2] as usize);
|
||||
let album = album.pad_to_width(COLUMN_WIDTHS[3] as usize);
|
||||
let track = track.pad_to_width(COLUMN_WIDTHS[4] as usize);
|
||||
let title = title.pad_to_width(COLUMN_WIDTHS[5] as usize);
|
||||
format!("{hash}│{label}│{artist}╎{album}╎{track}╎{title}")
|
||||
}
|
||||
|
||||
fn status_bar (content: impl Content<TuiOut>) -> impl Content<TuiOut> {
|
||||
|
|
@ -20,7 +23,9 @@ impl Content<TuiOut> for Taggart {
|
|||
let sizer = Fill::xy(&self.size);
|
||||
let size = format!("{}x{}", self.size.w(), self.size.h());
|
||||
let size_bar = status_bar(Align::e(size));
|
||||
let titlebar = status_bar(Align::w(table_row("FILE", "ARTIST", "RELEASE", "TRACK", "TITLE")));
|
||||
let titlebar = status_bar(Align::w(table_row(
|
||||
Some("HASH"), "FILE", "ARTIST", "RELEASE", "TRACK", "TITLE"
|
||||
)));
|
||||
let table = Fill::xy(TreeTable(self));
|
||||
Bsp::n(size_bar, Bsp::s(titlebar, Bsp::b(sizer, table)))
|
||||
}
|
||||
|
|
@ -65,12 +70,19 @@ impl<'a> Content<TuiOut> for TreeTable<'a> {
|
|||
};
|
||||
let name = fragment.display();
|
||||
let indent = "".pad_to_width((entry.depth - 1) * 2);
|
||||
let label = table_row(&format!("{cursor} {indent}{icon} {name}"), "", "", "", "");
|
||||
let label = table_row(
|
||||
entry.hash.as_deref(),
|
||||
&format!("{indent}{icon} {name}"),
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
""
|
||||
);
|
||||
to.blit(&label, area.x(), y, style);
|
||||
if selected {
|
||||
let fill = [area.x(), y, area.w(), 1];
|
||||
to.fill_bg(fill, Color::Rgb(48, 48, 48));
|
||||
to.fill_fg(fill, Color::Rgb(224, 192, 0));
|
||||
to.fill_fg(fill, Color::Rgb(0, 0, 0));
|
||||
to.fill_bg(fill, Color::Rgb(224, 192, 0));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue