@@ -126,6 +126,7 @@ pub(crate) mod stream;
126126pub ( crate ) mod sys;
127127pub ( crate ) mod timeout;
128128
129+ #[ cfg( feature = "derive-more" ) ]
129130use derive_more:: derive:: IsVariant ;
130131#[ cfg( feature = "event-stream" ) ]
131132pub use stream:: EventStream ;
@@ -543,8 +544,9 @@ impl Command for PopKeyboardEnhancementFlags {
543544
544545/// Represents an event.
545546#[ cfg_attr( feature = "serde" , derive( serde:: Serialize , serde:: Deserialize ) ) ]
547+ #[ cfg_attr( feature = "derive-more" , derive( IsVariant ) ) ]
546548#[ cfg_attr( not( feature = "bracketed-paste" ) , derive( Copy ) ) ]
547- #[ derive( Debug , PartialOrd , PartialEq , Eq , Clone , Hash , IsVariant ) ]
549+ #[ derive( Debug , PartialOrd , PartialEq , Eq , Clone , Hash ) ]
548550pub enum Event {
549551 /// The terminal gained focus
550552 FocusGained ,
@@ -793,7 +795,8 @@ pub struct MouseEvent {
793795/// `MouseEventKind::Up` and `MouseEventKind::Drag` events. `MouseButton::Left`
794796/// is returned if we don't know which button was used.
795797#[ cfg_attr( feature = "serde" , derive( serde:: Serialize , serde:: Deserialize ) ) ]
796- #[ derive( Debug , PartialOrd , PartialEq , Eq , Clone , Copy , Hash , IsVariant ) ]
798+ #[ cfg_attr( feature = "derive-more" , derive( IsVariant ) ) ]
799+ #[ derive( Debug , PartialOrd , PartialEq , Eq , Clone , Copy , Hash ) ]
797800pub enum MouseEventKind {
798801 /// Pressed mouse button. Contains the button that was pressed.
799802 Down ( MouseButton ) ,
@@ -815,7 +818,8 @@ pub enum MouseEventKind {
815818
816819/// Represents a mouse button.
817820#[ cfg_attr( feature = "serde" , derive( serde:: Serialize , serde:: Deserialize ) ) ]
818- #[ derive( Debug , PartialOrd , PartialEq , Eq , Clone , Copy , Hash , IsVariant ) ]
821+ #[ cfg_attr( feature = "derive-more" , derive( IsVariant ) ) ]
822+ #[ derive( Debug , PartialOrd , PartialEq , Eq , Clone , Copy , Hash ) ]
819823pub enum MouseButton {
820824 /// Left mouse button.
821825 Left ,
@@ -895,7 +899,8 @@ impl Display for KeyModifiers {
895899
896900/// Represents a keyboard event kind.
897901#[ cfg_attr( feature = "serde" , derive( serde:: Serialize , serde:: Deserialize ) ) ]
898- #[ derive( Debug , PartialOrd , PartialEq , Eq , Clone , Copy , Hash , IsVariant ) ]
902+ #[ cfg_attr( feature = "derive-more" , derive( IsVariant ) ) ]
903+ #[ derive( Debug , PartialOrd , PartialEq , Eq , Clone , Copy , Hash ) ]
899904pub enum KeyEventKind {
900905 Press ,
901906 Repeat ,
@@ -1002,17 +1007,17 @@ impl KeyEvent {
10021007
10031008 /// Returns whether the key event is a press event.
10041009 pub fn is_press ( & self ) -> bool {
1005- self . kind . is_press ( )
1010+ matches ! ( self . kind, KeyEventKind :: Press )
10061011 }
10071012
10081013 /// Returns whether the key event is a release event.
10091014 pub fn is_release ( & self ) -> bool {
1010- self . kind . is_release ( )
1015+ matches ! ( self . kind, KeyEventKind :: Release )
10111016 }
10121017
10131018 /// Returns whether the key event is a repeat event.
10141019 pub fn is_repeat ( & self ) -> bool {
1015- self . kind . is_repeat ( )
1020+ matches ! ( self . kind, KeyEventKind :: Repeat )
10161021 }
10171022}
10181023
@@ -1214,7 +1219,8 @@ impl Display for ModifierKeyCode {
12141219}
12151220
12161221/// Represents a key.
1217- #[ derive( Debug , PartialOrd , PartialEq , Eq , Clone , Copy , Hash , IsVariant ) ]
1222+ #[ derive( Debug , PartialOrd , PartialEq , Eq , Clone , Copy , Hash ) ]
1223+ #[ cfg_attr( feature = "derive-more" , derive( IsVariant ) ) ]
12181224#[ cfg_attr( feature = "serde" , derive( serde:: Serialize , serde:: Deserialize ) ) ]
12191225pub enum KeyCode {
12201226 /// Backspace key (Delete on macOS, Backspace on other platforms).
@@ -1248,12 +1254,12 @@ pub enum KeyCode {
12481254 /// F key.
12491255 ///
12501256 /// `KeyCode::F(1)` represents F1 key, etc.
1251- #[ is_variant( ignore) ]
1257+ #[ cfg_attr ( feature = "derive-more" , is_variant( ignore) ) ]
12521258 F ( u8 ) ,
12531259 /// A character.
12541260 ///
12551261 /// `KeyCode::Char('c')` represents `c` character, etc.
1256- #[ is_variant( ignore) ]
1262+ #[ cfg_attr ( feature = "derive-more" , is_variant( ignore) ) ]
12571263 Char ( char ) ,
12581264 /// Null.
12591265 Null ,
@@ -1306,15 +1312,15 @@ pub enum KeyCode {
13061312 /// **Note:** these keys can only be read if
13071313 /// [`KeyboardEnhancementFlags::DISAMBIGUATE_ESCAPE_CODES`] has been enabled with
13081314 /// [`PushKeyboardEnhancementFlags`].
1309- #[ is_variant( ignore) ]
1315+ #[ cfg_attr ( feature = "derive-more" , is_variant( ignore) ) ]
13101316 Media ( MediaKeyCode ) ,
13111317 /// A modifier key.
13121318 ///
13131319 /// **Note:** these keys can only be read if **both**
13141320 /// [`KeyboardEnhancementFlags::DISAMBIGUATE_ESCAPE_CODES`] and
13151321 /// [`KeyboardEnhancementFlags::REPORT_ALL_KEYS_AS_ESCAPE_CODES`] have been enabled with
13161322 /// [`PushKeyboardEnhancementFlags`].
1317- #[ is_variant( ignore) ]
1323+ #[ cfg_attr ( feature = "derive-more" , is_variant( ignore) ) ]
13181324 Modifier ( ModifierKeyCode ) ,
13191325}
13201326
@@ -1632,6 +1638,7 @@ mod tests {
16321638 modifiers : KeyModifiers :: empty ( ) ,
16331639 } ;
16341640
1641+ #[ cfg( feature = "derive-more" ) ]
16351642 #[ test]
16361643 fn event_is ( ) {
16371644 let event = Event :: FocusGained ;
0 commit comments