Here's the situation, I want to make some terminal interaction, I want to start child thread to refresh the first N lines, and use the main thread to handle user input.
After that the program will print changeable string, maybe some logs.
The child thread like this:
let mut count: i32 = 0;
loop {
println!("\x1B[2F\x1B[2KHi user1, count:{}\n", count);
count += 1;
let ten_millis = time::Duration::from_millis(1000);
thread::sleep(ten_millis);
}
e.g.:
----------------
Hi user1, count: 0
Input: 1+1
Output: 2
----------------
The refresher code works well, but the cursor will reset to the start of line, and I want to move it always to the end of the last line. How can I do this trick?
Any help would be great appreciated.