module Tty:sig
..end
TTY handles represent a stream for the console.
type
t
include Uwt.Stream
include Uwt.Handle_fileno
val to_stream : t -> Uwt.Stream.t
val init : file -> read:bool -> t uv_result
Initialize a new TTY stream with the given file
descriptor. Usually the file descriptor will be:
stdin
,stdout
or stderr
~read
specifies if you plan on
calling read_start
with this stream. stdin
is readable,
stdout
is not.
On Unix this function will determine the path of the fd of the terminal using ttyname_r(3), open it, and use it if the passed file descriptor refers to a TTY. This lets libuv put the tty in non-blocking mode without affecting other processes that share the tty.
This function is not thread safe on systems that don't support ioctl TIOCGPTN or TIOCPTYGNAME, for instance OpenBSD and Solaris.
Note: If reopening the TTY fails, libuv falls back to blocking writes for non-readable TTY streams.
val init_exn : file -> read:bool -> t
type
mode =
| |
Normal |
| |
Raw |
| |
Io |
val set_mode : t -> mode:mode -> Int_result.unit
Set the TTY using the specified terminal mode
val set_mode_exn : t -> mode:mode -> unit
val reset_mode : unit -> Int_result.unit
To be called when the program exits. Resets TTY settings to default values for the next process to take over.
This function is async signal-safe on Unix platforms but can fail with error code UV_EBUSY if you call it when execution is inside uv_tty_set_mode().
val reset_mode_exn : unit -> unit
type
winsize = {
|
width : |
|
height : |
val get_winsize : t -> winsize uv_result
Gets the current Window size.
val get_winsize_exn : t -> winsize