summaryrefslogtreecommitdiff
path: root/src/main.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/main.rs')
-rw-r--r--src/main.rs14
1 files changed, 7 insertions, 7 deletions
diff --git a/src/main.rs b/src/main.rs
index c51f63c..3e37ce2 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -1,12 +1,8 @@
use anyhow::{bail, Context, Result};
use app_state::StateFileStatus;
use clap::{Parser, Subcommand};
-use crossterm::{
- terminal::{Clear, ClearType},
- ExecutableCommand,
-};
use std::{
- io::{self, BufRead, Write},
+ io::{self, BufRead, StdoutLock, Write},
path::Path,
process::exit,
};
@@ -45,6 +41,10 @@ fn in_official_repo() -> bool {
Path::new("dev/rustlings-repo.txt").exists()
}
+fn clear_terminal(stdout: &mut StdoutLock) -> io::Result<()> {
+ stdout.write_all(b"\x1b[H\x1b[2J\x1b[3J")
+}
+
/// Rustlings is a collection of small exercises to get you used to writing and reading Rust code
#[derive(Parser)]
#[command(version)]
@@ -129,7 +129,7 @@ fn main() -> Result<()> {
match state_file_status {
StateFileStatus::NotRead => {
let mut stdout = io::stdout().lock();
- stdout.execute(Clear(ClearType::All))?;
+ clear_terminal(&mut stdout)?;
let welcome_message = welcome_message.trim();
write!(stdout, "{welcome_message}\n\nPress ENTER to continue ")?;
@@ -137,7 +137,7 @@ fn main() -> Result<()> {
io::stdin().lock().read_until(b'\n', &mut Vec::new())?;
- stdout.execute(Clear(ClearType::All))?;
+ clear_terminal(&mut stdout)?;
}
StateFileStatus::Read => (),
}