use serde::{Deserialize, Serialize};
#[derive(Debug, Default, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub struct PaneAttributes {
pub bits: u16,
}
impl PaneAttributes {
pub const EMPTY: Self = Self { bits: 0 };
pub const BOLD: Self = Self { bits: 0x1 };
pub const BRIGHT: Self = Self::BOLD;
pub const DIM: Self = Self { bits: 0x2 };
pub const UNDERLINE: Self = Self { bits: 0x4 };
pub const UNDERSCORE: Self = Self::UNDERLINE;
pub const BLINK: Self = Self { bits: 0x8 };
pub const REVERSE: Self = Self { bits: 0x10 };
pub const HIDDEN: Self = Self { bits: 0x20 };
pub const ITALIC: Self = Self { bits: 0x40 };
pub const ITALICS: Self = Self::ITALIC;
pub const CHARSET: Self = Self { bits: 0x80 };
pub const STRIKETHROUGH: Self = Self { bits: 0x100 };
pub const DOUBLE_UNDERLINE: Self = Self { bits: 0x200 };
pub const CURLY_UNDERLINE: Self = Self { bits: 0x400 };
pub const DOTTED_UNDERLINE: Self = Self { bits: 0x800 };
pub const DASHED_UNDERLINE: Self = Self { bits: 0x1000 };
pub const OVERLINE: Self = Self { bits: 0x2000 };
pub const NO_ATTRIBUTES: Self = Self { bits: 0x4000 };
pub const NOATTR: Self = Self::NO_ATTRIBUTES;
pub const ALL_UNDERSCORE: Self = Self {
bits: Self::UNDERLINE.bits
| Self::DOUBLE_UNDERLINE.bits
| Self::CURLY_UNDERLINE.bits
| Self::DOTTED_UNDERLINE.bits
| Self::DASHED_UNDERLINE.bits,
};
#[must_use]
pub const fn from_bits(bits: u16) -> Self {
Self { bits }
}
#[must_use]
pub const fn bits(self) -> u16 {
self.bits
}
#[must_use]
pub const fn contains(self, other: Self) -> bool {
self.bits & other.bits == other.bits
}
#[must_use]
pub const fn is_empty(self) -> bool {
self.bits == 0
}
}
impl std::ops::BitOr for PaneAttributes {
type Output = Self;
fn bitor(self, rhs: Self) -> Self::Output {
Self {
bits: self.bits | rhs.bits,
}
}
}
impl std::ops::BitOrAssign for PaneAttributes {
fn bitor_assign(&mut self, rhs: Self) {
self.bits |= rhs.bits;
}
}
impl std::ops::BitAnd for PaneAttributes {
type Output = Self;
fn bitand(self, rhs: Self) -> Self::Output {
Self {
bits: self.bits & rhs.bits,
}
}
}