use ratatui::crossterm::event::KeyCode;
pub const PAGE: usize = 10;
pub fn list_move(code: KeyCode, cursor: usize, len: usize) -> Option<usize> {
let last = len.saturating_sub(1);
let target = match code {
KeyCode::Char('j') | KeyCode::Down => (cursor + 1).min(last),
KeyCode::Char('k') | KeyCode::Up => cursor.saturating_sub(1),
KeyCode::Char('g') | KeyCode::Home => 0,
KeyCode::Char('G') | KeyCode::End => last,
KeyCode::PageDown => (cursor + PAGE).min(last),
KeyCode::PageUp => cursor.saturating_sub(PAGE),
_ => return None,
};
Some(target)
}