#![allow(deprecated)]
#![allow(clippy::trivially_copy_pass_by_ref)]
#![allow(clippy::from_over_into)]
use crate::{
normal::{Attribute, ColorPair},
gen::ColorPairType,
ncurses::{COLOR_PAIR, PAIR_NUMBER},
shims::ncurses::short_t
};
include!("../include/attributes.rs");
impl_attributes_type!(short_t);
impl Attributes {
pub fn color_pair(&self) -> ColorPair {
ColorPair::_from(self.screen, PAIR_NUMBER(self.raw))
}
}
impl BitOr<ColorPair> for Attributes {
type Output = Attributes;
fn bitor(mut self, rhs: ColorPair) -> Self::Output {
assert!(self.screen == rhs.screen());
self.raw ^= COLOR_PAIR(i32::from(self.color_pair().number()));
self.raw |= COLOR_PAIR(i32::from(rhs.number()));
self
}
}
impl BitXor<ColorPair> for Attributes {
type Output = Self;
fn bitxor(mut self, rhs: ColorPair) -> Self::Output {
assert!(self.screen == rhs.screen());
self.raw ^= COLOR_PAIR(i32::from(rhs.number()));
self
}
}
impl Into<i32> for Attributes {
fn into(self) -> i32 {
self.raw as i32
}
}