Initial commit
[mlrogue.git] / rawmode-stty.sml
blobd461e0e54eeadeb56b9371966cde51c45004e386
1 structure RM :
2 sig
3 val enable : unit -> OS.Process.status
4 val disable : unit -> OS.Process.status
5 end =
6 struct
7 val orig = ref ""
9 fun enable () =
10 let
11 val stty = Unix.execute("/usr/bin/stty", ["-F", "/dev/tty", "-g"])
12 val _ = orig := TextIO.input (Unix.textInstreamOf stty)
13 val _ = Unix.reap stty
15 OS.Process.system "stty raw -echo"
16 end
18 fun disable () = OS.Process.system ("stty " ^ !orig)
19 end