highlight selected column

This commit is contained in:
🪞👃🪞 2025-03-03 20:33:23 +02:00
parent b3a52c171b
commit 01bc1b7b47
3 changed files with 53 additions and 11 deletions

View file

@ -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)
}
}