From a9c2053865975ef758886c6cf963c0742da66df0 Mon Sep 17 00:00:00 2001 From: linrongbin16 Date: Wed, 7 Aug 2024 14:58:20 +0800 Subject: [PATCH 01/10] feat(cursor): Derive 'Debug', 'PartialEq', 'Eq' for SetCursorStyle --- src/cursor.rs | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/src/cursor.rs b/src/cursor.rs index 24c4fdd9..8d320355 100644 --- a/src/cursor.rs +++ b/src/cursor.rs @@ -370,7 +370,7 @@ impl Command for DisableBlinking { /// # Note /// /// - Commands must be executed/queued for execution otherwise they do nothing. -#[derive(Clone, Copy)] +#[derive(Clone, Copy, Debug, PartialEq, Eq)] pub enum SetCursorStyle { /// Default cursor shape configured by the user. DefaultUserShape, @@ -432,7 +432,8 @@ mod tests { use crate::execute; use super::{ - sys::position, MoveDown, MoveLeft, MoveRight, MoveTo, MoveUp, RestorePosition, SavePosition, + sys::position, MoveDown, MoveLeft, MoveRight, MoveTo, MoveUp, RestorePosition, + SavePosition, SetCursorStyle, }; // Test is disabled, because it's failing on Travis @@ -501,4 +502,18 @@ mod tests { assert_eq!(x, saved_x); assert_eq!(y, saved_y); } + + #[test] + fn test_set_cursor_style() { + assert_eq!( + SetCursorStyle::DefaultUserShape, + SetCursorStyle::DefaultUserShape + ); + assert_eq!(SetCursorStyle::BlinkingBlock, SetCursorStyle::BlinkingBlock,); + assert_ne!( + SetCursorStyle::BlinkingBlock, + SetCursorStyle::BlinkingUnderScore, + ); + assert_eq!(format!("{:?}", SetCursorStyle::SteadyBar), "SteadyBar"); + } } From fb8ab3a94460b0065dd66e114d6e19e50279558a Mon Sep 17 00:00:00 2001 From: linrongbin16 Date: Wed, 7 Aug 2024 15:00:55 +0800 Subject: [PATCH 02/10] chore --- src/cursor.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cursor.rs b/src/cursor.rs index 8d320355..a52d59a4 100644 --- a/src/cursor.rs +++ b/src/cursor.rs @@ -370,7 +370,7 @@ impl Command for DisableBlinking { /// # Note /// /// - Commands must be executed/queued for execution otherwise they do nothing. -#[derive(Clone, Copy, Debug, PartialEq, Eq)] +#[derive(Debug, Clone, Copy, PartialEq, Eq)] pub enum SetCursorStyle { /// Default cursor shape configured by the user. DefaultUserShape, From 60e287ddd246ec3c04a78b86a1bc658dc82d85f1 Mon Sep 17 00:00:00 2001 From: linrongbin16 Date: Wed, 7 Aug 2024 15:01:49 +0800 Subject: [PATCH 03/10] chore --- src/cursor.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cursor.rs b/src/cursor.rs index a52d59a4..38ab05f4 100644 --- a/src/cursor.rs +++ b/src/cursor.rs @@ -509,7 +509,7 @@ mod tests { SetCursorStyle::DefaultUserShape, SetCursorStyle::DefaultUserShape ); - assert_eq!(SetCursorStyle::BlinkingBlock, SetCursorStyle::BlinkingBlock,); + assert_eq!(SetCursorStyle::BlinkingBlock, SetCursorStyle::BlinkingBlock); assert_ne!( SetCursorStyle::BlinkingBlock, SetCursorStyle::BlinkingUnderScore, From e7e0c5d27cc69d59403ddf92ced5efe1f547977c Mon Sep 17 00:00:00 2001 From: linrongbin16 Date: Wed, 7 Aug 2024 17:36:18 +0800 Subject: [PATCH 04/10] chore --- src/cursor.rs | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/src/cursor.rs b/src/cursor.rs index 38ab05f4..6b38408c 100644 --- a/src/cursor.rs +++ b/src/cursor.rs @@ -505,15 +505,9 @@ mod tests { #[test] fn test_set_cursor_style() { - assert_eq!( - SetCursorStyle::DefaultUserShape, - SetCursorStyle::DefaultUserShape - ); + assert!(SetCursorStyle::DefaultUserShape == SetCursorStyle::DefaultUserShape); + assert!(SetCursorStyle::BlinkingBlock != SetCursorStyle::BlinkingUnderScore); assert_eq!(SetCursorStyle::BlinkingBlock, SetCursorStyle::BlinkingBlock); - assert_ne!( - SetCursorStyle::BlinkingBlock, - SetCursorStyle::BlinkingUnderScore, - ); assert_eq!(format!("{:?}", SetCursorStyle::SteadyBar), "SteadyBar"); } } From 3cc6b8c940aed78f26cc994223846c25ef8d5953 Mon Sep 17 00:00:00 2001 From: linrongbin16 Date: Wed, 7 Aug 2024 18:25:51 +0800 Subject: [PATCH 05/10] chore --- src/cursor.rs | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/src/cursor.rs b/src/cursor.rs index 6b38408c..04a89ce8 100644 --- a/src/cursor.rs +++ b/src/cursor.rs @@ -370,7 +370,7 @@ impl Command for DisableBlinking { /// # Note /// /// - Commands must be executed/queued for execution otherwise they do nothing. -#[derive(Debug, Clone, Copy, PartialEq, Eq)] +#[derive(Debug, Clone, Copy, PartialEq, Eq, Ord, PartialOrd, Hash)] pub enum SetCursorStyle { /// Default cursor shape configured by the user. DefaultUserShape, @@ -427,6 +427,7 @@ impl_display!(for SetCursorStyle); #[cfg(test)] #[cfg(feature = "events")] mod tests { + use std::hash::{DefaultHasher, Hash}; use std::io::{self, stdout}; use crate::execute; @@ -509,5 +510,22 @@ mod tests { assert!(SetCursorStyle::BlinkingBlock != SetCursorStyle::BlinkingUnderScore); assert_eq!(SetCursorStyle::BlinkingBlock, SetCursorStyle::BlinkingBlock); assert_eq!(format!("{:?}", SetCursorStyle::SteadyBar), "SteadyBar"); + let s1 = SetCursorStyle::DefaultUserShape; + let s2 = s1; + let s3 = s1.clone(); + assert!(s2 == s1); + assert!(s3 == s1); + let mut hasher = DefaultHasher::new(); + let h1 = &s1; + let h2 = &s2; + let h3 = &s3; + assert!(h1.hash(&mut hasher) == h2.hash(&mut hasher)); + assert!(h1.hash(&mut hasher) == h3.hash(&mut hasher)); + assert!(SetCursorStyle::DefaultUserShape < SetCursorStyle::BlinkingBlock); + assert!(SetCursorStyle::BlinkingBlock < SetCursorStyle::SteadyBlock); + assert!(SetCursorStyle::SteadyBlock < SetCursorStyle::BlinkingUnderScore); + assert!(SetCursorStyle::BlinkingUnderScore < SetCursorStyle::SteadyUnderScore); + assert!(SetCursorStyle::SteadyUnderScore < SetCursorStyle::BlinkingBar); + assert!(SetCursorStyle::BlinkingBar < SetCursorStyle::SteadyBar); } } From ea91d2e1e859f678f5ed6c851b5be82117464856 Mon Sep 17 00:00:00 2001 From: linrongbin16 Date: Thu, 8 Aug 2024 13:03:17 +0800 Subject: [PATCH 06/10] chore --- src/cursor.rs | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/src/cursor.rs b/src/cursor.rs index 04a89ce8..68552bc5 100644 --- a/src/cursor.rs +++ b/src/cursor.rs @@ -370,7 +370,7 @@ impl Command for DisableBlinking { /// # Note /// /// - Commands must be executed/queued for execution otherwise they do nothing. -#[derive(Debug, Clone, Copy, PartialEq, Eq, Ord, PartialOrd, Hash)] +#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] pub enum SetCursorStyle { /// Default cursor shape configured by the user. DefaultUserShape, @@ -516,16 +516,7 @@ mod tests { assert!(s2 == s1); assert!(s3 == s1); let mut hasher = DefaultHasher::new(); - let h1 = &s1; - let h2 = &s2; - let h3 = &s3; - assert!(h1.hash(&mut hasher) == h2.hash(&mut hasher)); - assert!(h1.hash(&mut hasher) == h3.hash(&mut hasher)); - assert!(SetCursorStyle::DefaultUserShape < SetCursorStyle::BlinkingBlock); - assert!(SetCursorStyle::BlinkingBlock < SetCursorStyle::SteadyBlock); - assert!(SetCursorStyle::SteadyBlock < SetCursorStyle::BlinkingUnderScore); - assert!(SetCursorStyle::BlinkingUnderScore < SetCursorStyle::SteadyUnderScore); - assert!(SetCursorStyle::SteadyUnderScore < SetCursorStyle::BlinkingBar); - assert!(SetCursorStyle::BlinkingBar < SetCursorStyle::SteadyBar); + assert!(s1.hash(&mut hasher) == s2.hash(&mut hasher)); + assert!(s1.hash(&mut hasher) == s3.hash(&mut hasher)); } } From f44c662f55c5bd84ef2564f6f6584d6045026ce3 Mon Sep 17 00:00:00 2001 From: linrongbin16 Date: Fri, 9 Aug 2024 13:28:37 +0800 Subject: [PATCH 07/10] Update src/cursor.rs Co-authored-by: Josh McKinney --- src/cursor.rs | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/src/cursor.rs b/src/cursor.rs index 68552bc5..80985122 100644 --- a/src/cursor.rs +++ b/src/cursor.rs @@ -504,19 +504,4 @@ mod tests { assert_eq!(y, saved_y); } - #[test] - fn test_set_cursor_style() { - assert!(SetCursorStyle::DefaultUserShape == SetCursorStyle::DefaultUserShape); - assert!(SetCursorStyle::BlinkingBlock != SetCursorStyle::BlinkingUnderScore); - assert_eq!(SetCursorStyle::BlinkingBlock, SetCursorStyle::BlinkingBlock); - assert_eq!(format!("{:?}", SetCursorStyle::SteadyBar), "SteadyBar"); - let s1 = SetCursorStyle::DefaultUserShape; - let s2 = s1; - let s3 = s1.clone(); - assert!(s2 == s1); - assert!(s3 == s1); - let mut hasher = DefaultHasher::new(); - assert!(s1.hash(&mut hasher) == s2.hash(&mut hasher)); - assert!(s1.hash(&mut hasher) == s3.hash(&mut hasher)); - } } From 6b81b94abceb51aa2f1610817bbf7a0b9cb77b8f Mon Sep 17 00:00:00 2001 From: linrongbin16 Date: Fri, 9 Aug 2024 13:30:12 +0800 Subject: [PATCH 08/10] Update cursor.rs --- src/cursor.rs | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/cursor.rs b/src/cursor.rs index 80985122..6a2d3ea7 100644 --- a/src/cursor.rs +++ b/src/cursor.rs @@ -427,7 +427,6 @@ impl_display!(for SetCursorStyle); #[cfg(test)] #[cfg(feature = "events")] mod tests { - use std::hash::{DefaultHasher, Hash}; use std::io::{self, stdout}; use crate::execute; @@ -503,5 +502,4 @@ mod tests { assert_eq!(x, saved_x); assert_eq!(y, saved_y); } - } From 10c2b9ed488404c7fa04c9fe708989ceb95e87c6 Mon Sep 17 00:00:00 2001 From: linrongbin16 Date: Fri, 9 Aug 2024 13:30:40 +0800 Subject: [PATCH 09/10] Update cursor.rs --- src/cursor.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cursor.rs b/src/cursor.rs index 6a2d3ea7..a8aaeb19 100644 --- a/src/cursor.rs +++ b/src/cursor.rs @@ -433,7 +433,7 @@ mod tests { use super::{ sys::position, MoveDown, MoveLeft, MoveRight, MoveTo, MoveUp, RestorePosition, - SavePosition, SetCursorStyle, + SavePosition, }; // Test is disabled, because it's failing on Travis From 30fe0db235689824507f82ff9eb0fa876032823a Mon Sep 17 00:00:00 2001 From: linrongbin16 Date: Fri, 9 Aug 2024 13:31:23 +0800 Subject: [PATCH 10/10] Update cursor.rs --- src/cursor.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/cursor.rs b/src/cursor.rs index a8aaeb19..24796dc4 100644 --- a/src/cursor.rs +++ b/src/cursor.rs @@ -432,8 +432,7 @@ mod tests { use crate::execute; use super::{ - sys::position, MoveDown, MoveLeft, MoveRight, MoveTo, MoveUp, RestorePosition, - SavePosition, + sys::position, MoveDown, MoveLeft, MoveRight, MoveTo, MoveUp, RestorePosition, SavePosition, }; // Test is disabled, because it's failing on Travis