@@ -126,6 +126,7 @@ pub(crate) mod stream;
126
126
pub ( crate ) mod sys;
127
127
pub ( crate ) mod timeout;
128
128
129
+ #[ cfg( feature = "derive-more" ) ]
129
130
use derive_more:: derive:: IsVariant ;
130
131
#[ cfg( feature = "event-stream" ) ]
131
132
pub use stream:: EventStream ;
@@ -543,8 +544,9 @@ impl Command for PopKeyboardEnhancementFlags {
543
544
544
545
/// Represents an event.
545
546
#[ cfg_attr( feature = "serde" , derive( serde:: Serialize , serde:: Deserialize ) ) ]
547
+ #[ cfg_attr( feature = "derive-more" , derive( IsVariant ) ) ]
546
548
#[ 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 ) ]
548
550
pub enum Event {
549
551
/// The terminal gained focus
550
552
FocusGained ,
@@ -793,7 +795,8 @@ pub struct MouseEvent {
793
795
/// `MouseEventKind::Up` and `MouseEventKind::Drag` events. `MouseButton::Left`
794
796
/// is returned if we don't know which button was used.
795
797
#[ 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 ) ]
797
800
pub enum MouseEventKind {
798
801
/// Pressed mouse button. Contains the button that was pressed.
799
802
Down ( MouseButton ) ,
@@ -815,7 +818,8 @@ pub enum MouseEventKind {
815
818
816
819
/// Represents a mouse button.
817
820
#[ 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 ) ]
819
823
pub enum MouseButton {
820
824
/// Left mouse button.
821
825
Left ,
@@ -895,7 +899,8 @@ impl Display for KeyModifiers {
895
899
896
900
/// Represents a keyboard event kind.
897
901
#[ 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 ) ]
899
904
pub enum KeyEventKind {
900
905
Press ,
901
906
Repeat ,
@@ -1002,17 +1007,17 @@ impl KeyEvent {
1002
1007
1003
1008
/// Returns whether the key event is a press event.
1004
1009
pub fn is_press ( & self ) -> bool {
1005
- self . kind . is_press ( )
1010
+ matches ! ( self . kind, KeyEventKind :: Press )
1006
1011
}
1007
1012
1008
1013
/// Returns whether the key event is a release event.
1009
1014
pub fn is_release ( & self ) -> bool {
1010
- self . kind . is_release ( )
1015
+ matches ! ( self . kind, KeyEventKind :: Release )
1011
1016
}
1012
1017
1013
1018
/// Returns whether the key event is a repeat event.
1014
1019
pub fn is_repeat ( & self ) -> bool {
1015
- self . kind . is_repeat ( )
1020
+ matches ! ( self . kind, KeyEventKind :: Repeat )
1016
1021
}
1017
1022
}
1018
1023
@@ -1214,7 +1219,8 @@ impl Display for ModifierKeyCode {
1214
1219
}
1215
1220
1216
1221
/// 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 ) ) ]
1218
1224
#[ cfg_attr( feature = "serde" , derive( serde:: Serialize , serde:: Deserialize ) ) ]
1219
1225
pub enum KeyCode {
1220
1226
/// Backspace key (Delete on macOS, Backspace on other platforms).
@@ -1248,12 +1254,12 @@ pub enum KeyCode {
1248
1254
/// F key.
1249
1255
///
1250
1256
/// `KeyCode::F(1)` represents F1 key, etc.
1251
- #[ is_variant( ignore) ]
1257
+ #[ cfg_attr ( feature = "derive-more" , is_variant( ignore) ) ]
1252
1258
F ( u8 ) ,
1253
1259
/// A character.
1254
1260
///
1255
1261
/// `KeyCode::Char('c')` represents `c` character, etc.
1256
- #[ is_variant( ignore) ]
1262
+ #[ cfg_attr ( feature = "derive-more" , is_variant( ignore) ) ]
1257
1263
Char ( char ) ,
1258
1264
/// Null.
1259
1265
Null ,
@@ -1306,15 +1312,15 @@ pub enum KeyCode {
1306
1312
/// **Note:** these keys can only be read if
1307
1313
/// [`KeyboardEnhancementFlags::DISAMBIGUATE_ESCAPE_CODES`] has been enabled with
1308
1314
/// [`PushKeyboardEnhancementFlags`].
1309
- #[ is_variant( ignore) ]
1315
+ #[ cfg_attr ( feature = "derive-more" , is_variant( ignore) ) ]
1310
1316
Media ( MediaKeyCode ) ,
1311
1317
/// A modifier key.
1312
1318
///
1313
1319
/// **Note:** these keys can only be read if **both**
1314
1320
/// [`KeyboardEnhancementFlags::DISAMBIGUATE_ESCAPE_CODES`] and
1315
1321
/// [`KeyboardEnhancementFlags::REPORT_ALL_KEYS_AS_ESCAPE_CODES`] have been enabled with
1316
1322
/// [`PushKeyboardEnhancementFlags`].
1317
- #[ is_variant( ignore) ]
1323
+ #[ cfg_attr ( feature = "derive-more" , is_variant( ignore) ) ]
1318
1324
Modifier ( ModifierKeyCode ) ,
1319
1325
}
1320
1326
@@ -1632,6 +1638,7 @@ mod tests {
1632
1638
modifiers : KeyModifiers :: empty ( ) ,
1633
1639
} ;
1634
1640
1641
+ #[ cfg( feature = "derive-more" ) ]
1635
1642
#[ test]
1636
1643
fn event_is ( ) {
1637
1644
let event = Event :: FocusGained ;
0 commit comments