From 5eaf42a3a9686576e74871dcbe1dbe5cf1f27115 Mon Sep 17 00:00:00 2001 From: Hampus Lidin Date: Mon, 14 Nov 2022 22:47:54 +0100 Subject: [PATCH 1/2] Implement `clear_to_end_of_line` --- src/common_term.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/common_term.rs b/src/common_term.rs index 020660a5..3aea7d04 100644 --- a/src/common_term.rs +++ b/src/common_term.rs @@ -51,6 +51,11 @@ pub fn clear_line(out: &Term) -> io::Result<()> { out.write_str("\r\x1b[2K") } +#[inline] +pub fn clear_to_end_of_line(out: &Term) -> io::Result<()> { + out.write_str("\r\x1b[0K") +} + #[inline] pub fn clear_screen(out: &Term) -> io::Result<()> { out.write_str("\r\x1b[2J\r\x1b[H") From 8998b344112c60c6d71bb2013a739de763718a67 Mon Sep 17 00:00:00 2001 From: Hampus Lidin Date: Mon, 14 Nov 2022 21:53:14 +0000 Subject: [PATCH 2/2] Add `clear_to_end_of_line` method --- src/term.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/term.rs b/src/term.rs index 350a7894..10441328 100644 --- a/src/term.rs +++ b/src/term.rs @@ -446,6 +446,14 @@ impl Term { clear_line(self) } + /// Clear from the current cursor position to the end of the line. + /// + /// Position of the cursor does not change. + #[inline] + pub fn clear_to_end_of_line(&self) -> io::Result<()> { + clear_to_end_of_line(self) + } + /// Clear the last `n` lines before the current line. /// /// Position the cursor at the beginning of the first line that was cleared.