# TtyTerminalBinding

`import { TtyTerminalBinding } from "destack:tty/binding";`

Terminal binding family.

```ds title="TtyTerminalBinding"
export interface TtyTerminalBinding {
    openStandardInputTty(): Result<TtyHandle, HostError>;
    openStandardOutputTty(): Result<TtyHandle, HostError>;
    openStandardErrorTty(): Result<TtyHandle, HostError>;
    closeTty(tty: TtyHandle): Result<void, HostError>;
    isTerminalFile(handle: FileHandle): Result<boolean, HostError>;
    readTty(tty: TtyHandle, buffer: &'a [uint8]): Result<uint64, HostError>;
    writeTty(tty: TtyHandle, buffer: &'a readonly [uint8]): Result<uint64, HostError>;
    readTtyMode(tty: TtyHandle): Result<TtyMode, HostError>;
    setTtyMode(tty: TtyHandle, mode: &'a readonly TtyMode): Result<void, HostError>;
    setRawTtyMode(tty: TtyHandle, enabled: boolean): Result<void, HostError>;
    readTtySize(tty: TtyHandle): Result<TtySize, HostError>;
    setTtySize(tty: TtyHandle, size: &'a readonly TtySize): Result<void, HostError>;
}
```

[language/library/src/tty/binding/terminal.ds:33:141](https://github.com/destack-sh/destack/blob/main/language/library/src/tty/binding/terminal.ds#L33-L141)

## Members

### `openStandardInputTty(): Result<TtyHandle, HostError>`

Open one standard input terminal handle.

### `openStandardOutputTty(): Result<TtyHandle, HostError>`

Open one standard output terminal handle.

### `openStandardErrorTty(): Result<TtyHandle, HostError>`

Open one standard error terminal handle.

### `closeTty(tty: TtyHandle): Result<void, HostError>`

Close one terminal handle.

### `isTerminalFile(handle: FileHandle): Result<boolean, HostError>`

Return whether one file handle is attached to a terminal.

### `readTty(tty: TtyHandle, buffer: &'a [uint8]): Result<uint64, HostError>`

Read bytes from a terminal.

### `writeTty(tty: TtyHandle, buffer: &'a readonly [uint8]): Result<uint64, HostError>`

Write bytes to a terminal.

### `readTtyMode(tty: TtyHandle): Result<TtyMode, HostError>`

Read terminal mode flags.

### `setTtyMode(tty: TtyHandle, mode: &'a readonly TtyMode): Result<void, HostError>`

Apply terminal mode flags.

### `setRawTtyMode(tty: TtyHandle, enabled: boolean): Result<void, HostError>`

Enable or disable raw terminal mode.

### `readTtySize(tty: TtyHandle): Result<TtySize, HostError>`

Read terminal size.

### `setTtySize(tty: TtyHandle, size: &'a readonly TtySize): Result<void, HostError>`

Apply terminal size.
