How ghostty-org/ghostty works
Ghostty is a native terminal emulator and an embeddable terminal library. In the macOS app, users launch or open a terminal; app actions create terminal windows and tabs, while controllers manage surfaces, splits, and rendering. The separate libghostty-vt API exposes terminal parsing and state for embedding. The graph includes documented native features such as Quick Terminal and automation, even where implementation details were not sampled; those links are marked unverified. Relationships reflect shown calls or source-index references, not an assumed end-to-end pipeline.
Main entry points: TerminalController.swift Window and Tabs · BaseTerminalController.swift Terminal Controller Base · AppDelegate.swift App Lifecycle · QuickTerminalController.swift Quick Terminal
Components 19
macOS App
- App Lifecycle
macos/Sources/App/AppDelegate.swift
Terminal Workspace
- Window and Tabs
macos/Sources/Features/Terminal/TerminalController.swift - Terminal Controller Base
macos/Sources/Features/Terminal/BaseTerminalController.swift - Split Layout
macos/Sources/Features/Splits/SplitTree.swift - Terminal View
macos/Sources/Features/Terminal/TerminalView.swift - View Container
macos/Sources/Features/Terminal/TerminalViewContainer.swift - Terminal Surface
macos/Sources/Ghostty/Surface View/SurfaceView.swift - Window Styling
macos/Sources/Features/Terminal/Window Styles/TerminalWindow.swift
Native Features
- Quick Terminal
macos/Sources/Features/QuickTerminal/QuickTerminalController.swift - Quick Positioning
macos/Sources/Features/QuickTerminal/QuickTerminalPosition.swift - Screen State Cache
macos/Sources/Features/QuickTerminal/QuickTerminalScreenStateCache.swift - Secure Input
macos/Sources/Features/Secure Input/SecureInput.swift - Update UI State
macos/Sources/Features/Update/UpdateViewModel.swift - AppleScript and Shortcuts
macos/Sources/Features/AppleScript
Embeddable Library
- libghostty API
include/ghostty.h - VT Terminal API
include/ghostty/vt/terminal.h - Terminal Search
include/ghostty/vt/search.h
Other components
- User
- Embedding Application
Connections 21
- User → App Lifecycle: launches
- App Lifecycle → Window and Tabs: creates window
macos/Sources/App/AppDelegate.swift - Window and Tabs → Terminal Controller Base: inherits from
macos/Sources/Features/Terminal/TerminalController.swift - Terminal Controller Base → Terminal Surface: creates surface
macos/Sources/Features/Terminal/BaseTerminalController.swift - Terminal Controller Base → Split Layout: updates layout
macos/Sources/Features/Terminal/BaseTerminalController.swift - Window and Tabs → Split Layout: uses layout
macos/Sources/Features/Terminal/TerminalController.swift - Window and Tabs → Terminal View: uses view
macos/Sources/Features/Terminal/TerminalController.swift - Window and Tabs → View Container: uses container
macos/Sources/Features/Terminal/TerminalController.swift - Window and Tabs → Window Styling: uses window
macos/Sources/Features/Terminal/TerminalController.swift - Terminal View → Terminal Surface: displays surface
macos/Sources/Features/Terminal/TerminalView.swift - View Container → Terminal Controller Base: uses controller
macos/Sources/Features/Terminal/TerminalViewContainer.swift - App Lifecycle → Quick Terminal: manages feature
macos/Sources/App/AppDelegate.swift - Quick Terminal → Quick Positioning: uses positioning
macos/Sources/Features/QuickTerminal/QuickTerminalController.swift - Quick Terminal → Screen State Cache: saves screen state
macos/Sources/Features/QuickTerminal/QuickTerminalController.swift - Quick Terminal → Terminal Controller Base: inherits from
macos/Sources/Features/QuickTerminal/QuickTerminalController.swift - Terminal Surface → Secure Input: uses secure input
macos/Sources/Ghostty/Surface View/SurfaceView.swift - App Lifecycle → Update UI State: configures updates
macos/Sources/App/AppDelegate.swift - User → AppleScript and Shortcuts: invokes commands
- Embedding Application → libghostty API: embeds library
- libghostty API → VT Terminal API: exposes VT API
- Embedding Application → Terminal Search: uses search API
include/ghostty/vt/search.h