2020-12-04 01:25:49 +00:00
|
|
|
|
//! `NcInput`
|
|
|
|
|
|
|
|
|
|
// functions manually reimplemented: 1
|
|
|
|
|
// ------------------------------------------
|
2020-11-03 19:26:33 +00:00
|
|
|
|
// (+) done: 1 / 0
|
|
|
|
|
// (#) test: 0 / 1
|
|
|
|
|
// ------------------------------------------
|
2020-12-04 01:25:49 +00:00
|
|
|
|
// + ncinput_equal_p
|
2020-11-03 19:26:33 +00:00
|
|
|
|
|
2020-12-02 13:01:09 +00:00
|
|
|
|
/// Reads and decodes input events
|
|
|
|
|
///
|
|
|
|
|
/// Reads from stdin and decodes the input to stdout,
|
|
|
|
|
/// including synthesized events and mouse events.
|
|
|
|
|
///
|
|
|
|
|
/// To exit, generate EOF (usually Ctrl+‘d’).
|
2020-12-05 17:55:10 +00:00
|
|
|
|
pub type NcInput = crate::bindings::ffi::ncinput;
|
2020-11-03 19:26:33 +00:00
|
|
|
|
|
2020-12-04 01:25:49 +00:00
|
|
|
|
/// Compares two ncinput structs for data equality by doing a field-by-field
|
2020-11-03 19:26:33 +00:00
|
|
|
|
/// comparison for equality (excepting seqnum).
|
|
|
|
|
///
|
|
|
|
|
/// Returns true if the two are data-equivalent.
|
2020-11-06 12:40:52 +00:00
|
|
|
|
pub fn ncinput_equal_p(n1: NcInput, n2: NcInput) -> bool {
|
2020-11-03 19:26:33 +00:00
|
|
|
|
if n1.id != n2.id {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
if n1.y != n2.y || n1.x != n2.x {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
// do not check seqnum
|
|
|
|
|
true
|
|
|
|
|
}
|
2020-11-03 19:58:13 +00:00
|
|
|
|
|
2020-12-04 01:25:49 +00:00
|
|
|
|
/// New `NcInput`.
|
2020-11-06 12:40:52 +00:00
|
|
|
|
impl NcInput {
|
|
|
|
|
pub fn new() -> NcInput {
|
|
|
|
|
NcInput {
|
2020-11-03 19:58:13 +00:00
|
|
|
|
id: 0,
|
|
|
|
|
y: 0,
|
|
|
|
|
x: 0,
|
|
|
|
|
alt: false,
|
|
|
|
|
shift: false,
|
|
|
|
|
ctrl: false,
|
|
|
|
|
seqnum: 0,
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|