-
-
Save spytheman/a9028cf856b6696376663a448e964e7a to your computer and use it in GitHub Desktop.
This file contains 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
import os | |
fn C.scanf() | |
fn get_cursor_position() (int,int) { | |
mut x := 0 mut y := 0 | |
C.printf('\033[6n') | |
C.scanf('\033[%d;%dR', &x, &y) | |
return x,y | |
} | |
fn main(){ | |
print('hello world!') | |
oldmode := os.exec('stty -g') or { panic(err) } | |
os.exec('stty raw -echo min 1') or { panic(err) } | |
x,y := get_cursor_position() | |
os.system('stty $oldmode.output') | |
eprintln('\nx: $x | y: $y | oldmode: $oldmode.output') | |
} |
Author
spytheman
commented
Jan 26, 2020
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment