Last active
August 29, 2015 14:14
-
-
Save carols10cents/c87ef14458d0f3531931 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| fn ansi_esc(input: &str) -> String { | |
| format!("\x1b[{}", input) | |
| } | |
| fn ansi_escape(message: &str) { | |
| let out = ansi_esc(message); | |
| // Use println to reproduce the issue | |
| println!("{}", out); | |
| // Use print to fix the issue | |
| // print!("{}", out); | |
| } | |
| fn ansi_set_position(line: usize, column: usize) { | |
| let message = format!("{};{}H", line + 1, column + 1); | |
| ansi_escape(message.as_slice()); | |
| } | |
| fn main() { | |
| // my screen height is 45 | |
| let number_greater_than_your_screen_height = 46us; | |
| for i in 0..number_greater_than_your_screen_height { | |
| ansi_set_position(i, 0); | |
| ansi_escape("2K"); | |
| ansi_set_position(i, 0); | |
| println!("{}", i); | |
| } | |
| } | |
| // What it looks like to reproduce the issue: | |
| // 40 | |
| // 41 | |
| // 42 | |
| // | |
| // 43 | |
| // | |
| // | |
| // | |
| // 44 | |
| // | |
| // | |
| // | |
| // 45 | |
| // What it looks like to fix the issue: | |
| // 40 | |
| // 41 | |
| // 42 | |
| // 43 | |
| // 44 | |
| // 45 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment