libnotcurses_sys/input/
mice_events.rs1#[repr(transparent)]
19#[derive(Debug, Clone, Copy, PartialEq, Eq)]
20pub struct NcMiceEvents(pub c_api::NcMiceEvents_u32);
21
22impl NcMiceEvents {
24 pub const None: NcMiceEvents = Self(c_api::NCMICE_NO_EVENTS);
26
27 pub const Move: NcMiceEvents = Self(c_api::NCMICE_MOVE_EVENTS);
29
30 pub const Button: NcMiceEvents = Self(c_api::NCMICE_BUTTON_EVENTS);
32
33 pub const Drag: NcMiceEvents = Self(c_api::NCMICE_DRAG_EVENTS);
35
36 pub const All: NcMiceEvents = Self(c_api::NCMICE_ALL_EVENTS);
38}
39
40impl NcMiceEvents {
42 pub fn new(value: c_api::NcMiceEvents_u32) -> Self {
44 Self(value)
45 }
46
47 pub fn has(&self, other: NcMiceEvents) -> bool {
49 (self.0 & other.0) == other.0
50 }
51
52 pub fn add(&mut self, other: NcMiceEvents) {
54 self.0 |= other.0
55 }
56}
57
58mod core_impls {
59 use super::{c_api::NcMiceEvents_u32, NcMiceEvents};
60
61 impl Default for NcMiceEvents {
62 fn default() -> Self {
63 Self::None
64 }
65 }
66 crate::from_primitive![NcMiceEvents, NcMiceEvents_u32];
67 crate::unit_impl_from![NcMiceEvents, NcMiceEvents_u32];
68 crate::unit_impl_ops![bitwise; NcMiceEvents, NcMiceEvents_u32];
69 crate::unit_impl_fmt![bases+display; NcMiceEvents];
70}
71
72pub(crate) mod c_api {
73 use crate::c_api::ffi;
74
75 pub type NcMiceEvents_u32 = u32;
86
87 pub const NCMICE_NO_EVENTS: NcMiceEvents_u32 = ffi::NCMICE_NO_EVENTS;
89
90 pub const NCMICE_MOVE_EVENTS: NcMiceEvents_u32 = ffi::NCMICE_MOVE_EVENT;
92
93 pub const NCMICE_BUTTON_EVENTS: NcMiceEvents_u32 = ffi::NCMICE_BUTTON_EVENT;
95
96 pub const NCMICE_DRAG_EVENTS: NcMiceEvents_u32 = ffi::NCMICE_DRAG_EVENT;
98
99 pub const NCMICE_ALL_EVENTS: NcMiceEvents_u32 = ffi::NCMICE_ALL_EVENTS;
101}