unix::tty
Index
Types
type ttysize = struct {
rows: u16,
columns: u16,
};
type termios = struct {
file: io::file,
saved: rt::termios,
current: rt::termios,
};
Errors
type error = !(errors::invalid | errors::unsupported | errors::noentry);
Functions
fn isatty(fd: io::file) bool;
fn makeraw(termios: *termios) (void | errors::error);
fn noecho(termios: *termios) (void | errors::error);
fn noncanonical(termios: *termios) (void | errors::error);
fn open() (io::file | error);
fn openpty() ((io::file, io::file) | fs::error);
fn ptsname(master: io::file) (str | error);
fn set_winsize(pty: io::file, sz: ttysize) (void | error);
fn strerror(err: error) str;
fn tcsetpgrp(fd: io::file, pg: exec::process) (void | errors::error);
fn termios_query(file: io::file) (termios | errors::error);
fn termios_restore(termios: *const termios) void;
fn termios_set(termios: *const termios) (void | errors::error);
fn winsize(fd: io::file) (ttysize | error);
Types
type ttysize
type ttysize = struct {
rows: u16,
columns: u16,
};
Structure representing dimensions of a terminal.
type termios
Show undocumented member
type termios = struct {
file: io::file,
saved: rt::termios,
current: rt::termios,
};
Errors
type error
type error = !(errors::invalid | errors::unsupported | errors::noentry);
Any error that may occur during TTY-related tasks.
Functions
fn isatty
fn isatty(fd: io::file) bool;
Returns whether the given stream is connected to a terminal.
fn makeraw
fn makeraw(termios: *termios) (void | errors::error);
Enables "raw" mode for this terminal, disabling echoing, line editing, and signal handling. Users should call termios_query prior to this to save the previous terminal settings, and termios_restore to restore them before exiting.
fn noecho
fn noecho(termios: *termios) (void | errors::error);
Disables "echo" on this terminal. Users should call termios_restore to restore settings.
fn noncanonical
fn noncanonical(termios: *termios) (void | errors::error);
Enables "noncanonical" mode for this terminal, disabling line buffering and line editing. Users should call termios_restore to restore settings.
fn open
fn open() (io::file | error);
Returns a stream connected to the TTY of the current process. The caller must close it using io::close.
fn openpty
fn openpty() ((io::file, io::file) | fs::error);
Opens an available pseudoterminal and returns the file descriptors of the master and slave.
fn ptsname
fn ptsname(master: io::file) (str | error);
Returns the filename of the pseudoterminal slave.
fn set_winsize
fn set_winsize(pty: io::file, sz: ttysize) (void | error);
Sets the dimensions of the underlying pseudoterminal for an io::file.
fn strerror
fn strerror(err: error) str;
Converts an error to a human-friendly string.
fn tcsetpgrp
fn tcsetpgrp(fd: io::file, pg: exec::process) (void | errors::error);
Sets the process group on the foreground of this terminal.
fn termios_query
fn termios_query(file: io::file) (termios | errors::error);
Retrieves serial port settings of the given terminal.
fn termios_restore
fn termios_restore(termios: *const termios) void;
Restores original serial port settings.
fn termios_set
fn termios_set(termios: *const termios) (void | errors::error);
Sets serial port settings.
fn winsize
fn winsize(fd: io::file) (ttysize | error);
Returns the dimensions of underlying terminal for an io::file.