//! hexwork-ui: screen stack + HUD + log (docs/04 §4.6). //! Full keyboard play mandatory; every mouse action has a key twin. pub mod board; pub mod chapel; pub mod death_ui; pub mod explore; pub mod hud; pub mod identify_ui; pub mod inventory; pub mod logfmt; pub mod look; pub mod screens; pub mod settings; pub mod sheet; pub mod stream; pub mod text; pub mod town; pub mod transfer; pub mod undo; /// Screens in the stack: Title → Chargen → Play → … → Death/Replay. #[derive(Clone, Copy, Debug, PartialEq, Eq)] pub enum Screen { Title, Chargen, Play, Look, Inventory, Contracts, Map, Chapel, Death, Replay, } /// Searchable message log. NetHack voice lives here. #[derive(Clone, Debug, Default)] pub struct Log { lines: Vec, } impl Log { pub fn new() -> Self { Self::default() } pub fn push(&mut self, line: impl Into) { self.lines.push(line.into()); } /// Case-insensitive substring search (the `/` key). pub fn search(&self, query: &str) -> Vec<&str> { let q = query.to_lowercase(); self.lines .iter() .filter(|l| l.to_lowercase().contains(&q)) .map(|s| s.as_str()) .collect() } pub fn lines(&self) -> &[String] { &self.lines } } #[cfg(test)] mod tests { use super::*; #[test] fn log_search_is_case_insensitive() { let mut log = Log::new(); log.push("You smell ozone and wet wool."); assert_eq!(log.search("OZONE").len(), 1); assert!(log.search("dragon").is_empty()); } }