Ghostty.TTY (Ghostty v0.4.7)

Copy Markdown View Source

Current-terminal adapter for local terminal applications.

Ghostty.Terminal emulates a terminal and Ghostty.PTY manages child pseudo-terminals. Ghostty.TTY is the complementary adapter for the terminal running the current BEAM process: it starts raw input, decodes keyboard bytes into Ghostty.KeyEvent, writes output, and reports resize events.

Events are sent to the owner process passed in :owner (defaults to the process that calls start_link/1):

{Ghostty.TTY, tty, {:key, %Ghostty.KeyEvent{}}}
{Ghostty.TTY, tty, {:data, binary}}
{Ghostty.TTY, tty, {:resize, cols, rows}}
{Ghostty.TTY, tty, :eof}

This module owns terminal mode setup and restore so applications do not need local raw-terminal adapters.

Summary

Functions

Returns a child spec for supervision trees.

Types

backend()

@type backend() :: :auto | :otp_raw | :nif

event()

@type event() ::
  {:key, Ghostty.KeyEvent.t()}
  | {:data, binary()}
  | {:resize, pos_integer(), pos_integer()}
  | :eof

option()

@type option() ::
  {:owner, pid()}
  | {:name, GenServer.name()}
  | {:raw, boolean()}
  | {:backend, backend()}
  | {:takeover, boolean()}
  | {:disable_otp_reader, boolean()}

Functions

child_spec(init_arg)

Returns a child spec for supervision trees.

size()

@spec size() :: {pos_integer(), pos_integer()}

start_link(opts \\ [])

@spec start_link([option()]) :: GenServer.on_start()

write(tty, data)

@spec write(GenServer.server(), iodata()) :: :ok