2024-08-08 03:45:18 +03:00
|
|
|
use std::io::{self, BufRead, StdoutLock, Write};
|
|
|
|
|
2024-08-24 01:14:12 +03:00
|
|
|
use crossterm::{
|
|
|
|
cursor::MoveTo,
|
|
|
|
terminal::{Clear, ClearType},
|
|
|
|
QueueableCommand,
|
|
|
|
};
|
|
|
|
|
2024-08-08 03:45:18 +03:00
|
|
|
pub fn clear_terminal(stdout: &mut StdoutLock) -> io::Result<()> {
|
2024-08-24 01:14:12 +03:00
|
|
|
stdout
|
|
|
|
.queue(MoveTo(0, 0))?
|
|
|
|
.queue(Clear(ClearType::All))?
|
|
|
|
.queue(Clear(ClearType::Purge))
|
|
|
|
.map(|_| ())
|
2024-08-08 03:45:18 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
pub fn press_enter_prompt(stdout: &mut StdoutLock) -> io::Result<()> {
|
|
|
|
stdout.flush()?;
|
|
|
|
io::stdin().lock().read_until(b'\n', &mut Vec::new())?;
|
|
|
|
stdout.write_all(b"\n")?;
|
|
|
|
Ok(())
|
|
|
|
}
|