mirror of
https://codeberg.org/unspeaker/perch.git
synced 2025-12-06 17:46:42 +01:00
highlight selected column
This commit is contained in:
parent
b3a52c171b
commit
01bc1b7b47
3 changed files with 53 additions and 11 deletions
21
src/keys.rs
21
src/keys.rs
|
|
@ -1,7 +1,5 @@
|
|||
use crate::*;
|
||||
|
||||
const PAGE_SIZE: usize = 10;
|
||||
|
||||
impl Handle<TuiIn> for Taggart {
|
||||
fn handle (&mut self, input: &TuiIn) -> Perhaps<bool> {
|
||||
let x_min = self.offset;
|
||||
|
|
@ -39,6 +37,22 @@ impl Handle<TuiIn> for Taggart {
|
|||
}) => {
|
||||
self.cursor += PAGE_SIZE;
|
||||
},
|
||||
Event::Key(KeyEvent {
|
||||
code: KeyCode::Left,
|
||||
kind: KeyEventKind::Press,
|
||||
modifiers: KeyModifiers::NONE,
|
||||
state: KeyEventState::NONE
|
||||
}) => {
|
||||
self.column = self.column.saturating_sub(1);
|
||||
},
|
||||
Event::Key(KeyEvent {
|
||||
code: KeyCode::Right,
|
||||
kind: KeyEventKind::Press,
|
||||
modifiers: KeyModifiers::NONE,
|
||||
state: KeyEventState::NONE
|
||||
}) => {
|
||||
self.column = self.column + 1;
|
||||
},
|
||||
_ => {}
|
||||
}
|
||||
if self.cursor < x_min {
|
||||
|
|
@ -50,6 +64,9 @@ impl Handle<TuiIn> for Taggart {
|
|||
if self.cursor >= self.paths.len() {
|
||||
self.cursor = self.paths.len().saturating_sub(1)
|
||||
}
|
||||
if self.column + 1 > COLUMN_COUNT {
|
||||
self.column = COLUMN_COUNT.saturating_sub(1)
|
||||
}
|
||||
Ok(None)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue