From 6261d6b457fae0fe9528175742c936ee4b0a2e59 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Saccoccio?= Date: Wed, 11 Jan 2023 21:28:09 +0100 Subject: [PATCH 1/3] SetCursorStyle improvements --- src/cursor.rs | 20 +++++++++++++------- src/lib.rs | 5 ++--- 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/src/cursor.rs b/src/cursor.rs index a5e203346..ec0b05f1c 100644 --- a/src/cursor.rs +++ b/src/cursor.rs @@ -333,7 +333,10 @@ impl Command for Show { /// /// # Notes /// +/// - Some Unix terminals (ex: GNOME and Konsole) do not support this functionality. +/// Use SetCursorStyle for better cross-compatibility. /// - Windows versions lower than Windows 10 do not support this functionality. +/// Use SetCursorStyle for better cross-compatibility. /// - Commands must be executed/queued for execution otherwise they do nothing. #[derive(Debug, Clone, Copy, PartialEq, Eq)] pub struct EnableBlinking; @@ -353,7 +356,10 @@ impl Command for EnableBlinking { /// /// # Notes /// +/// - Some Unix terminals (ex: GNOME and Konsole) do not support this functionality. +/// Use SetCursorStyle for better cross-compatibility. /// - Windows versions lower than Windows 10 do not support this functionality. +/// Use SetCursorStyle for better cross-compatibility. /// - Commands must be executed/queued for execution otherwise they do nothing. #[derive(Debug, Clone, Copy, PartialEq, Eq)] pub struct DisableBlinking; @@ -393,13 +399,13 @@ pub enum SetCursorStyle { impl Command for SetCursorStyle { fn write_ansi(&self, f: &mut impl fmt::Write) -> fmt::Result { match self { - SetCursorStyle::DefaultUserShape => f.write_str("\x1b[?12h\x1b[0 q"), - SetCursorStyle::BlinkingBlock => f.write_str("\x1b[?12h\x1b[1 q"), - SetCursorStyle::SteadyBlock => f.write_str("\x1b[?12l\x1b[2 q"), - SetCursorStyle::BlinkingUnderScore => f.write_str("\x1b[?12h\x1b[3 q"), - SetCursorStyle::SteadyUnderScore => f.write_str("\x1b[?12l\x1b[4 q"), - SetCursorStyle::BlinkingBar => f.write_str("\x1b[?12h\x1b[5 q"), - SetCursorStyle::SteadyBar => f.write_str("\x1b[?12l\x1b[6 q"), + SetCursorStyle::DefaultUserShape => f.write_str("\x1b[0 q"), + SetCursorStyle::BlinkingBlock => f.write_str("\x1b[1 q"), + SetCursorStyle::SteadyBlock => f.write_str("\x1b[2 q"), + SetCursorStyle::BlinkingUnderScore => f.write_str("\x1b[3 q"), + SetCursorStyle::SteadyUnderScore => f.write_str("\x1b[4 q"), + SetCursorStyle::BlinkingBar => f.write_str("\x1b[5 q"), + SetCursorStyle::SteadyBar => f.write_str("\x1b[6 q"), } } diff --git a/src/lib.rs b/src/lib.rs index 4bcb70841..2a2fc6c6a 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -41,15 +41,14 @@ //! - Module [`cursor`](cursor/index.html) //! - Visibility - [`Show`](cursor/struct.Show.html), [`Hide`](cursor/struct.Hide.html) //! - Appearance - [`EnableBlinking`](cursor/struct.EnableBlinking.html), -//! [`DisableBlinking`](cursor/struct.DisableBlinking.html) +//! [`DisableBlinking`](cursor/struct.DisableBlinking.html), +//! [`SetCursorStyle`](cursor/enum.SetCursorStyle.html) //! - Position - //! [`SavePosition`](cursor/struct.SavePosition.html), [`RestorePosition`](cursor/struct.RestorePosition.html), //! [`MoveUp`](cursor/struct.MoveUp.html), [`MoveDown`](cursor/struct.MoveDown.html), //! [`MoveLeft`](cursor/struct.MoveLeft.html), [`MoveRight`](cursor/struct.MoveRight.html), //! [`MoveTo`](cursor/struct.MoveTo.html), [`MoveToColumn`](cursor/struct.MoveToColumn.html),[`MoveToRow`](cursor/struct.MoveToRow.html), //! [`MoveToNextLine`](cursor/struct.MoveToNextLine.html), [`MoveToPreviousLine`](cursor/struct.MoveToPreviousLine.html) -//! - Shape - -//! [`SetCursorShape`](cursor/struct.SetCursorShape.html) //! - Module [`event`](event/index.html) //! - Keyboard events - //! [`PushKeyboardEnhancementFlags`](event/struct.PushKeyboardEnhancementFlags.html), From b619904e81fa1aeb65089692dfa3601f6bf129fe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Saccoccio?= Date: Wed, 11 Jan 2023 21:45:33 +0100 Subject: [PATCH 2/3] documentation --- src/cursor.rs | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/cursor.rs b/src/cursor.rs index ec0b05f1c..94384eed1 100644 --- a/src/cursor.rs +++ b/src/cursor.rs @@ -333,9 +333,7 @@ impl Command for Show { /// /// # Notes /// -/// - Some Unix terminals (ex: GNOME and Konsole) do not support this functionality. -/// Use SetCursorStyle for better cross-compatibility. -/// - Windows versions lower than Windows 10 do not support this functionality. +/// - Some Unix terminals (ex: GNOME and Konsole) as well as Windows versions lower than Windows 10 do not support this functionality. /// Use SetCursorStyle for better cross-compatibility. /// - Commands must be executed/queued for execution otherwise they do nothing. #[derive(Debug, Clone, Copy, PartialEq, Eq)] @@ -356,9 +354,7 @@ impl Command for EnableBlinking { /// /// # Notes /// -/// - Some Unix terminals (ex: GNOME and Konsole) do not support this functionality. -/// Use SetCursorStyle for better cross-compatibility. -/// - Windows versions lower than Windows 10 do not support this functionality. +/// - Some Unix terminals (ex: GNOME and Konsole) as well as Windows versions lower than Windows 10 do not support this functionality. /// Use SetCursorStyle for better cross-compatibility. /// - Commands must be executed/queued for execution otherwise they do nothing. #[derive(Debug, Clone, Copy, PartialEq, Eq)] From a2d8d47545948768191bf4a83cda4465b389da52 Mon Sep 17 00:00:00 2001 From: Timon Date: Thu, 12 Jan 2023 21:06:24 +0100 Subject: [PATCH 3/3] Remove documentation line --- src/cursor.rs | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/src/cursor.rs b/src/cursor.rs index 94384eed1..277e013ce 100644 --- a/src/cursor.rs +++ b/src/cursor.rs @@ -328,13 +328,11 @@ impl Command for Show { } /// A command that enables blinking of the terminal cursor. -/// -/// See `SetCursorStyle` which is more advanced and better supported. -/// +/// /// # Notes /// /// - Some Unix terminals (ex: GNOME and Konsole) as well as Windows versions lower than Windows 10 do not support this functionality. -/// Use SetCursorStyle for better cross-compatibility. +/// Use `SetCursorStyle` for better cross-compatibility. /// - Commands must be executed/queued for execution otherwise they do nothing. #[derive(Debug, Clone, Copy, PartialEq, Eq)] pub struct EnableBlinking; @@ -350,12 +348,10 @@ impl Command for EnableBlinking { /// A command that disables blinking of the terminal cursor. /// -/// See `SetCursorStyle` which is more advanced and better supported. -/// /// # Notes /// /// - Some Unix terminals (ex: GNOME and Konsole) as well as Windows versions lower than Windows 10 do not support this functionality. -/// Use SetCursorStyle for better cross-compatibility. +/// Use `SetCursorStyle` for better cross-compatibility. /// - Commands must be executed/queued for execution otherwise they do nothing. #[derive(Debug, Clone, Copy, PartialEq, Eq)] pub struct DisableBlinking;