open files with space

This commit is contained in:
🪞👃🪞 2025-03-09 04:47:44 +02:00
parent 8cc9418272
commit 41c5686d67
5 changed files with 137 additions and 33 deletions

View file

@ -1,9 +1,10 @@
use crate::*;
use opener::open;
macro_rules! press {
($key:tt) => {
($($key:tt)+) => {
Event::Key(KeyEvent {
code: KeyCode::$key,
code: KeyCode::$($key)+,
kind: KeyEventKind::Press,
modifiers: KeyModifiers::NONE,
state: KeyEventState::NONE
@ -16,14 +17,15 @@ impl Handle<TuiIn> for Taggart {
let x_min = self.offset;
let x_max = self.offset + self.size.h().saturating_sub(1);
match &*input.event() {
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!(Left) => { self.column = self.column.saturating_sub(1); },
press!(Right) => { self.column = self.column + 1; },
press!(Enter) => { self.editing = Some((self.cursor, self.column)); },
press!(Esc) => { self.editing = None; },
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!(Left) => { self.column = self.column.saturating_sub(1); },
press!(Right) => { self.column = self.column + 1; },
press!(Enter) => { self.editing = Some((self.cursor, self.column)); },
press!(Esc) => { self.editing = None; },
press!(Char(' ')) => { open(&self.paths[self.cursor].path)?; }
_ => {}
}
if self.cursor < x_min {