mirror of
https://codeberg.org/unspeaker/perch.git
synced 2025-12-06 09:36:42 +01:00
63 lines
2.1 KiB
Rust
63 lines
2.1 KiB
Rust
use crate::*;
|
|
pub(crate) use tengri::tui::ratatui::style::Color;//, Style}, prelude::Stylize};
|
|
pub(crate) use pad::PadStr;
|
|
|
|
mod status; pub use self::status::*;
|
|
mod table; pub use self::table::*;
|
|
|
|
impl Taggart {
|
|
pub(crate) const FG_BROWSE: Color = Color::Rgb(255, 192, 0);
|
|
pub(crate) const BG_BROWSE: Color = Color::Rgb(0, 0, 0);
|
|
pub(crate) const BG_EDIT: Color = Color::Rgb(48, 128, 0);
|
|
pub(crate) const FG_EDIT: Color = Color::Rgb(255, 255, 255);
|
|
}
|
|
|
|
impl Content<TuiOut> for Taggart {
|
|
fn content (&self) -> impl Render<TuiOut> {
|
|
let sizer = Fill::xy(&self.display);
|
|
let size = format!("{}x{}", self.display.w(), self.display.h());
|
|
let titlebar = status_bar(Align::w(self.columns.header()));
|
|
let size_bar = status_bar(Fill::x(Bsp::a(
|
|
Fill::x(Align::w(Tui::bold(true, if self.editing.is_some() {
|
|
Bsp::e(
|
|
Tui::bg(Self::BG_EDIT, Tui::fg(Self::FG_EDIT, " EDIT ")),
|
|
" Esc to cancel, Enter to save"
|
|
)
|
|
} else {
|
|
Bsp::e(
|
|
Tui::bg(Self::BG_BROWSE, Tui::fg(Self::FG_BROWSE, " BROWSE ")),
|
|
" Q to exit, Arrows to select, Enter to edit"
|
|
)
|
|
}))),
|
|
Fill::x(Align::e(size)),
|
|
)));
|
|
Bsp::n(size_bar, Bsp::s(titlebar, Bsp::b(sizer, Fill::xy(TreeTable(self)))))
|
|
}
|
|
}
|
|
|
|
impl Entry {
|
|
pub fn name (&self) -> Option<Arc<str>> {
|
|
let indent = "".pad_to_width((self.depth - 1) * 2);
|
|
let icon = self.icon();
|
|
let name = self.path.iter().last().expect("empty path").display();
|
|
Some(format!("{indent}{icon} {name}").into())
|
|
}
|
|
fn icon (&self) -> &'static str {
|
|
if self.is_dir() {
|
|
"" //"+"
|
|
} else if self.is_img() {
|
|
""
|
|
} else if self.is_mus() {
|
|
""
|
|
} else {
|
|
"⁇"
|
|
}
|
|
}
|
|
//fn style (&self) -> Option<Style> {
|
|
//if self.is_dir() {
|
|
//None
|
|
//} else {
|
|
//Some(Style::default().bold())
|
|
//}
|
|
//}
|
|
}
|