extern crate ncurseswwin;
use std::process::exit;
use ncurseswwin::*;
macro_rules! result { ($type: ty) => { Result<$type, NCurseswWinError> } }
fn main() {
match ncursesw_entry(|stdscr| {
set_input_mode(InputMode::Character)?;
set_echo(false)?;
set_newline(false)?;
intrflush(false)?;
cursor_set(CursorType::Visible)?;
ncursesw_entry_test_pass(stdscr)?;
Ok(ncursesw_entry_test_fail()?)
}) {
Err(source) => {
if let Some(err) = source.downcast_ref::<NCurseswWinError>() {
match err {
NCurseswWinError::Panic { message } => eprintln!("panic: {}", message),
_ => eprintln!("error: {}", err)
}
} else {
eprintln!("error: {}", source);
}
source.chain().skip(1).for_each(|cause| eprintln!("cause: {}", cause));
exit(1);
},
Ok(value) => {
assert!(value == -1);
println!("return: {}", value);
exit(0);
}
}
}
fn ncursesw_entry_test_pass(stdscr: &Window) -> result!(()) {
let mut origin = Origin::default();
stdscr.mvaddstr(origin, "If the doors of perception were cleansed every thing would appear to man as it is: Infinite.")?;
origin.y += 1;
stdscr.mvaddstr(origin, "For man has closed himself up, till he sees all things thro' narrow chinks of his cavern.")?;
origin.y += 2;
stdscr.mvaddstr(origin, "Press <Return> to continue: ")?;
stdscr.refresh()?;
stdscr.getch()?;
Ok(())
}
fn ncursesw_entry_test_fail() -> result!(i32) {
Err(NCurseswWinError::InternalError) }