2026-07-12 11:28:39 +07:00
|
|
|
//! TUI mode definitions and per-mode input/action handlers, one submodule
|
|
|
|
|
//! per overlay/mode (bash, editor, effort, mcp, quit confirm, rewind, etc.).
|
2026-07-11 13:16:10 +07:00
|
|
|
pub mod bash;
|
2026-07-12 01:25:52 +07:00
|
|
|
pub mod editor;
|
|
|
|
|
pub mod effort;
|
|
|
|
|
pub mod key_input;
|
|
|
|
|
pub mod mcp;
|
2026-07-12 03:14:52 +07:00
|
|
|
|
2026-07-16 07:42:03 +07:00
|
|
|
pub mod learning;
|
2026-07-11 13:16:10 +07:00
|
|
|
pub mod quit_confirm;
|
2026-07-12 01:25:52 +07:00
|
|
|
pub mod rewind;
|
2026-07-11 13:16:10 +07:00
|
|
|
pub mod settings;
|
|
|
|
|
pub mod todo;
|
2026-07-18 01:59:42 +07:00
|
|
|
|
|
|
|
|
/// 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
|
|
|
|
|
}
|
|
|
|
|
}
|