mirror of
https://github.com/nushell/reedline.git
synced 2024-09-11 15:55:50 +03:00
feat: impl ClearScreen with crossterm's Clear (#813)
* feat: add ClearDisplay event Signed-off-by: tison <wander4096@gmail.com> * take 2 - reimpl clear_screen Signed-off-by: tison <wander4096@gmail.com> --------- Signed-off-by: tison <wander4096@gmail.com>
This commit is contained in:
parent
ad56a23d05
commit
f2b414c678
@ -510,23 +510,18 @@ impl Painter {
|
||||
/// Clear the screen by printing enough whitespace to start the prompt or
|
||||
/// other output back at the first line of the terminal.
|
||||
pub(crate) fn clear_screen(&mut self) -> Result<()> {
|
||||
self.stdout.queue(cursor::Hide)?;
|
||||
let (_, num_lines) = terminal::size()?;
|
||||
for _ in 0..2 * num_lines {
|
||||
self.stdout.queue(Print("\n"))?;
|
||||
}
|
||||
self.stdout.queue(MoveTo(0, 0))?;
|
||||
self.stdout.queue(cursor::Show)?;
|
||||
|
||||
self.stdout.flush()?;
|
||||
self.stdout
|
||||
.queue(Clear(ClearType::All))?
|
||||
.queue(MoveTo(0, 0))?
|
||||
.flush()?;
|
||||
self.initialize_prompt_position(None)
|
||||
}
|
||||
|
||||
pub(crate) fn clear_scrollback(&mut self) -> Result<()> {
|
||||
self.stdout
|
||||
.queue(crossterm::terminal::Clear(ClearType::All))?
|
||||
.queue(crossterm::terminal::Clear(ClearType::Purge))?
|
||||
.queue(cursor::MoveTo(0, 0))?
|
||||
.queue(Clear(ClearType::All))?
|
||||
.queue(Clear(ClearType::Purge))?
|
||||
.queue(MoveTo(0, 0))?
|
||||
.flush()?;
|
||||
self.initialize_prompt_position(None)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user