Skip to content

Commit

Permalink
Auto merge of #227 - workingjubilee:watch-clears-terminal, r=fmoko
Browse files Browse the repository at this point in the history
watch: clears terminal before entering loop

Fixes #146

If someone is sliding in and out of "watch" mode, it can make it hard
to tell which error messages are still relevant. This patch resolves
that by clearing the terminal entirely before entering watch's loop.

Note that the escape character is chosen for compatibility reasons, because different shells/terminals can change which commands they accept or have installed, betting on what other commands are in use to collect data seems risky, and just expecting them to implement ANSI escape code sequences is more reliable. This seems especially true since Windows is seeking more UNIX compatibility in its terminals going forward, even though it doesn't implement the POSIX standard per se.
  • Loading branch information
bors committed Nov 9, 2019
2 parents 79a5694 + 83be517 commit fea8141
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,9 @@ fn main() {
}

if matches.subcommand_matches("watch").is_some() {
/* Clears the terminal with an ANSI escape code.
Works in UNIX and newer Windows terminals. */
println!("\x1Bc");
watch(&exercises).unwrap();
}

Expand Down

0 comments on commit fea8141

Please sign in to comment.