cursor/
cursor.rs

1use std::time::Duration;
2
3use async_tty::commands::cursor::{CursorDown, CursorPosition, CursorUp};
4use tokio::io::AsyncWriteExt;
5use tokio::time::sleep;
6
7#[tokio::main]
8async fn main() -> color_eyre::Result<()> {
9    color_eyre::install()?;
10    let mut terminal = async_tty::Terminal::new()?;
11    terminal.switch_to_alternate_screen().await?;
12    let cursor_movements = format!(
13        "{}at 20,10{}up 1{}down 2",
14        CursorPosition {
15            row: 10,
16            column: 20,
17        },
18        CursorUp { count: 1 },
19        CursorDown { count: 2 }
20    );
21    terminal.write_all(cursor_movements.as_bytes()).await?;
22    sleep(Duration::from_secs(2)).await;
23    terminal.switch_to_main_screen().await?;
24    Ok(())
25}