Merge branch 'add-serde' into 'master'

1.6.0 - add optional serde implementations

See merge request redox-os/termion!176
This commit is contained in:
Jeremy Soller 2022-10-21 06:55:35 +00:00
commit 583bb40f32
3 changed files with 11 additions and 1 deletions

View File

@ -1,6 +1,6 @@
[package] [package]
name = "termion" name = "termion"
version = "1.5.6" version = "1.6.0"
authors = ["ticki <Ticki@users.noreply.github.com>", "gycos <alexandre.bury@gmail.com>", "IGI-111 <igi-111@protonmail.com>"] authors = ["ticki <Ticki@users.noreply.github.com>", "gycos <alexandre.bury@gmail.com>", "IGI-111 <igi-111@protonmail.com>"]
description = "A bindless library for manipulating terminals." description = "A bindless library for manipulating terminals."
repository = "https://gitlab.redox-os.org/redox-os/termion" repository = "https://gitlab.redox-os.org/redox-os/termion"
@ -11,6 +11,7 @@ exclude = ["target", "CHANGELOG.md", "image.png", "Cargo.lock"]
[dependencies] [dependencies]
numtoa = { version = "0.1", features = ["std"]} numtoa = { version = "0.1", features = ["std"]}
serde = { version = "1.0", features = ["derive"], optional = true }
[target.'cfg(not(target_os = "redox"))'.dependencies] [target.'cfg(not(target_os = "redox"))'.dependencies]
libc = "0.2" libc = "0.2"

View File

@ -1,9 +1,13 @@
//! Mouse and key events. //! Mouse and key events.
#[cfg(feature = "serde")]
use serde::{Deserialize, Serialize};
use std::io::{Error, ErrorKind}; use std::io::{Error, ErrorKind};
use std::str; use std::str;
/// An event reported by the terminal. /// An event reported by the terminal.
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[derive(Debug, Clone, PartialEq, Eq, Hash)] #[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub enum Event { pub enum Event {
/// A key press. /// A key press.
@ -15,6 +19,7 @@ pub enum Event {
} }
/// A mouse related event. /// A mouse related event.
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
pub enum MouseEvent { pub enum MouseEvent {
/// A mouse button was pressed. /// A mouse button was pressed.
@ -32,6 +37,7 @@ pub enum MouseEvent {
} }
/// A mouse button. /// A mouse button.
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
pub enum MouseButton { pub enum MouseButton {
/// The left mouse button. /// The left mouse button.
@ -51,6 +57,7 @@ pub enum MouseButton {
} }
/// A key. /// A key.
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
pub enum Key { pub enum Key {
/// Backspace. /// Backspace.

View File

@ -12,6 +12,8 @@
#![warn(missing_docs)] #![warn(missing_docs)]
extern crate numtoa; extern crate numtoa;
#[cfg(feature = "serde")]
extern crate serde;
#[cfg(target_os = "redox")] #[cfg(target_os = "redox")]
#[path="sys/redox/mod.rs"] #[path="sys/redox/mod.rs"]