mirror of
https://codeberg.org/unspeaker/perch.git
synced 2025-12-07 10:06:44 +01:00
better column resizing
This commit is contained in:
parent
44a2108585
commit
4de94beafb
9 changed files with 403 additions and 359 deletions
37
src/keys.rs
37
src/keys.rs
|
|
@ -43,13 +43,14 @@ impl Handle<TuiIn> for Taggart {
|
|||
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.entries[self.cursor].path.as_ref())?; }
|
||||
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); }
|
||||
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!(Char('{')) => { self.column_collapse(true, 1); },
|
||||
press!(Char('}')) => { self.column_collapse(false, -1); },
|
||||
_ => {}
|
||||
},
|
||||
}
|
||||
|
|
@ -57,3 +58,25 @@ impl Handle<TuiIn> for Taggart {
|
|||
Ok(None)
|
||||
}
|
||||
}
|
||||
|
||||
impl Taggart {
|
||||
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 column_next (&mut self) {
|
||||
self.column = self.column + 1;
|
||||
}
|
||||
fn column_resize (&mut self, amount: isize) {
|
||||
let column = &mut self.columns.0[self.column];
|
||||
column.width = ((column.width as isize) + amount).max(0) as usize;
|
||||
}
|
||||
fn column_collapse (&mut self, value: bool, next: isize) {
|
||||
let column = &mut self.columns.0[self.column];
|
||||
column.collapsed = value;
|
||||
self.column = ((self.column as isize) + next).max(0) as usize;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue