PrivatecontainerPrivatecurrentPrivate OptionaldataPrivatefitPrivateghosttyPrivateinitializedPrivatemobilePrivateoptionsPrivate OptionalresizePrivateresizePrivateterminalThe number of columns (characters per line) in the terminal.
The current column count, or 80 if not initialized
The number of rows (lines) in the terminal.
The current row count, or 24 if not initialized
PrivatecopyInternalCopies text to clipboard using synchronous methods that work in Safari.
The text to copy to clipboard
PrivatecreateInternalCreates or recreates the terminal instance.
Fits the terminal to its container dimensions.
This method should be called when the container size changes. It's automatically called on window resize, but you may need to call it manually after dynamic layout changes.
PrivatehandleInternalHandles window resize events.
Initializes the Ghostty terminal and mounts it to the container.
This method:
The HTML element to mount the terminal into
Configuration options for the terminal
A promise that resolves when initialization is complete
PrivateisInternalChecks if the current device supports touch input.
Registers a callback to receive user input data.
The callback is invoked whenever the user types in the terminal. This includes regular characters, control sequences, and escape codes.
The callback function to handle input data
Sets the terminal color theme.
Since Ghostty-web doesn't fully support runtime theme changes, this method recreates the terminal with the new theme.
The theme to apply
PrivatesetupInternalSets up mobile-specific functionality: touch scrolling and keyboard input.
PrivatesetupInternalCreates a hidden textarea for mobile keyboard input. Appended to document.body to avoid interfering with terminal touch events.
PrivatesetupInternalSets up a workaround for Safari's clipboard restrictions.
Safari requires clipboard operations to happen synchronously within a user gesture. The async Clipboard API loses the gesture context after an await, causing copy to fail. This workaround intercepts Cmd+C and uses the synchronous execCommand method.
PrivatesetupInternalSets up touch-based scrolling for the terminal. Translates touch gestures into scroll commands.
PrivatethemeInternalConverts a Theme object to Ghostty's theme format.
The theme to convert
The theme in Ghostty's expected format
An adapter that wraps the Ghostty terminal emulator for web use.
This class provides a simplified interface for:
The adapter handles all the low-level details of working with the Ghostty terminal emulator, including WASM initialization, addon loading, and event handling.
Example: Basic usage
Example: Theme switching