mirror of
https://github.com/FliegendeWurst/cursive.git
synced 2024-11-23 17:35:00 +00:00
Add EventResult::and
This commit is contained in:
parent
b607be40d4
commit
b21224cf1c
19
src/event.rs
19
src/event.rs
@ -140,6 +140,25 @@ impl EventResult {
|
|||||||
other => other,
|
other => other,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Returns an event result that combines `self` and `other`.
|
||||||
|
pub fn and(self, other: Self) -> Self {
|
||||||
|
match (self, other) {
|
||||||
|
(EventResult::Ignored, result)
|
||||||
|
| (result, EventResult::Ignored) => result,
|
||||||
|
(EventResult::Consumed(None), EventResult::Consumed(cb))
|
||||||
|
| (EventResult::Consumed(cb), EventResult::Consumed(None)) => {
|
||||||
|
EventResult::Consumed(cb)
|
||||||
|
}
|
||||||
|
(
|
||||||
|
EventResult::Consumed(Some(cb1)),
|
||||||
|
EventResult::Consumed(Some(cb2)),
|
||||||
|
) => EventResult::with_cb(move |siv| {
|
||||||
|
(cb1)(siv);
|
||||||
|
(cb2)(siv);
|
||||||
|
}),
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A non-character key on the keyboard
|
/// A non-character key on the keyboard
|
||||||
|
Loading…
Reference in New Issue
Block a user