/* * Copyright (C) 2024 Jonni Liljamo * * This file is licensed under GPL-3.0-or-later, see NOTICE and LICENSE for * more information. */ use std::io::Stdout; use crossterm::{cursor, terminal, ExecutableCommand}; pub fn clear_and_reset_cursor(stdout: &mut Stdout) { stdout .execute(terminal::Clear(terminal::ClearType::All)) .expect("could not clear terminal"); stdout .execute(cursor::MoveTo(0, 0)) .expect("could not move cursor to 0,0"); } pub fn save_cursor(stdout: &mut Stdout) { stdout .execute(cursor::SavePosition) .expect("could not save cursor position"); } pub fn restore_cursor_and_clear(stdout: &mut Stdout) { stdout .execute(cursor::RestorePosition) .expect("could not restore cursor position"); stdout .execute(terminal::Clear(terminal::ClearType::FromCursorDown)) .expect("could not clear terminal"); }