Retrieves the current state of the TTY.
tty_get() function is used to retrieve the current state of the terminal (TTY). It provides information such as the number of columns, number of rows, width, height, and TTY configuration.
This function is typically used in interactive applications that need to obtain information about the terminal to perform certain operations or adjust their behavior based on the terminal settings.
;;; Retrieves the current state of the TTY (@interface func (export "tty_get") (param $state (@witx pointer $tty)) (result $error (expected (error $errno))) )
ctx: The function environment.
tty_state: A pointer to a
Ttystructure where the TTY state will be stored.
The function returns an
Errno value indicating the result of the operation. If the operation is successful and the TTY state is retrieved, it returns
Errno::Success. If the TTY is not supported, it returns
tty_get()function retrieves the current state of the TTY.
- It checks if the TTY is available in the runtime. If it is not available, indicating that the program is not running in an interactive terminal, it returns
- If the TTY is available, it calls the
tty_get()method on the TTY bridge to obtain the current TTY state.
- The TTY state is then stored in a
Ttystructure with fields such as
- The function writes the
Ttystructure to the memory specified by the
- If the operation is successful, it returns