mirror of
https://github.com/crossterm-rs/crossterm.git
synced 2025-05-05 15:32:57 +00:00
Implement Ord for Event and sub-types (#951)
This commit is contained in:
parent
36d95b26a2
commit
922e951723
22
src/event.rs
22
src/event.rs
@ -546,7 +546,7 @@ impl Command for PopKeyboardEnhancementFlags {
|
||||
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
|
||||
#[cfg_attr(feature = "derive-more", derive(IsVariant))]
|
||||
#[cfg_attr(not(feature = "bracketed-paste"), derive(Copy))]
|
||||
#[derive(Debug, PartialOrd, PartialEq, Eq, Clone, Hash)]
|
||||
#[derive(Debug, PartialOrd, Ord, PartialEq, Eq, Clone, Hash)]
|
||||
pub enum Event {
|
||||
/// The terminal gained focus
|
||||
FocusGained,
|
||||
@ -773,7 +773,7 @@ impl Event {
|
||||
/// combinations for all mouse event types. For example - macOS reports
|
||||
/// `Ctrl` + left mouse button click as a right mouse button click.
|
||||
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
|
||||
#[derive(Debug, PartialOrd, PartialEq, Eq, Clone, Copy, Hash)]
|
||||
#[derive(Debug, PartialOrd, Ord, PartialEq, Eq, Clone, Copy, Hash)]
|
||||
pub struct MouseEvent {
|
||||
/// The kind of mouse event that was caused.
|
||||
pub kind: MouseEventKind,
|
||||
@ -796,7 +796,7 @@ pub struct MouseEvent {
|
||||
/// is returned if we don't know which button was used.
|
||||
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
|
||||
#[cfg_attr(feature = "derive-more", derive(IsVariant))]
|
||||
#[derive(Debug, PartialOrd, PartialEq, Eq, Clone, Copy, Hash)]
|
||||
#[derive(Debug, PartialOrd, Ord, PartialEq, Eq, Clone, Copy, Hash)]
|
||||
pub enum MouseEventKind {
|
||||
/// Pressed mouse button. Contains the button that was pressed.
|
||||
Down(MouseButton),
|
||||
@ -819,7 +819,7 @@ pub enum MouseEventKind {
|
||||
/// Represents a mouse button.
|
||||
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
|
||||
#[cfg_attr(feature = "derive-more", derive(IsVariant))]
|
||||
#[derive(Debug, PartialOrd, PartialEq, Eq, Clone, Copy, Hash)]
|
||||
#[derive(Debug, PartialOrd, Ord, PartialEq, Eq, Clone, Copy, Hash)]
|
||||
pub enum MouseButton {
|
||||
/// Left mouse button.
|
||||
Left,
|
||||
@ -836,7 +836,7 @@ bitflags! {
|
||||
/// [`KeyboardEnhancementFlags::DISAMBIGUATE_ESCAPE_CODES`] has been enabled with
|
||||
/// [`PushKeyboardEnhancementFlags`].
|
||||
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize), serde(transparent))]
|
||||
#[derive(Debug, PartialOrd, PartialEq, Eq, Clone, Copy, Hash)]
|
||||
#[derive(Debug, PartialOrd, Ord, PartialEq, Eq, Clone, Copy, Hash)]
|
||||
pub struct KeyModifiers: u8 {
|
||||
const SHIFT = 0b0000_0001;
|
||||
const CONTROL = 0b0000_0010;
|
||||
@ -901,7 +901,7 @@ impl Display for KeyModifiers {
|
||||
/// Represents a keyboard event kind.
|
||||
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
|
||||
#[cfg_attr(feature = "derive-more", derive(IsVariant))]
|
||||
#[derive(Debug, PartialOrd, PartialEq, Eq, Clone, Copy, Hash)]
|
||||
#[derive(Debug, PartialOrd, Ord, PartialEq, Eq, Clone, Copy, Hash)]
|
||||
pub enum KeyEventKind {
|
||||
Press,
|
||||
Repeat,
|
||||
@ -914,7 +914,7 @@ bitflags! {
|
||||
/// **Note:** This state can only be read if
|
||||
/// [`KeyboardEnhancementFlags::DISAMBIGUATE_ESCAPE_CODES`] has been enabled with
|
||||
/// [`PushKeyboardEnhancementFlags`].
|
||||
#[derive(Debug, PartialOrd, PartialEq, Eq, Clone, Copy, Hash)]
|
||||
#[derive(Debug, PartialOrd, Ord, PartialEq, Eq, Clone, Copy, Hash)]
|
||||
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize), serde(transparent))]
|
||||
pub struct KeyEventState: u8 {
|
||||
/// The key event origins from the keypad.
|
||||
@ -933,7 +933,7 @@ bitflags! {
|
||||
|
||||
/// Represents a key event.
|
||||
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
|
||||
#[derive(Debug, PartialOrd, Clone, Copy)]
|
||||
#[derive(Debug, PartialOrd, Ord, Clone, Copy)]
|
||||
pub struct KeyEvent {
|
||||
/// The key itself.
|
||||
pub code: KeyCode,
|
||||
@ -1072,7 +1072,7 @@ impl Hash for KeyEvent {
|
||||
}
|
||||
|
||||
/// Represents a media key (as part of [`KeyCode::Media`]).
|
||||
#[derive(Debug, PartialOrd, PartialEq, Eq, Clone, Copy, Hash)]
|
||||
#[derive(Debug, PartialOrd, Ord, PartialEq, Eq, Clone, Copy, Hash)]
|
||||
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
|
||||
pub enum MediaKeyCode {
|
||||
/// Play media key.
|
||||
@ -1124,7 +1124,7 @@ impl Display for MediaKeyCode {
|
||||
}
|
||||
|
||||
/// Represents a modifier key (as part of [`KeyCode::Modifier`]).
|
||||
#[derive(Debug, PartialOrd, PartialEq, Eq, Clone, Copy, Hash)]
|
||||
#[derive(Debug, PartialOrd, Ord, PartialEq, Eq, Clone, Copy, Hash)]
|
||||
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
|
||||
pub enum ModifierKeyCode {
|
||||
/// Left Shift key.
|
||||
@ -1220,7 +1220,7 @@ impl Display for ModifierKeyCode {
|
||||
}
|
||||
|
||||
/// Represents a key.
|
||||
#[derive(Debug, PartialOrd, PartialEq, Eq, Clone, Copy, Hash)]
|
||||
#[derive(Debug, PartialOrd, Ord, PartialEq, Eq, Clone, Copy, Hash)]
|
||||
#[cfg_attr(feature = "derive-more", derive(IsVariant))]
|
||||
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
|
||||
pub enum KeyCode {
|
||||
|
Loading…
x
Reference in New Issue
Block a user