Upgrade to bitflags 2 (#777)
This commit is contained in:
parent
a2c9350ff2
commit
b2cbd94853
@ -27,16 +27,18 @@ all-features = true
|
||||
#
|
||||
[features]
|
||||
default = ["bracketed-paste", "windows", "events"]
|
||||
windows = ["winapi", "crossterm_winapi"]
|
||||
windows = ["dep:winapi", "dep:crossterm_winapi"]
|
||||
bracketed-paste = []
|
||||
event-stream = ["futures-core", "events"]
|
||||
use-dev-tty = ["filedescriptor"]
|
||||
events = ["mio", "signal-hook", "signal-hook-mio"]
|
||||
events = ["dep:mio", "dep:signal-hook", "dep:signal-hook-mio"]
|
||||
serde = ["dep:serde", "bitflags/serde"]
|
||||
|
||||
#
|
||||
# Shared dependencies
|
||||
#
|
||||
[dependencies]
|
||||
bitflags = "1.3"
|
||||
bitflags = {version = "2.1" }
|
||||
parking_lot = "0.12"
|
||||
|
||||
# optional deps only added when requested
|
||||
|
@ -1,6 +1,5 @@
|
||||
#![allow(clippy::cognitive_complexity)]
|
||||
|
||||
use crate::Result;
|
||||
use crossterm::{cursor, queue, style};
|
||||
use std::io::Write;
|
||||
|
||||
|
30
src/event.rs
30
src/event.rs
@ -101,9 +101,6 @@ use parking_lot::{MappedMutexGuard, Mutex, MutexGuard};
|
||||
use std::fmt;
|
||||
use std::time::Duration;
|
||||
|
||||
#[cfg(feature = "serde")]
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use bitflags::bitflags;
|
||||
use std::hash::{Hash, Hasher};
|
||||
|
||||
@ -250,7 +247,8 @@ bitflags! {
|
||||
/// See <https://sw.kovidgoyal.net/kitty/keyboard-protocol/#progressive-enhancement> for more information.
|
||||
///
|
||||
/// Alternate keys and Unicode codepoints are not yet supported by crossterm.
|
||||
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
||||
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize), serde(transparent))]
|
||||
#[derive(Debug, PartialOrd, PartialEq, Eq, Clone, Copy, Hash)]
|
||||
pub struct KeyboardEnhancementFlags: u8 {
|
||||
/// Represent Escape and modified keys using CSI-u sequences, so they can be unambiguously
|
||||
/// read.
|
||||
@ -504,7 +502,7 @@ impl Command for PopKeyboardEnhancementFlags {
|
||||
}
|
||||
|
||||
/// Represents an event.
|
||||
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
||||
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
|
||||
#[cfg_attr(not(feature = "bracketed-paste"), derive(Copy))]
|
||||
#[derive(Debug, PartialOrd, PartialEq, Eq, Clone, Hash)]
|
||||
pub enum Event {
|
||||
@ -540,7 +538,7 @@ pub enum Event {
|
||||
/// Some platforms/terminals does not report all key modifiers
|
||||
/// 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(Serialize, Deserialize))]
|
||||
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
|
||||
#[derive(Debug, PartialOrd, PartialEq, Eq, Clone, Copy, Hash)]
|
||||
pub struct MouseEvent {
|
||||
/// The kind of mouse event that was caused.
|
||||
@ -562,7 +560,7 @@ pub struct MouseEvent {
|
||||
/// Some platforms/terminals do not report mouse button for the
|
||||
/// `MouseEventKind::Up` and `MouseEventKind::Drag` events. `MouseButton::Left`
|
||||
/// is returned if we don't know which button was used.
|
||||
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
||||
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
|
||||
#[derive(Debug, PartialOrd, PartialEq, Eq, Clone, Copy, Hash)]
|
||||
pub enum MouseEventKind {
|
||||
/// Pressed mouse button. Contains the button that was pressed.
|
||||
@ -580,7 +578,7 @@ pub enum MouseEventKind {
|
||||
}
|
||||
|
||||
/// Represents a mouse button.
|
||||
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
||||
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
|
||||
#[derive(Debug, PartialOrd, PartialEq, Eq, Clone, Copy, Hash)]
|
||||
pub enum MouseButton {
|
||||
/// Left mouse button.
|
||||
@ -597,7 +595,8 @@ bitflags! {
|
||||
/// **Note:** `SUPER`, `HYPER`, and `META` can only be read if
|
||||
/// [`KeyboardEnhancementFlags::DISAMBIGUATE_ESCAPE_CODES`] has been enabled with
|
||||
/// [`PushKeyboardEnhancementFlags`].
|
||||
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
||||
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize), serde(transparent))]
|
||||
#[derive(Debug, PartialOrd, PartialEq, Eq, Clone, Copy, Hash)]
|
||||
pub struct KeyModifiers: u8 {
|
||||
const SHIFT = 0b0000_0001;
|
||||
const CONTROL = 0b0000_0010;
|
||||
@ -610,7 +609,7 @@ bitflags! {
|
||||
}
|
||||
|
||||
/// Represents a keyboard event kind.
|
||||
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
||||
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
|
||||
#[derive(Debug, PartialOrd, PartialEq, Eq, Clone, Copy, Hash)]
|
||||
pub enum KeyEventKind {
|
||||
Press,
|
||||
@ -624,7 +623,8 @@ bitflags! {
|
||||
/// **Note:** This state can only be read if
|
||||
/// [`KeyboardEnhancementFlags::DISAMBIGUATE_ESCAPE_CODES`] has been enabled with
|
||||
/// [`PushKeyboardEnhancementFlags`].
|
||||
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
||||
#[derive(Debug, PartialOrd, 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.
|
||||
const KEYPAD = 0b0000_0001;
|
||||
@ -641,7 +641,7 @@ bitflags! {
|
||||
}
|
||||
|
||||
/// Represents a key event.
|
||||
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
||||
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
|
||||
#[derive(Debug, PartialOrd, Clone, Copy)]
|
||||
pub struct KeyEvent {
|
||||
/// The key itself.
|
||||
@ -767,7 +767,7 @@ impl Hash for KeyEvent {
|
||||
|
||||
/// Represents a media key (as part of [`KeyCode::Media`]).
|
||||
#[derive(Debug, PartialOrd, PartialEq, Eq, Clone, Copy, Hash)]
|
||||
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
||||
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
|
||||
pub enum MediaKeyCode {
|
||||
/// Play media key.
|
||||
Play,
|
||||
@ -799,7 +799,7 @@ pub enum MediaKeyCode {
|
||||
|
||||
/// Represents a modifier key (as part of [`KeyCode::Modifier`]).
|
||||
#[derive(Debug, PartialOrd, PartialEq, Eq, Clone, Copy, Hash)]
|
||||
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
||||
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
|
||||
pub enum ModifierKeyCode {
|
||||
/// Left Shift key.
|
||||
LeftShift,
|
||||
@ -833,7 +833,7 @@ pub enum ModifierKeyCode {
|
||||
|
||||
/// Represents a key.
|
||||
#[derive(Debug, PartialOrd, PartialEq, Eq, Clone, Copy, Hash)]
|
||||
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
||||
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
|
||||
pub enum KeyCode {
|
||||
/// Backspace key.
|
||||
Backspace,
|
||||
|
Loading…
Reference in New Issue
Block a user