Ghostty.TTY (Ghostty v0.4.1)

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 uses OTP terminal facilities rather than shelling out to stty.

Summary

Functions

Returns a child spec for supervision trees.

Types

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()}

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