extern crate alloc; use tui_orchestrator::input::{default_bindings, ComponentAction, InputError, InputSource, Key}; struct MockInput { keys: alloc::vec::Vec, index: usize, } impl MockInput { fn new(keys: alloc::vec::Vec) -> Self { Self { keys, index: 0 } } } impl InputSource for MockInput { fn read_key(&mut self) -> Result { if self.index < self.keys.len() { let key = self.keys[self.index]; self.index += 1; Ok(key) } else { Err(InputError::BackendError) } } } fn main() { let bindings = default_bindings(); let mut input = MockInput::new(alloc::vec![Key::tab(), Key::enter(), Key::esc(),]); loop { match input.read_key() { Ok(key) => { if let Some(action) = bindings.get(&key) { match action { ComponentAction::Next => println!("Next"), ComponentAction::Select => println!("Select"), ComponentAction::Cancel => { println!("Cancel - exiting"); break; } _ => println!("Other action: {:?}", action), } } else { println!("No binding for key: {:?}", key); } } Err(e) => { println!("Error: {:?}", e); break; } } } }