// Copyright (c) 2023-2025 R3BL LLC. Licensed under Apache License, Version 2.0.
usecrate::InputEvent;pubtraitKeyPressReader{fnread_key_press(&mutself)->Option<InputEvent>;}#[derive(Debug)]pubstructCrosstermKeyPressReader;implKeyPressReader forCrosstermKeyPressReader{fnread_key_press(&mutself)->Option<InputEvent>{let maybe_read =crossterm::event::read().ok()?;InputEvent::try_from(maybe_read).ok()}}#[derive(Debug)]pubstructTestVecKeyPressReader{pubkey_press_vec:Vec<InputEvent>,
pubindex:Option<usize>,
}implKeyPressReader forTestVecKeyPressReader{#[allow(clippy::unwrap_in_result)]/* This is only used in tests */fnread_key_press(&mutself)->Option<InputEvent>{// Increment index every time this function is called until the end of the vector
// and then wrap around.
matchself.index {Some(index)=>{if index <self.key_press_vec.len()-1{self.index =Some(index +1);}else{self.index =Some(0);}}None=>{self.index =Some(0);}}let index =self.index.unwrap();Some(self.key_press_vec[index].clone())}}