Commit Graph

8488 Commits

Author SHA1 Message Date
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
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
Jacob Sandlund
f258265ef0 font/shaper: keep codepoints in same cell if detecting ligature 2026-01-06 10:30:13 -05: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
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
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
dba0ff5339 Add C API function to handle new surfaces of different types 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
Jeffrey C. Ollie
f3e90e23d9 Lower unimplemented OSC from warning to debug 2026-01-05 15:47:49 -06:00
Mitchell Hashimoto
c5bc6bb2ce fix: use flush instead of end on stdout in code generators for Windows compatibility (#10150)
This fixes the Windows build failure discussed in
https://github.com/ghostty-org/ghostty/discussions/10148

When building on Windows, `symbols-unigen` and `props-unigen` crash with
`error.FileTooBig` because `stdout.end()` calls `setEndPos()` to
truncate the output. Windows does not support `SetEndOfFile` on pipes or
console handles - it returns `ERROR_INVALID_PARAMETER`, which Zig maps
to `error.FileTooBig`.

Using `flush()` instead of `end()` is correct here because:

1. `end()` flushes AND truncates - useful when overwriting files that
might have leftover content
2. For stdout captured as a pipe, there's nothing to truncate - we're
writing sequentially to a fresh pipe
3. `flush()` ensures all buffered data is sent, which is all that's
needed

CI before fix was failing with FileTooBig, after fix builds
successfully:
https://github.com/remorses/opentui/actions/runs/20671299561/job/59352503875
2026-01-05 11:44:13 -08:00
Mitchell Hashimoto
dda27d43be font/shaper: Fix CoreText position.y for some scripts (#10179)
This PR simplifies and corrects the logic for placing a glyph
vertically, by using the `position.y` from `CoreText` directly, instead
of using an offset from the cell's starting `y`. The logic was incorrect
from the beginning, always treating the first glyph of a cell as being
at `y` of zero. We only need to be subtracting the cell's starting `x`
to align the glyphs to the cell grid.

Enabling the commented out logging, I found no instances of `position.y
differs from old offset.y` lines with `JetBrains Mono` with ligatures
turned on, but running
[ttylang](https://github.com/jacobsandlund/ttylang) (printing the
Universal Declaration of Human Rights in various languages) revealed 676
instances of this, with many only slightly off.

An example log from some Tai Tham text is the following, and this PR
adds a test based on this:

```
...pos=(0.00,-8.21) run_offset=(69.41,-8.21) cell_offset=(69.41,-8.21) old offset.y=0.00 cps = \u{1a49}\u{1a60} \u{1a3f}▸\u{1a69} \u{1a2f} → ᩉ᩠ᨿᩩᨯ
```

Browsers display this as:

ᩉ᩠ᨿᩩ

`main` is printing:

<img width="852" height="90" alt="CleanShot 2026-01-05 at 10 28 17@2x"
src="https://github.com/user-attachments/assets/c97b738c-8fe4-48b5-81f8-e0e79f1a9269"
/>

this PR prints:

<img width="958" height="90" alt="CleanShot 2026-01-05 at 10 29 07@2x"
src="https://github.com/user-attachments/assets/88fd26a7-8041-4b33-ab02-56f411204b04"
/>

Since this is a ligature of two different grapheme clusters, Ghostty
ends up subtracting too much of the `x` value with the `cell_offset.x`
(starting x), so neither of the screenshots above are correct, but the
second is closer and gets the `y` value right.

AI disclaimer: I didn't use AI for the code, but did ask it about this
Tai Tham text and why it wasn't a single grapheme cluster:
https://ampcode.com/threads/T-019b8ea2-1822-75bb-a8eb-55a9ddb9f7ea
2026-01-05 11:17:16 -08:00
Jacob Sandlund
15899b70fb simplify run_offset_x comment 2026-01-05 10:35:22 -05:00
Jacob Sandlund
7aec7effea Add test for Tai Tham letter position.y difference 2026-01-05 10:12:05 -05:00
Jacob Sandlund
41f63384f5 Turn off debugging 2026-01-05 09:59:37 -05:00
Jacob Sandlund
f31d2b99ae Merge remote-tracking branch 'upstream/main' into coretext-position-y 2026-01-05 09:58:10 -05:00
Jacob Sandlund
d38558aee1 Show current cp with ▸ in list of cps 2026-01-05 09:34:17 -05:00
Peter Cardenas
f36abed35a fix: reset progress bar on reset terminal 2026-01-05 05:26:33 -08:00
Jacob Sandlund
1d4a5d91e0 More debugging for position.y differences 2026-01-04 21:24:45 -05:00
Tommy Brunn
f5d7108c51 gtk: Remove strong reference to surface from command palette 2026-01-04 08:36:40 +01:00
Tommy Brunn
d3aa684139 gtk: Remove window reference from jump commands
Removes redundant implementations that is already present in the core
application to work with surfaces.
2026-01-03 22:34:23 +01:00
Tommy Brunn
8754c53e0e gtk: Get jump command title from Surface title 2026-01-03 22:07:57 +01:00
Tommy Brunn
d7972cb8b7 gtk: Session Search
Gtk implementation of #9945. Fixes #9948.

This adds session search to the command palette on Gtk, allowing you to
jump to any surface by title or working directory. The main difference
to the Mac OS implementation is that tabs do not have colors by which to
search.
2026-01-03 18:38:28 +01:00
Tommy D. Rossi
e2de0bfd93 fix: clarify error codes in comment 2026-01-03 13:44:29 +01:00
Tommy D. Rossi
4ea669562e fix: use flush instead of end on stdout in code generators for Windows compatibility 2026-01-03 13:43:27 +01:00
Eric Bower
f316c969a5 chore: update test expectation 2026-01-01 20:24:33 -05:00
Eric Bower
ea03c5c8a2 fix: reset style to prevent bleeding bg colors newline 2026-01-01 20:15:41 -05:00
Eric Bower
6fdbc29b9a fix(formatter): preserve background colors on cells without text
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.

Reference: https://ampcode.com/threads/T-019b7a35-c3f3-73fc-adfa-00bbe9dbda3c
2026-01-01 20:07:27 -05:00
Martin Emde
ec2612f9ce Add iTimeFocus shader uniform to track time since focus 2026-01-01 13:11:54 -08:00
Eric Bower
c081adce05 chore: write page vt test bg color with trailing row
The issue is in ghostty_src/src/terminal/formatter.zig#L1117-L1129:

- Cells without text are treated as "blank" (line 1117-1119) - this includes cells that only have background colors
- When blank cells are emitted, they're plain spaces (line 1129) - writer.splatByteAll(' ', blank_cells) outputs spaces without any SGR styling
- Background-only cells (bg_color_palette, bg_color_rgb) are marked unreachable (lines 1233-1235) because the code assumes hasText() already filtered them

This means when htop draws a row like:

`[green bg]CPU: 45%[red bg]          [default]`

The trailing cells with red background but no text get accumulated as blanks and emitted as plain spaces - losing the background color.
2026-01-01 10:47:40 -05:00
Mitchell Hashimoto
f2bc722a58 pkg/dcimgui: fix wchar size mismatch 2025-12-31 13:36:40 -08:00
Mitchell Hashimoto
965ffb1750 pkg/dcimgui: add freetype 2025-12-31 13:20:27 -08:00
Mitchell Hashimoto
f1ba5297b8 build: fix imgui on GTK 2025-12-31 13:20:03 -08:00
Mitchell Hashimoto
896361f426 Fix up API calls for initialization 2025-12-31 13:01:28 -08:00
Mitchell Hashimoto
978400b0b0 replace cimgui with dcimgui 2025-12-31 10:42:10 -08:00
Jacob Sandlund
0a648cddf8 shaping: Use position.y directly for CoreText 2025-12-30 17:36:45 -05:00
qingyunha
5c4af69765 Update Vim filetype detection patterns
Fixes #10094
2025-12-30 08:47:18 +08:00
Mitchell Hashimoto
61df50d70b input: add end_key_sequence binding action
End the currently active key sequence, if any, and flush the
keys up to this point to the terminal, excluding the key that
triggered this action.

For example: `ctrl+w>escape=end_key_sequence` would encode
`ctrl+w` to the terminal and exit the key sequence.

Normally, an invalid sequence will reset the key sequence and
flush all data including the invalid key. This action allows
you to flush only the prior keys, which is useful when you want
to bind something like a control key (`ctrl+w`) but not send
additional inputs.
2025-12-29 12:07:54 -08:00
Mitchell Hashimoto
e3dd5b93e6 gtk: pass through keypress when clipboard has no text (#10089)
## Summary

When `paste_from_clipboard` is triggered but the clipboard contains no
text (e.g., an image), the action now returns `false` to indicate it
couldn't be performed. This enables the `performable:` keybind prefix to
work correctly for paste actions.

## Problem

On GTK/Linux, when a user has `keybind = ctrl+v=paste_from_clipboard`
and the clipboard contains an image (not text), pressing Ctrl+V does
nothing. Applications like `opencode` that handle their own clipboard
reading via `wl-paste` never receive the keypress.

## Solution

Make `clipboardRequest` return `bool` to indicate whether the action
could be performed. For paste requests on GTK, synchronously check if
the clipboard contains text formats before starting the async read. When
no text format is available, return `false`.

Users can now use:
```
keybind = performable:ctrl+v=paste_from_clipboard
```

When the clipboard has no text, the keybind is not consumed and Ctrl+V
passes through to the terminal application.

## Changes

- `Surface.startClipboardRequest` now returns `bool`
- `paste_from_clipboard` / `paste_from_selection` actions return the
result
- GTK apprt checks clipboard formats synchronously before async read
- Embedded apprt always returns `true` (can't check synchronously)

## Testing

1. Add `keybind = performable:ctrl+v=paste_from_clipboard` to config
2. Copy an image to clipboard
3. Open an application that handles image paste (e.g., `opencode`)
4. Press Ctrl+V
5. Image pastes successfully (app receives keypress and handles
clipboard itself)

## Disclaimer

Most of the changes is done with Opus 4.5
2025-12-29 09:39:17 -08:00
cyppe
972b65eb1b review 2025-12-29 18:32:25 +01:00