chore: struct Taggart -> Perch

This commit is contained in:
🪞👃🪞 2025-04-09 01:17:04 +03:00
parent 44315dcc72
commit 332869c5cb
12 changed files with 15 additions and 15 deletions

View file

@ -25,7 +25,7 @@ mod save;
mod quit;
mod help;
impl Handle<TuiIn> for Taggart {
impl Handle<TuiIn> for Perch {
fn handle (&mut self, input: &TuiIn) -> Perhaps<bool> {
let min = self.offset;
let max = self.offset + self.display.h().saturating_sub(1);
@ -60,7 +60,7 @@ impl Handle<TuiIn> for Taggart {
}
}
impl Taggart {
impl Perch {
fn open_in_player (&self) -> Usually<()> {
open(self.entries[self.cursor].path.as_ref())?;
Ok(())

View file

@ -1,6 +1,6 @@
use crate::*;
impl Taggart {
impl Perch {
pub fn handle_edit (&mut self, event: &Event) {
match event {
press!(Char(c)) => self.edit_insert(*c),

View file

@ -1,6 +1,6 @@
use crate::*;
impl Taggart {
impl Perch {
pub fn handle_help (&mut self, event: &Event, _page: u8) {
match event {
press!(Esc) => { self.mode = None },

View file

@ -1,6 +1,6 @@
use crate::*;
impl Taggart {
impl Perch {
pub fn handle_quit (&mut self, input: &TuiIn, choice: u8) {
match &*input.event() {
press!(Esc) => { self.mode = None },

View file

@ -1,6 +1,6 @@
use crate::*;
impl Taggart {
impl Perch {
pub fn handle_save (&mut self, event: &Event, choice: u8) {
match event {
press!(Esc) => { self.mode = None }

View file

@ -52,7 +52,7 @@ fn main () -> Usually<()> {
if let Ok(results) = Arc::try_unwrap(results) {
let mut results = results.into_inner()?;
results.sort();
let state = Arc::new(RwLock::new(Taggart::new(&path, results)?));
let state = Arc::new(RwLock::new(Perch::new(&path, results)?));
if let Some(true) = args.get_one::<bool>("check") {
return Ok(())
}

View file

@ -5,7 +5,7 @@ mod column; pub use self::column::*;
mod entry; pub use self::entry::*;
/// The application state.
pub struct Taggart {
pub struct Perch {
pub _root: PathBuf,
pub entries: Vec<Entry>,
pub cursor: usize,
@ -32,7 +32,7 @@ pub enum Mode {
Quit { choice: u8, },
}
impl Taggart {
impl Perch {
pub fn new (root: &impl AsRef<Path>, entries: Vec<Entry>) -> Usually<Self> {
Ok(Self {
_root: root.as_ref().into(),

View file

@ -63,7 +63,7 @@ pub struct Columns<G, S, U>(pub Vec<Column<G, S, U>>);
macro_rules! setter {
($set:ident) => {{
fn $set (state: &mut Taggart, index: usize, value: Option<&str>) {
fn $set (state: &mut Perch, index: usize, value: Option<&str>) {
if let Some(entries) = entries_under(&mut state.entries, index) {
for (_path, entry) in entries.into_iter() {
if entry.write().unwrap().$set(value) {
@ -82,7 +82,7 @@ macro_rules! setter {
impl Default for Columns<
fn(&Entry)->Option<Arc<str>>,
fn(&mut Taggart, usize, Option<&str>),
fn(&mut Perch, usize, Option<&str>),
fn(&Entry)->Option<Style>,
> {
fn default () -> Self {

View file

@ -6,7 +6,7 @@ mod table; pub use self::table::*;
mod dialog;
mod status;
impl Content<TuiOut> for Taggart {
impl Content<TuiOut> for Perch {
fn content (&self) -> impl Render<TuiOut> {
let w = self.display.w();
let h = self.display.h();

View file

@ -1,6 +1,6 @@
use crate::*;
impl Taggart {
impl Perch {
fn dialog (content: impl Content<TuiOut>) -> impl Content<TuiOut> {
let pos = |x|Fill::xy( Align::c(x));
let style = |x|Tui::modify(false, Modifier::DIM, Tui::fg_bg(FG_MODAL, BG_MODAL, x));

View file

@ -1,6 +1,6 @@
use crate::*;
impl Taggart {
impl Perch {
pub(crate) fn title_bar (&self) -> impl Content<TuiOut> {
status_bar(
Color::Rgb(0, 0, 0),

View file

@ -1,6 +1,6 @@
use crate::*;
pub struct TreeTable<'a>(pub(crate) &'a Taggart);
pub struct TreeTable<'a>(pub(crate) &'a Perch);
impl<'a> Content<TuiOut> for TreeTable<'a> {
fn render (&self, to: &mut TuiOut) {