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") diff --git a/src/term.rs b/src/term.rs index 1715a2ff..7d62ced4 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.