Files
zesdex/crates/zesdex-backend/src/app/mode/mod.rs
T

33 lines
837 B
Rust
Raw Normal View History

//! TUI mode definitions and per-mode input/action handlers, one submodule
//! per overlay/mode (bash, editor, effort, mcp, quit confirm, rewind, etc.).
pub mod bash;
pub mod editor;
pub mod effort;
pub mod key_input;
pub mod mcp;
pub mod learning;
pub mod quit_confirm;
pub mod rewind;
pub mod settings;
pub mod todo;
/// Cycle `current` in the range `[0, len)`.
///
/// * `forward = true` — increment (wrap at len)
/// * `forward = false` — decrement (wrap at 0), saturating at 0 when len is 0
///
/// Return: `0` when `len == 0`, otherwise the wrapped index.
pub fn cycle_selected_index(current: usize, len: usize, forward: bool) -> usize {
if len == 0 {
return 0;
}
if forward {
(current + 1) % len
} else if current == 0 {
len.saturating_sub(1)
} else {
current - 1
}
}