Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement