mirror of
https://codeberg.org/unspeaker/perch.git
synced 2025-12-06 09:36:42 +01:00
open files with space
This commit is contained in:
parent
8cc9418272
commit
41c5686d67
5 changed files with 137 additions and 33 deletions
22
src/keys.rs
22
src/keys.rs
|
|
@ -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 {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue