use ncursesw::{*, normal::*};
fn main() {
if let Err(source) = main_routine() {
println!("error: {}", source);
}
}
fn main_routine() -> Result<(), NCurseswError> {
let stdscr = initscr()?;
if has_colors() {
start_color()?;
use_default_colors()?;
let yellow = Color::new(ColorPalette::Yellow);
let blue = Color::new(ColorPalette::Blue);
let color_pair0 = ColorPair::default();
let color_pair1 = ColorPair::new(1, Colors::new(yellow, blue))?;
let attrs0 = Attribute::Normal | color_pair0;
let attrs1 = Attribute::Bold | color_pair1;
wattrset(stdscr, attrs1)?;
waddstr(stdscr, "Test string printed with attr1 and color_pair1")?;
let retrived_attrs = getattrs(stdscr);
wattrset(stdscr, attrs0)?;
waddstr(stdscr, "\n\nNormal attributes and color pair of `attrs1`...\n\n")?;
waddstr(stdscr, format!("retrived_attrs={:?}\n", retrived_attrs))?;
waddstr(stdscr, format!("retrived_attrs.is_normal={}\n", retrived_attrs.is_normal()))?;
waddstr(stdscr, format!("retrived_attrs.is_bold={}\n", retrived_attrs.is_bold()))?;
waddstr(stdscr, format!("retrived_attrs.color_pair={:?}", retrived_attrs.color_pair()))?;
} else {
waddstr(stdscr, "terminal has no color support!!!")?;
}
waddstr(stdscr, "\n\nhit <return> to continue ")?;
wgetch(stdscr)?;
delwin(stdscr)?;
endwin()
}