local ttysettings_file function setup_screen() ttysettings_file = os.tmpname() os.execute("stty -g > "..ttysettings_file) -- hope no weird chars in filename! os.execute("stty cbreak -echo -ixon") end function restore_screen() os.execute("stty $(cat "..ttysettings_file..")") os.remove(ttysettings_file) end function termout(s) io.stdout:write(s) end function termin() return io.stdin:read(1) end function reset_terminal() termout("\27c") end function gotoxy(x, y) termout("\27["..y..";"..x.."H") end function home_cursor() gotoxy("0", "0") end