Skip to main content

rl_lang/interpreter/stdlib/terminal/
move_cursor.rs

1use crate::interpreter::stdlib::common::{try_fn, verr, vnl, vok, vs};
2use crate::interpreter::stdlib::terminal::common::extract_u16;
3use crate::interpreter::{evaluator::Evaluator, values::Value};
4use crossterm::{cursor::MoveTo, execute};
5use std::io::stdout;
6
7pub fn func(_: &mut Evaluator, x: Value, y: Value) -> Value {
8    let x = match extract_u16(x, "x") {
9        Ok(v) => v,
10        Err(e) => return verr!(vs!(e)),
11    };
12    let y = match extract_u16(y, "y") {
13        Ok(v) => v,
14        Err(e) => return verr!(vs!(e)),
15    };
16
17    try_fn!("term_move", execute!(stdout(), MoveTo(x, y)));
18
19    vok!(vnl!())
20}