use ncursesw::{*, extend::*};
fn main() {
if let Err(source) = main_routine() {
println!("error: {}", source);
}
}
fn main_routine() -> Result<(), NCurseswError> {
initscr()?;
if has_colors() {
start_color()?;
let red = Color::new(ColorPalette::Red);
let black = Color::new(ColorPalette::Black);
let yellow = Color::new(ColorPalette::Yellow);
let colors1 = Colors::new(red, black);
let colors2 = Colors::new(yellow, black);
let color_pair0 = ColorPair::default();
let color_pair1 = ColorPair::new(1, colors1)?;
let color_pair2 = ColorPair::new(2, colors2)?;
let mut attrs = Attributes::default();
attr_set(attrs, color_pair0)?;
addstr("Using modern attribute setting...\n\n")?;
attr_set(attrs, color_pair1)?;
addstr("I am Mr. Red!\n")?;
attr_set(attrs, color_pair2)?;
addstr("I am Mr. Yellow!\n")?;
attrs = attrs.set_bold(true);
attr_set(attrs, color_pair1)?;
addstr("I'm feeling bold!\n")?;
attr_set(attrs, color_pair2)?;
addstr("Me too!\n")?;
} else {
addstr("terminal has no color support!!!")?;
}
refresh()?;
getch()?;
endwin()
}