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