Function ncursesw::wattr_get [−][src]
pub fn wattr_get(
handle: WINDOW
) -> Result<AttributesColorPairSet, NCurseswError>
Expand description
Return the current attributes and color pair on the given window.
Notes: This does NOT return the attribute and color pair rendition when defined
by chtype
and/or cchar
type add/insert functions as these are cell based
but when set by functions such as wattr_set
.
When returning a normal
attribute and color pair the attribute does NOT
contain the color pair so this must be OR’d to back for some functions.
Example
extern crate ncursesw;
extern crate ascii;
use ascii::*;
use ncursesw::*;
use ncursesw::normal::*;
start_color()?;
use_default_colors()?;
let win_size = Size { lines: 10, columns: 50 };
let win_origin = Origin { y: 5, x: 5 };
let win = newwin(win_size, win_origin)?;
let color_pair0 = ColorPair::default();
let color_pair1 = ColorPair::new(1, Colors::new(Color::Dark(BaseColor::Yellow), Color::Dark(BaseColor::Blue)))?;
let attrs0 = Attribute::Dim | color_pair0;
let attrs1 = Attribute::Bold | color_pair1;
let ascii_char = AsciiChar::A;
let chtype_char = ChtypeChar::new(ascii_char);
wattr_set(win, attrs1, color_pair1)?;
waddch(win, chtype_char | attrs0)?;
match wattr_get(win)? {
AttributesColorPairSet::Normal(s) => {
assert!(s.attributes().is_bold());
assert!(s.color_pair() == color_pair1);
},
AttributesColorPairSet::Extended(_) => {
panic!("not a extended attributes/color pair!");
}
}
delwin(win)?;