libnotcurses_sys/input/
reimplemented.rs1use crate::{NcInput, NcInputType, NcKeyMod};
4
5pub fn ncinput_nomod_p(input: &NcInput) -> bool {
9 NcKeyMod::from(input.modifiers).none_p()
10}
11
12pub fn ncinput_shift_p(input: &NcInput) -> bool {
16 NcKeyMod::from(input.modifiers).shift_p()
17}
18
19pub fn ncinput_alt_p(input: &NcInput) -> bool {
23 NcKeyMod::from(input.modifiers).alt_p()
24}
25
26pub fn ncinput_ctrl_p(input: &NcInput) -> bool {
30 NcKeyMod::from(input.modifiers).ctrl_p()
31}
32
33pub fn ncinput_meta_p(input: &NcInput) -> bool {
37 NcKeyMod::from(input.modifiers).meta_p()
38}
39
40pub fn ncinput_super_p(input: &NcInput) -> bool {
44 NcKeyMod::from(input.modifiers).super_p()
45}
46
47pub fn ncinput_hyper_p(input: &NcInput) -> bool {
51 NcKeyMod::from(input.modifiers).hyper_p()
52}
53
54pub fn ncinput_capslock_p(input: &NcInput) -> bool {
58 NcKeyMod::from(input.modifiers).capslock_p()
59}
60
61pub fn ncinput_numlock_p(input: &NcInput) -> bool {
65 NcKeyMod::from(input.modifiers).numlock_p()
66}
67
68pub fn ncinput_equal_p(n1: &NcInput, n2: &NcInput) -> bool {
72 if n1.id != n2.id {
73 return false;
74 }
75 if n1.y != n2.y || n1.x != n2.x {
76 return false;
77 }
78 if (n1.modifiers & !(NcKeyMod::CapsLock | NcKeyMod::NumLock))
79 != (n2.modifiers & !(NcKeyMod::CapsLock | NcKeyMod::NumLock))
80 {
81 return false;
82 }
83 if n1.evtype != n2.evtype
84 && ((n1.evtype != NcInputType::Unknown as u32 && n1.evtype != NcInputType::Press as u32)
85 || (n2.evtype != NcInputType::Unknown as u32 && n2.evtype != NcInputType::Press as u32))
86 {
87 return false;
88 }
89 if n1.ypx != n2.ypx || n1.xpx != n2.xpx {
90 return false;
91 }
92 true
93}