use ncursesw::*;
fn main() {
if let Err(source) = menu_routine() {
eprintln!("error: {}", source);
}
}
fn menu_routine() -> Result<(), NCurseswError> {
initscr()?;
cbreak()?;
noecho()?;
curs_set(CursorType::Invisible)?;
keypad(stdscr(), true)?;
let mut origin = Origin { y: 5, x: 5 };
mvaddstr(origin, "Press <F1> to Quit or any other key to see result")?;
origin.y += 2;
mvaddstr(origin, "Result Type =")?;
origin.x = 19;
loop {
let result_type = get_wch()?;
r#move(origin)?;
clrtoeol()?;
match result_type {
CharacterResult::Key(result_type_as_keybinding) => { if result_type_as_keybinding == KeyBinding::FunctionKey(1) { break
} else {
mvaddstr(origin, format!("{:?}, KeyBinding = {:?}", result_type, result_type_as_keybinding))?;
}
},
CharacterResult::Character(result_type_as_widechar) => { if result_type_as_widechar.to_ascii_lowercase() == 'q' { mvaddstr(origin, format!("'{}' is not for quit.", result_type_as_widechar.as_char()?))?;
} else {
mvaddstr(origin, format!("{:?}, char = {}", result_type, result_type_as_widechar.as_char()?))?;
}
}
};
refresh()?;
}
endwin()
}