diff --git a/Cargo.toml b/Cargo.toml index fe9766f..a159a92 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -37,6 +37,7 @@ tuirs-termion = ["tuirs", "dep:termion", "tui/termion"] tuirs-no-backend = ["tuirs"] # Other optional features search = ["dep:regex"] +serde = ["dep:serde"] [dependencies] arbitrary = { version = "1", features = ["derive"], optional = true } @@ -48,6 +49,7 @@ termion = { version = "2.0", optional = true } termwiz = { version = "0.20.0", optional = true } tui = { version = "0.19", default-features = false, optional = true } unicode-width = "0.1.11" +serde = { version = "1", optional = true } [[example]] name = "minimal" diff --git a/src/cursor.rs b/src/cursor.rs index ed521e7..e9b084b 100644 --- a/src/cursor.rs +++ b/src/cursor.rs @@ -2,14 +2,17 @@ use crate::widget::Viewport; use crate::word::{find_word_start_backward, find_word_start_forward}; #[cfg(feature = "arbitrary")] use arbitrary::Arbitrary; +#[cfg(feature = "serde")] +use serde::{Deserialize, Serialize}; use std::cmp; /// Specify how to move the cursor. /// /// This type is marked as `#[non_exhaustive]` since more variations may be supported in the future. #[non_exhaustive] -#[derive(Clone, Copy, Debug)] +#[derive(Clone, Copy, Debug, PartialEq, Eq)] #[cfg_attr(feature = "arbitrary", derive(Arbitrary))] +#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] pub enum CursorMove { /// Move cursor forward by one character. When the cursor is at the end of line, it moves to the head of next line. /// ```