mirror of
https://github.com/rust-lang/rustlings.git
synced 2026-01-03 09:19:18 +00:00
Added 'cls' command to 'watch' mode (in addition to 'hint') so we can clear the screen :)
This commit is contained in:
parent
523d18b873
commit
4306586348
@ -143,15 +143,18 @@ fn main() {
|
|||||||
|
|
||||||
fn spawn_watch_shell(failed_exercise_hint: &Arc<Mutex<Option<String>>>) {
|
fn spawn_watch_shell(failed_exercise_hint: &Arc<Mutex<Option<String>>>) {
|
||||||
let failed_exercise_hint = Arc::clone(failed_exercise_hint);
|
let failed_exercise_hint = Arc::clone(failed_exercise_hint);
|
||||||
println!("Type 'hint' to get help");
|
println!("Type 'hint' to get help or 'cls' to clear the screen");
|
||||||
thread::spawn(move || loop {
|
thread::spawn(move || loop {
|
||||||
let mut input = String::new();
|
let mut input = String::new();
|
||||||
match io::stdin().read_line(&mut input) {
|
match io::stdin().read_line(&mut input) {
|
||||||
Ok(_) => {
|
Ok(_) => {
|
||||||
if input.trim().eq("hint") {
|
let input = input.trim();
|
||||||
|
if input.eq("hint") {
|
||||||
if let Some(hint) = &*failed_exercise_hint.lock().unwrap() {
|
if let Some(hint) = &*failed_exercise_hint.lock().unwrap() {
|
||||||
println!("{}", hint);
|
println!("{}", hint);
|
||||||
}
|
}
|
||||||
|
} else if input.eq("cls") {
|
||||||
|
println!("\x1B[2J\x1B[1;1H");
|
||||||
} else {
|
} else {
|
||||||
println!("unknown command: {}", input);
|
println!("unknown command: {}", input);
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user