Add Reset outcome (#186, #211)

This commit is contained in:
Félix Saparelli 2021-09-04 01:55:25 +12:00
parent 645ab74c62
commit 4043ed34ae
No known key found for this signature in database
GPG Key ID: B948C4BAE44FC474
1 changed files with 20 additions and 1 deletions

View File

@ -7,6 +7,7 @@ use std::{
};
use atomic_take::AtomicTake;
use clearscreen::ClearScreen;
use once_cell::sync::OnceCell;
use tokio::{
process::Command,
@ -154,9 +155,16 @@ pub enum Outcome {
/// Send this signal to the command.
Signal(Signal),
/// Clear the screen.
/// Clear the (terminal) screen.
Clear,
/// Reset the (terminal) screen.
///
/// This invokes: [`WindowsCooked`][ClearScreen::WindowsCooked],
/// [`WindowsVt`][ClearScreen::WindowsVt], [`VtWellDone`][ClearScreen::VtWellDone],
/// and [the default][ClearScreen::default()], in this order.
Reset,
/// Exit watchexec.
Exit,
@ -391,6 +399,17 @@ async fn apply_outcome(
clearscreen::clear()?;
}
(_, Outcome::Reset) => {
for cs in [
ClearScreen::WindowsCooked,
ClearScreen::WindowsVt,
ClearScreen::VtWellDone,
ClearScreen::default(),
] {
cs.clear()?;
}
}
(Some(_), Outcome::IfRunning(then, _)) => {
apply_outcome(
*then,