Commit Graph

13790 Commits

Author SHA1 Message Date
Mitchell Hashimoto
435cb951f0 config: add more details to the key-remap feature (#10223)
cc @jcollie
2026-01-08 10:47:28 -08:00
Mitchell Hashimoto
a6d36b5e6d config: add more details to the key-remap feature 2026-01-08 10:45:45 -08:00
Mitchell Hashimoto
89e9562615 feat: key-remap configuration to remap modifiers at the app-level (#10064)
This PR introduces a new `key-remap` configuration option that allows
users to remap modifier keys at the application level without affecting
system-wide settings.

## Issue
Closes #5160

## Usage

```ini
# Make Ctrl act as Cmd within Ghostty
key-remap = ctrl=super

# Swap Ctrl and Cmd
key-remap = ctrl=super
key-remap = super=ctrl

# Remap only left Alt to Ctrl
key-remap = left_alt=ctrl
```

### Supported Modifiers

| Generic | Left-sided | Right-sided |
|---------|------------|-------------|
| `ctrl` / `control` | `left_ctrl` | `right_ctrl` |
| `alt` / `opt` / `option` | `left_alt` | `right_alt` |
| `shift` | `left_shift` | `right_shift` |
| `super` / `cmd` / `command` | `left_super` | `right_super` |

## Behavior

Per the issue specification:

- **One-way remapping**: `ctrl=super` means Ctrl becomes Super, but
Super remains Super
- **Non-transitive**: `ctrl=super` + `alt=ctrl` → Alt becomes Ctrl (NOT
Super)
- **Sided support**: Generic modifiers match both sides; use `left_*` or
`right_*` for specific sides
- **Immediate effect**: Changes apply on config reload

## Limitations

- Implemented in Zig core, works on both macOS and Linux
- Only modifier keys can be remapped (not regular keys)
2026-01-08 10:32:15 -08:00
Mitchell Hashimoto
21d9d89d32 input: RemapSet should support aliased mods 2026-01-08 10:26:46 -08:00
Mitchell Hashimoto
5b24aebcab update to use new RemapSet 2026-01-08 10:22:56 -08:00
Mitchell Hashimoto
f804a4344e input: RemapSet 2026-01-08 10:22:56 -08:00
Mitchell Hashimoto
619427c84c input: move mods out to key_mods.zig 2026-01-08 10:22:56 -08:00
Mitchell Hashimoto
8415d8215b comments 2026-01-08 10:22:56 -08:00
Jagjeevan Kashid
111b0996d2 feat: key-remap configuration to remap modifiers at the app-level
Signed-off-by: Jagjeevan Kashid <jagjeevandev97@gmail.com>
2026-01-08 10:22:56 -08:00
Mitchell Hashimoto
891f442041 macos: custom tab title shows bell if active (#10211)
Fixes #10210
2026-01-07 13:37:32 -08:00
Mitchell Hashimoto
5a7fdf735e macos: custom tab title shows bell if active
Fixes #10210
2026-01-07 13:32:58 -08:00
Mitchell Hashimoto
e9ea94d364 fix(formatter): preserve background colors on cells without text (#10134)
The VT formatter was treating cells without text as blank and emitting
them as plain spaces, losing any background color styling. This caused
TUIs like htop to lose their background colors when rehydrating terminal
state (e.g., after detach/reattach in zmx).

For styled formats (VT/HTML), cells with background colors or `style_id`
are now emitted with proper SGR sequences and a space character instead
of being accumulated as unstyled blanks.

Adds handling for `bg_color_palette` and `bg_color_rgb` content tags
which
were previously unreachable.

I used amp to construct the test case and the code to make the test
pass. Please see the amp thread.

I tested my branch against the test cases where it was previously broken
(nvtop, htop, senpai).

Reference:
https://ampcode.com/threads/T-019b7a35-c3f3-73fc-adfa-00bbe9dbda3c

## VT

### BEFORE

<img width="2256" height="552" alt="screenshot_1767373196"
src="https://github.com/user-attachments/assets/32654801-35cb-4d94-8ebd-501cfe74b6b6"
/>

### AFTER

<img width="2256" height="632" alt="screenshot_1767373113"
src="https://github.com/user-attachments/assets/f011260b-20ca-40a7-95b4-965c29b2eba3"
/>

## HTML

### BEFORE

<img width="1118" height="749" alt="screenshot_1767373647"
src="https://github.com/user-attachments/assets/e4152640-8f1e-48f7-893c-d437d48629ef"
/>

### AFTER

<img width="1130" height="775" alt="screenshot_1767373657"
src="https://github.com/user-attachments/assets/288423c8-d034-4dea-b976-506a7b95cc3c"
/>
2026-01-07 13:17:26 -08:00
Mitchell Hashimoto
7bfcaef1e8 terminal: formatting feedback 2026-01-07 13:12:37 -08:00
Mitchell Hashimoto
9bddca81dc shell-integration: better shell detection and setup (#10044)
Command-based shell detection has been extracted to its own function
(detectShell), which is nicer for testing. It now uses argIterator to
determine the command's executable, rather than the previous string
operations, which allows us to handle command strings containing quotes
and spaces.

Also, our shell-specific setup functions now use a consistent signature,
which simplifies the calling code quite a bit.
2026-01-07 10:30:45 -08:00
Jon Parise
795de7938d shell-integration: better shell detection and setup
Command-based shell detection has been extracted to its own function
(detectShell), which is nicer for testing. It now uses argIterator to
determine the command's executable, rather than the previous string
operations, which allows us to handle command strings containing quotes
and spaces.

Also, our shell-specific setup functions now use a consistent signature,
which simplifies the calling code quite a bit.
2026-01-07 10:25:17 -08:00
Mitchell Hashimoto
7c4ae08924 feat: select entire URL on double-click (#10132)
## Why

When double-clicking on a URL like `https://example.com`, only `https`
or `//example.com` gets selected because `:` and `/` are word
boundaries. Users expect the entire URL to be selected.

## How

Added URL detection to the double-click handler in `Surface.zig`:

1. Before falling back to `selectWord`, try to detect if the clicked
position is part of a URL
2. Uses the pre-compiled link regexes from user configuration (same
patterns used for cmd+click)
3. If a URL is found at the position, select the entire URL
4. Otherwise, fall back to normal word selection

The implementation:
- Respects user's link configuration (disabled URLs won't trigger
selection)
- Reuses pre-compiled regexes from `DerivedConfig.links` (no per-click
compilation)
- Follows the same patterns as `linkAtPos`

## What

- `src/Surface.zig`: Added `urlAtPin()` helper function and modified
double-click handler
- `src/terminal/StringMap.zig`: Added 2 tests for URL detection
following existing test patterns
2026-01-07 10:18:12 -08:00
Mitchell Hashimoto
6659315760 tweaks to link detection 2026-01-07 10:03:15 -08:00
teamchong
5a042570c8 feat: select entire URL on double-click
When double-clicking text, first check if the position is part of a URL
using the default URL regex pattern. If a URL is detected, select the
entire URL instead of just the word.

This follows the feedback from PR #2324 to modify the selection behavior
rather than introducing a separate selectLink function. The implementation
uses the existing URL regex from config/url.zig which already handles
various URL schemes (http, https, ftp, ssh, etc.) and file paths.

The URL detection runs before the normal word selection, falling back to
selectWord if no URL is found at the clicked position.
2026-01-07 10:03:15 -08:00
Mitchell Hashimoto
323d362bc1 macos: dragging last window out of quick terminal works 2026-01-07 09:33:37 -08:00
Lukas
a265462aa6 macOS: moving a focused split to another tab should also update the previous tab 2026-01-07 09:18:41 -08:00
Lukas
02fc0f502f macOS: rename function to avoid mutating misunderstanding 2026-01-07 09:18:17 -08:00
Mitchell Hashimoto
ba1952c8c2 build: add -fPIC for musl targets (#10198)
Adds `-fPIC` flag for musl targets when building highway and simdutf C++
dependencies, matching the existing freebsd behavior.

## What is PIC?

Position Independent Code (PIC) generates machine code using relative
addresses instead of absolute ones, allowing the code to be loaded at
any memory address. This is required when linking static libraries into
shared libraries (.so files).

## Why both freebsd and musl need it

Both freebsd and musl use strict relocation policies that reject non-PIC
code in shared libraries. Without `-fPIC`, linking fails with errors
like:

```
relocation R_X86_64_PC32 cannot be used against symbol '__cxa_begin_catch'
```

glibc is more permissive and handles these relocations at runtime, which
is why linux-gnu targets work without this flag.

## Context

This enables cross-compiling ghostty-vt to musl/Alpine Linux targets.
Discovered while integrating ghostty-vt into opentui:
https://github.com/sst/opentui/pull/440

---

This PR was created with help from Claude Opus 4.5.
2026-01-07 07:03:00 -08:00
Tommy D. Rossi
61394d5213 build: add -fPIC for musl targets in C++ dependencies 2026-01-07 06:55:40 -08:00
Leah Amelia Chen
c559a1dbba Allow for default or inherited CWD in new window, tab and split surfaces (redone for GTK-NG) (#9158) 2026-01-07 20:45:06 +08:00
Mitchell Hashimoto
a4368064a3 macOS: add Cmd+J "Jump to Selection" menu item and default binding (#10197)
This matches other built-in macOS apps like Terminal, Notes, Safari. We
already had the binding, just needed to create the menu.
2026-01-06 14:40:01 -08:00
Mitchell Hashimoto
7d0157e69a macOS: add Cmd+J "Jump to Selection" menu item and default binding
This matches other built-in macOS apps like Terminal, Notes, Safari. We
already had the binding, just needed to create the menu.

https://ampcode.com/threads/T-019b956a-f4e6-71b4-87fa-4162258d33ff
2026-01-06 14:30:11 -08:00
Mitchell Hashimoto
09c7240fb2 macOS: Selection for Find feature (#10192)
Adds the `selection_for_search` action, with Cmd+E keybind by default.
This action inputs the currently selected text into the search field
without changing focus, matching standard macOS behavior.

Implements discussion #9776 and #10036

<details><summary>AI Disclosure</summary>
<p>

Tab completions with Codestral.
Reviewed by Gemini 3 Flash via chatting.
No Agentic coding tools were involved.

</p>
</details>
2026-01-06 14:26:03 -08:00
Mitchell Hashimoto
3ba4f17f0d zig fmt 2026-01-06 14:21:42 -08:00
Mitchell Hashimoto
05a41c7772 macos: clean up menu 2026-01-06 14:20:34 -08:00
Mitchell Hashimoto
f07d600e43 macos: start_search with needle changes needle 2026-01-06 14:14:22 -08:00
Mitchell Hashimoto
8e28f58b42 rename the selection search binding, unify into start_search action 2026-01-06 14:10:42 -08:00
Mitchell Hashimoto
45abfa9190 font: add bitmap font tests for BDF, PCF, and OTB formats (#10193)
Adds test coverage for bitmap font rendering in the FreeType backend
using the Spleen 8x16 font in three formats:

- BDF (Bitmap Distribution Format)
- PCF (Portable Compiled Format)
- OTB (OpenType Bitmap)

Tests validate glyph dimensions and pixel-perfect rendering against
expected patterns, following the model established by the existing
TerminusTTF test.

Spleen was chosen because it ships in all three required formats from a
single source, providing consistent test data across formats. Its BSD
2-Clause license is compatible with the existing font licenses in the
repo (OFL, MIT). No existing embedded fonts could be used since they are
all TTF/OTF files that use the TrueType loader rather than the
BDF/PCF/OTB loaders being tested.

Addresses #8524.

---

This PR was written with assistance from Claude Code.
2026-01-06 09:26:27 -08:00
Britt Binler
896615c004 font: add bitmap font tests for BDF, PCF, and OTB formats
Add test coverage for bitmap font rendering using the Spleen 8x16 font
in three formats: BDF (Bitmap Distribution Format), PCF (Portable
Compiled Format), and OTB (OpenType Bitmap). Tests validate glyph
rendering against expected pixel patterns.

Addresses #8524.
2026-01-06 09:14:33 -08:00
Mitchell Hashimoto
6da5f72c45 Lower unimplemented OSC from warning to debug (#10184)
The "unimplemented OSC command" warning is a frequent source of red
herrings as there are many OSCs that we parse but deliberately do not
implement. It's also a small drag on performance due to the function
call overhead and the overhead of formatting and outputting the message.
This PR lowers the message from warning to debug. Debug logs are
compiled out of release builds so there should be less confusion from
general users who will no longer see the message.
2026-01-06 08:52:54 -08:00
Aaron Ruan
9b6a3be993 macOS: Selection for Find feature
Adds the `selection_for_search` action, with Cmd+E keybind by default.
This action inputs the currently selected text into the search
field without changing focus, matching standard macOS behavior.
2026-01-06 22:21:55 +08:00
Kat
b4a44bc47e i18n: Add missing German translation (#10164) 2026-01-06 13:01:39 +00:00
Jan Klass
1c7ba3dbe0 Update rev date and last translator 2026-01-06 10:26:40 +01:00
Peter Guy
93f33bc0d6 clarify config documentation around previously focused windows/tabs/splits 2026-01-05 16:47:04 -08:00
Peter Guy
55285fee28 preserve multi-line formatting 2026-01-05 16:47:04 -08:00
Peter Guy
b119bc6089 consolidated enums 2026-01-05 16:47:04 -08:00
Peter Guy
d660799723 Consolidate the several ghostty_surface_inherited_config
functions back into a single function with a second parameter for the source context.
2026-01-05 16:47:04 -08:00
Peter Guy
c035fb5385 Add an enum type for the C API 2026-01-05 16:47:04 -08:00
Peter Guy
0af2a3f693 Enable distinguishing between a new tab in a new window
(which should inherit based on the window setting),
and a new tab in an existing window
(which should inherit base on tab setting)
2026-01-05 16:47:04 -08:00
Peter Guy
82614511ab Use the new GTK Surface::setParent from the tab and split 2026-01-05 16:47:04 -08:00
Peter Guy
05229502bf Add the surface context to the Surface's setParent
In order to set the private context variable so that initiSurface can use it.
2026-01-05 16:47:04 -08:00
Peter Guy
496f5b3ed7 Add the context to the Swift layer.
- Define NewSurfaceContext to match the Zig enum name and avoid magic numbers.
2026-01-05 16:47:04 -08:00
Peter Guy
dba0ff5339 Add C API function to handle new surfaces of different types 2026-01-05 16:47:04 -08:00
Peter Guy
7cf4c8dc53 Add context field to C config struct 2026-01-05 16:47:04 -08:00
Peter Guy
02e1a68263 Use config to determine cwd inheritance for windows, tabs, and splits
- Define NewSurfaceContext enum (window, tab, split)
- Add shouldInheritWorkingDirectory helper function
- Thread surface context through newConfig and newSurfaceOptions
- Replace window-inherit-working-directory checks with context-aware logic
- Add context to embedded CAPI and GTK Surface structs
2026-01-05 16:47:04 -08:00
Peter Guy
87fc5357eb Add config entries for tab and split inheritance 2026-01-05 16:47:04 -08:00