1///|
2type Tty
3
4///|
5pub impl trait ToHandle {
to_handle(Self) -> Handle
of_handle(Handle) -> Self
close(Self, (Self) -> Unit) -> Unit
is_closing(Self) -> Bool
}
ToHandle for Tty with to_handle(tty : Tty) -> Handle = "%identity"
6
7///|
8pub impl trait ToHandle {
to_handle(Self) -> Handle
of_handle(Handle) -> Self
close(Self, (Self) -> Unit) -> Unit
is_closing(Self) -> Bool
}
ToHandle for Tty with of_handle(handle : Handle) -> Tty = "%identity"
9
10///|
11pub impl trait ToStream {
to_stream(Self) -> Stream
of_stream(Stream) -> Self
read_start(Self, (Self, Int) -> @bytes.View, (Self, Int, @bytes.View) -> Unit, (Self, Errno) -> Unit) -> Unit!Errno
read_stop(Self) -> Unit!Errno
write(Self, Array[@bytes.View], (Write) -> Unit, (Write, Errno) -> Unit) -> Unit!Errno
listen(Self, Int, (Self) -> Unit, (Self, Errno) -> Unit) -> Unit!Errno
is_readable(Self) -> Bool
is_writable(Self) -> Bool
shutdown(Self, (Shutdown) -> Unit, (Shutdown, Errno) -> Unit) -> Unit!Errno
}
ToStream for Tty with to_stream(tty : Tty) -> Stream = "%identity"
12
13///|
14pub impl trait ToStream {
to_stream(Self) -> Stream
of_stream(Stream) -> Self
read_start(Self, (Self, Int) -> @bytes.View, (Self, Int, @bytes.View) -> Unit, (Self, Errno) -> Unit) -> Unit!Errno
read_stop(Self) -> Unit!Errno
write(Self, Array[@bytes.View], (Write) -> Unit, (Write, Errno) -> Unit) -> Unit!Errno
listen(Self, Int, (Self) -> Unit, (Self, Errno) -> Unit) -> Unit!Errno
is_readable(Self) -> Bool
is_writable(Self) -> Bool
shutdown(Self, (Shutdown) -> Unit, (Shutdown, Errno) -> Unit) -> Unit!Errno
}
ToStream for Tty with of_stream(stream : Stream) -> Tty = "%identity"
15
16///|
17extern "c" fn uv_tty_make() -> Tty = "moonbit_uv_tty_make"
18
19///|
20extern "c" fn uv_tty_init(uv : Loop, tty : Tty, fd : Int) -> Int = "moonbit_uv_tty_init"
21
22///|
23pub fn Tty::(self : Loop, file : File) -> Tty!Errno
new(self : Loop, file : File) -> Tty!Errno {
24 let tty = uv_tty_make()
25 let result = (uv : Loop, tty : Tty, fd : Int) -> Int
uv_tty_init(self, tty, file._)
26 if result (self_ : Int, other : Int) -> Bool
< 0 {
27 raise Errno::of_int(result)
28 }
29 tty
30}
31
32///|
33enum TtyMode {
34 Normal
35 Raw
36 Io
37 RawVT
38}
39
40///|
41pub fn enum TtyMode {
Normal
Raw
Io
RawVT
}
TtyMode::normal() -> enum TtyMode {
Normal
Raw
Io
RawVT
}
TtyMode {
42 TtyMode::Normal
43}
44
45///|
46pub fn enum TtyMode {
Normal
Raw
Io
RawVT
}
TtyMode::raw() -> enum TtyMode {
Normal
Raw
Io
RawVT
}
TtyMode {
47 TtyMode::Raw
48}
49
50///|
51pub fn enum TtyMode {
Normal
Raw
Io
RawVT
}
TtyMode::io() -> enum TtyMode {
Normal
Raw
Io
RawVT
}
TtyMode {
52 TtyMode::Io
53}
54
55///|
56pub fn enum TtyMode {
Normal
Raw
Io
RawVT
}
TtyMode::raw_vt() -> enum TtyMode {
Normal
Raw
Io
RawVT
}
TtyMode {
57 TtyMode::RawVT
58}
59
60///|
61extern "c" fn uv_tty_set_mode(tty : Tty, mode : enum TtyMode {
Normal
Raw
Io
RawVT
}
TtyMode) -> Int = "moonbit_uv_tty_set_mode"
62
63///|
64pub fn Tty::(self : Tty, mode : TtyMode) -> Unit!Errno
set_mode(self : Tty, mode : enum TtyMode {
Normal
Raw
Io
RawVT
}
TtyMode) -> Unit!Errno {
65 let result = (tty : Tty, mode : TtyMode) -> Int
uv_tty_set_mode(self, mode)
66 if result (self_ : Int, other : Int) -> Bool
< 0 {
67 raise Errno::of_int(result)
68 }
69}
70
71///|
72extern "c" fn uv_tty_reset_mode() -> Int = "moonbit_uv_tty_reset_mode"
73
74///|
75pub fn Tty::reset_mode() -> Unit!Errno {
76 let result = uv_tty_reset_mode()
77 if result (self_ : Int, other : Int) -> Bool
< 0 {
78 raise Errno::of_int(result)
79 }
80}
81