unix::tty+x86_64 +linux
tty: basic tty and termios support
unix::tty provides an interface for interacting with and manipulating a terminal environment, based on the termios interface defined by POSIX.
https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/termios.h.html
Index
Types
type ttysize; // Undocumented types: type termios;
Errors
type error;
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 tcgetpgrp(fd: io::file) (unix::pid | errors::error); fn tcsetpgrp(fd: io::file, pg: unix::pid) (void | errors::error); fn termios_query(file: io::file) (termios | errors::error); fn termios_restore(termios: *termios) void; fn termios_set(termios: *termios) (void | errors::error); fn winsize(fd: io::file) (ttysize | error);
Types
type ttysize[permalink] [source]
type ttysize = struct { rows: u16, columns: u16, };
Structure representing dimensions of a terminal.
type termios[permalink] [source]
Show undocumented member
type termios = struct { file: io::file, saved: sys::termios, current: sys::termios, };
Errors
type error[permalink] [source]
type error = !(errors::invalid | errors::unsupported | errors::noentry);
Any error that may occur during TTY-related tasks.
Functions
fn isatty[permalink] [source]
fn isatty(fd: io::file) bool;
Returns whether the given stream is connected to a terminal.
fn makeraw[permalink] [source]
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[permalink] [source]
fn noecho(termios: *termios) (void | errors::error);
Disables "echo" on this terminal. Users should call termios_restore to restore settings.
fn noncanonical[permalink] [source]
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[permalink] [source]
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[permalink] [source]
fn openpty() ((io::file, io::file) | fs::error);
Opens an available pseudoterminal and returns the file descriptors of the master and slave.
fn ptsname[permalink] [source]
fn ptsname(master: io::file) (str | error);
Returns the filename of the pseudoterminal slave. The return value is statically allocated and will be overwritten on subsequent calls to this function.
fn set_winsize[permalink] [source]
fn set_winsize(pty: io::file, sz: ttysize) (void | error);
Sets the dimensions of the underlying pseudoterminal for an io::file.
fn strerror[permalink] [source]
fn strerror(err: error) str;
Converts an error to a human-friendly string.
fn tcgetpgrp[permalink] [source]
fn tcgetpgrp(fd: io::file) (unix::pid | errors::error);
Gets the process group on the foreground of this terminal.
fn tcsetpgrp[permalink] [source]
fn tcsetpgrp(fd: io::file, pg: unix::pid) (void | errors::error);
Sets the process group on the foreground of this terminal.
fn termios_query[permalink] [source]
fn termios_query(file: io::file) (termios | errors::error);
Retrieves serial port settings of the given terminal.
fn termios_restore[permalink] [source]
fn termios_restore(termios: *termios) void;
Restores original serial port settings.
fn termios_set[permalink] [source]
fn termios_set(termios: *termios) (void | errors::error);
Sets serial port settings.
fn winsize[permalink] [source]
fn winsize(fd: io::file) (ttysize | error);
Returns the dimensions of underlying terminal for an io::file.