extern crate ncurseswwin;
use std::{convert::TryFrom, process::exit};
use anyhow::Result;
use ncurseswwin::*;
fn main() {
if let Err(source) = ncursesw_entry(hello_world) {
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);
}
exit(0);
}
fn hello_world(stdscr: &Window) -> Result<()> {
let hello_world = "Hello World!!!";
stdscr.mvaddstr(Origin { y: LINES()? / 2, x: (COLS()? / 2) - (u16::try_from(hello_world.len())? / 2) }, hello_world)?;
stdscr.refresh()?;
stdscr.getch()?;
Ok(())
}