mirror of
https://codeberg.org/unspeaker/perch.git
synced 2025-12-06 17:46:42 +01:00
allow columns to be resized
This commit is contained in:
parent
23c3ce82b8
commit
c3676e7b62
1 changed files with 14 additions and 11 deletions
25
src/keys.rs
25
src/keys.rs
|
|
@ -26,6 +26,20 @@ impl Handle<TuiIn> for Taggart {
|
|||
let x_max = self.offset + self.size.h().saturating_sub(1);
|
||||
let event = &*input.event();
|
||||
match &self.editing {
|
||||
None => match 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.edit_begin() },
|
||||
press!(Char(' ')) => { open(&self.paths[self.cursor].path)?; }
|
||||
press!(Char(']')) => { self.columns.0[self.column].width += 1; }
|
||||
press!(Char('[')) => { self.columns.0[self.column].width =
|
||||
self.columns.0[self.column].width.saturating_sub(1).max(5); }
|
||||
_ => {}
|
||||
},
|
||||
Some(_value) => match event {
|
||||
press!(Char(c)) => self.edit_insert(*c),
|
||||
press!(Shift-Char(c)) => self.edit_insert(c.to_uppercase().next().unwrap()),
|
||||
|
|
@ -35,17 +49,6 @@ impl Handle<TuiIn> for Taggart {
|
|||
press!(Esc) => self.edit_confirm(),
|
||||
_ => {}
|
||||
},
|
||||
None => match 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!(Char(' ')) => { open(&self.paths[self.cursor].path)?; }
|
||||
press!(Enter) => self.edit_begin(),
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
if self.cursor < x_min {
|
||||
self.offset = self.cursor;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue