//! TUI mode definitions and per-mode input/action handlers, one submodule //! per overlay/mode (bash, editor, effort, mcp, quit confirm, rewind, etc.). //! Each mode encapsulates its own keyboard input parsing, state transitions, //! and view rendering so the top-level event loop can dispatch generically. pub mod bash; // Shell-command input overlay: prompt, history, execution pub mod editor; // Multi-line text editor overlay (write/edit tool content) pub mod effort; // Reasoning-effort selector overlay pub mod key_input; // Generic single-key prompt overlay (e.g. rename, search) pub mod mcp; // MCP tool argument builder overlay pub mod learning; // Learning/reflection input overlay pub mod quit_confirm; // Quit confirmation dialog overlay pub mod rewind; // Rewind/undo checkpoint selection overlay pub mod settings; // Settings panel overlay pub mod todo; // TODO-list management overlay /// 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 } }