Skip to content

Instantly share code, notes, and snippets.

@spytheman
Created January 26, 2020 17:43
Show Gist options
  • Save spytheman/a9028cf856b6696376663a448e964e7a to your computer and use it in GitHub Desktop.
Save spytheman/a9028cf856b6696376663a448e964e7a to your computer and use it in GitHub Desktop.
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')
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment