unix::tty +linux +x86_64

Index

Types

type ttysize;

// Undocumented types:
type termios;

Errors

type error;

Functions

fn isatty(io::file) bool;
fn makeraw(*termios) (void | errors::error);
fn noecho(*termios) (void | errors::error);
fn open() (io::file | error);
fn openpty() ((io::file, io::file) | fs::error);
fn ptsname(io::file) (str | error);
fn set_winsize(io::file, ttysize) (void | error);
fn strerror(error) str;
fn termios_query(io::file) (termios | errors::error);
fn termios_restore(*const termios) void;
fn termios_set(*const termios) (void | errors::error);
fn winsize(io::file) (ttysize | error);

Types

type ttysize[link]

type ttysize = struct {
	rows: u16,
	columns: u16,
};

Structure representing dimensions of a terminal.

type termios[link]

Show undocumented member
type termios = struct {
	file: io::file,
	saved: rt::termios,
	current: rt::termios,
};

Errors

type error[link]

type error = !(errors::invalid | errors::unsupported | errors::noentry);

Any error that may occur during TTY-related tasks.

Functions

fn isatty[link]

fn isatty(fd: io::file) bool;

Returns whether the given stream is connected to a terminal.

fn makeraw[link]

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[link]

fn noecho(termios: *termios) (void | errors::error);

Disables "echo" on this terminal. Users should call termios_restore to restore settings.

fn open[link]

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[link]

fn openpty() ((io::file, io::file) | fs::error);

Opens an available pseudoterminal and returns the file descriptors of the master and slave.

fn ptsname[link]

fn ptsname(master: io::file) (str | error);

Returns the filename of the pseudoterminal slave.

fn set_winsize[link]

fn set_winsize(pty: io::file, sz: ttysize) (void | error);

Sets the dimensions of the underlying pseudoterminal for an io::file.

fn strerror[link]

fn strerror(err: error) str;

Converts an error to a human-friendly string.

fn termios_query[link]

fn termios_query(file: io::file) (termios | errors::error);

Retrieves serial port settings of the given terminal.

fn termios_restore[link]

fn termios_restore(termios: *const termios) void;

Restores original serial port settings.

fn termios_set[link]

fn termios_set(termios: *const termios) (void | errors::error);

Sets serial port settings.

fn winsize[link]

fn winsize(fd: io::file) (ttysize | error);

Returns the dimensions of underlying terminal for an io::file.