Skip to content

feat: Add libghostty terminal backend (GPU-accelerated via Metal)#4

Open
ahmadyan wants to merge 1 commit intomainfrom
ahmadyan/ghostty-terminal
Open

feat: Add libghostty terminal backend (GPU-accelerated via Metal)#4
ahmadyan wants to merge 1 commit intomainfrom
ahmadyan/ghostty-terminal

Conversation

@ahmadyan
Copy link
Owner

Summary

Adds an experimental GPU-accelerated terminal backend using libghostty as an alternative to SwiftTerm.

  • GPU-accelerated rendering via Metal for smooth, high-performance terminal output
  • Full keyboard/mouse support including IME (Input Method Editor) for international input
  • Settings integration with persistent "Use Ghostty Backend" toggle
  • Clipboard support for copy/paste operations
  • Terminal title/PWD tracking for tab titles

New Files

Path Description
CodeEdit/Features/TerminalEmulator/Ghostty/ Core libghostty wrapper implementations
CodeEdit/Frameworks/GhosttyKit.xcframework/ Framework headers and metadata
scripts/setup-ghostty.sh Build script for libghostty

Setup Required

The static library (~130MB) is not included in the repo due to GitHub size limits. To test:

# Build the GhosttyKit library
./scripts/setup-ghostty.sh

# Or copy from existing Ghostty build
cp /path/to/ghostty/macos/GhosttyKit.xcframework/macos-arm64/libghostty-fat.a \
   CodeEdit/Frameworks/GhosttyKit.xcframework/macos-arm64/

Usage

  1. Run the setup script to get libghostty-fat.a
  2. Build CodeEdit
  3. Go to Settings → Terminal → Experimental
  4. Enable "Use Ghostty Backend"
  5. Restart CodeEdit

Test plan

  • Build libghostty using setup script
  • Build CodeEdit successfully
  • Enable Ghostty backend in settings
  • Verify setting persists after restart
  • Test basic terminal operations (typing, running commands)
  • Test keyboard shortcuts and special keys
  • Test mouse scrolling and selection
  • Test copy/paste operations

🤖 Generated with Claude Code

Adds an experimental Ghostty terminal backend as an alternative to SwiftTerm.
Ghostty uses libghostty for GPU-accelerated Metal rendering.

Features:
- GPU-accelerated terminal rendering via Metal
- Full keyboard/mouse input support
- IME (Input Method Editor) support
- Clipboard integration
- Title and PWD change notifications

Implementation:
- GhosttyApp: Singleton managing the libghostty app instance
- GhosttySurface: Wrapper for individual terminal sessions
- GhosttySurfaceView: NSView subclass handling rendering/input
- GhosttyTerminalView: SwiftUI wrapper for integration
- GhosttyInput: Key/mouse event translation
- GhosttyConfig: Configuration management

Setup:
The GhosttyKit static library (~130MB) is not included due to size.
Run `./scripts/setup-ghostty.sh` to build it, or see
CodeEdit/Frameworks/GhosttyKit.xcframework/README.md

Usage:
1. Run setup script to get libghostty
2. Build CodeEdit
3. Settings → Terminal → Experimental → Enable "Use Ghostty Backend"
4. Restart CodeEdit

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant