add stylers; dim column separators; shrink columns; refactor handlers

This commit is contained in:
🪞👃🪞 2025-04-06 23:38:23 +03:00
parent 38f97558a7
commit 004cf96c2e
5 changed files with 70 additions and 43 deletions

View file

@ -39,18 +39,19 @@ impl Handle<TuiIn> for Taggart {
press!(F(1)) => { self.help_begin() },
press!(Char('q')) => { self.quit_begin(&input) },
press!(Char('w')) => { self.save_begin() },
press!(Enter) => { self.edit_begin() },
press!(Up) => { self.cursor = self.cursor.saturating_sub(1); },
press!(Down) => { self.cursor = self.cursor + 1; },
press!(PageUp) => { self.cursor = self.cursor.saturating_sub(PAGE_SIZE); },
press!(PageDown) => { self.cursor += PAGE_SIZE; },
press!(Char(' ')) => { self.open_in_player()?; },
press!(Left) => { self.column_prev(); },
press!(Right) => { self.column_next(); },
press!(Char('[')) => { self.column_resize(-1); },
press!(Char(']')) => { self.column_resize( 1); },
press!(Up) => { self.cursor_select(-1); },
press!(Down) => { self.cursor_select( 1); },
press!(PageUp) => { self.cursor_select(-(PAGE_SIZE as isize)); },
press!(PageDown) => { self.cursor_select( PAGE_SIZE as isize); },
press!(Left) => { self.column_select(-1); },
press!(Right) => { self.column_select( 1); },
press!(Char('[')) => { self.column_resize(-1); },
press!(Char(']')) => { self.column_resize( 1); },
press!(Char('{')) => { self.column_collapse(true, 1); },
press!(Char('}')) => { self.column_collapse(false, -1); },
press!(Delete) => { self.clear() },
press!(Enter) => { self.edit_begin() },
press!(Char(' ')) => { self.open_in_player()?; },
_ => {}
},
}
@ -60,15 +61,18 @@ impl Handle<TuiIn> for Taggart {
}
impl Taggart {
fn clear (&self) {
todo!("clear")
}
fn open_in_player (&self) -> Usually<()> {
open(self.entries[self.cursor].path.as_ref())?;
Ok(())
}
fn column_prev (&mut self) {
self.column = self.column.saturating_sub(1);
fn cursor_select (&mut self, amount: isize) {
self.cursor = ((self.cursor as isize) + amount).max(0) as usize;
}
fn column_next (&mut self) {
self.column = self.column + 1;
fn column_select (&mut self, amount: isize) {
self.column = ((self.column as isize) + amount).max(0) as usize;
}
fn column_resize (&mut self, amount: isize) {
let column = &mut self.columns.0[self.column];