pub(crate) fn cleanup(
    mut out: impl io::Write,
    es: &crate::ExitStrategy,
    cleanup_screen: bool,
) -> std::result::Result<(), CleanupError> {
    if cleanup_screen {
        // Reverse order of setup.
        execute!(out, event::DisableMouseCapture)
            .map_err(|e| CleanupError::DisableMouseCapture(e.into()))?;
        execute!(out, cursor::Show).map_err(|e| CleanupError::ShowCursor(e.into()))?;
        terminal::disable_raw_mode().map_err(|e| CleanupError::DisableRawMode(e.into()))?;
        execute!(out, terminal::LeaveAlternateScreen)
            .map_err(|e| CleanupError::LeaveAlternateScreen(e.into()))?;
    }

    if *es == crate::ExitStrategy::ProcessQuit {
        std::process::exit(0);
    } else {
        Ok(())
    }
}
// Will try to clean up the terminal and set it back to its original state,
// before the pager was setup and called.
//
// Use this function if you encounter problems with your application not
// correctly setting back the terminal on errors.
//
// ## Errors
//
// Cleaning up the terminal can fail, see [`CleanupError`](CleanupError).
Will try to clean up the terminal and set it back to its original state,
before the pager was setup and called.

Use this function if you encounter problems with your application not
correctly setting back the terminal on errors.
Will try to clean up the terminal and set it back to its original state before the pager was setup and called . Use this function if you encounter problems with your application not correctly setting back the terminal on errors .
pub(crate) fn cleanup(
    mut out: impl io::Write,
    es: &crate::ExitStrategy,
    cleanup_screen: bool,
) -> std::result::Result<(), CleanupError> {
    if cleanup_screen {
        // Reverse order of setup.
        execute!(out, event::DisableMouseCapture)
            .map_err(|e| CleanupError::DisableMouseCapture(e.into()))?;
        execute!(out, cursor::Show).map_err(|e| CleanupError::ShowCursor(e.into()))?;
        terminal::disable_raw_mode().map_err(|e| CleanupError::DisableRawMode(e.into()))?;
        execute!(out, terminal::LeaveAlternateScreen)
            .map_err(|e| CleanupError::LeaveAlternateScreen(e.into()))?;
    }
    if *es == crate::ExitStrategy::ProcessQuit {
        std::process::exit(0);
    } else {
        Ok(())
    }
}
pub ( crate ) fn cleanup ( mut out : impl io :: Write , es : & crate :: ExitStrategy , cleanup_screen : bool , ) -> std :: result :: Result < ( ) , CleanupError > { if cleanup_screen { // Reverse order of setup. execute ! ( out event DisableMouseCapture ) . map_err ( | e | CleanupError :: DisableMouseCapture ( e . into ( ) ) ) ? ; execute ! ( out cursor Show ) . map_err ( | e | CleanupError :: ShowCursor ( e . into ( ) ) ) ? ; terminal :: disable_raw_mode ( ) . map_err ( | e | CleanupError :: DisableRawMode ( e . into ( ) ) ) ? ; execute ! ( out terminal LeaveAlternateScreen ) . map_err ( | e | CleanupError :: LeaveAlternateScreen ( e . into ( ) ) ) ? ; } if * es == crate :: ExitStrategy :: ProcessQuit { std :: process :: exit ( 0 ) ; } else { Ok ( ( ) ) } }
Will try to clean up the terminal and set it back to its original state,
before the pager was setup and called.
Will try to clean up the terminal and set it back to its original state before the pager was setup and called .
out
impl io::Write
es
&crate::ExitStrategy
cleanup_screen
bool
out
impl io::Write
es
&crate::ExitStrategy
cleanup_screen
bool
errors
Cleaning up the terminal can fail, see [`CleanupError`](CleanupError).
Cleaning up the terminal can fail see [ ` CleanupError ` ] ( CleanupError ) .