10774 Commits

Author SHA1 Message Date
mitchellh
8a0ca1b573 deps: Update iTerm2 color schemes 2025-05-18 00:14:40 +00:00
Leah Amelia Chen
b1af4a597f gtk: implement command palette (#7167)
Closes #7156
2025-05-16 22:16:48 +02:00
Mitchell Hashimoto
a6466c5ca0 macOS: use file parent dir for openTerminal service cwd (#7286) (#7292)
Fixes #7286

Previously, when using the "New Ghostty Window/Tab Here" macOS service
on a file, the new terminal window/tab would incorrectly open in the
user's home directory. This was because the service handler only
expected directory paths.

This commit updates the service handler to check if the provided path is
a file. If it is, the handler now uses the file's parent
directory as the working directory for the new Ghostty window or tab,
aligning with user expectations. If the path is a directory, it's used
directly as before.
2025-05-15 20:20:59 -07:00
Mitchell Hashimoto
2d29fe0494 bench: add --mode=gen-osc to generate synthetic OSC sequences (#7359)
cc @qwerasd205 

This commit adds a few new mode flags to the `bench-stream` program to
generator synthetic OSC sequences. The new modes are `gen-osc`,
`gen-osc-valid`, and `gen-osc-invalid`. The `gen-osc` mode generates
equal parts valid and invalid OSC sequences, while the suffixed variants
are for generating only valid or invalid sequences, respectively.

This commit also fixes our build system to actually be able to build the
benchmarks. It turns out we were just rebuilding the main Ghostty binary
for `-Demit-bench`. And, our benchmarks didn't run under Zig 0.14, which
is now fixed.

An important new design I'm working towards in this commit is to split
out synthetic data generation to a dedicated package in
`src/bench/synth` although I'm tempted to move it to `src/synth` since
it may be useful outside of benchmarks.

The synth package is a work-in-progress, but it contains a hint of
what's to come. I ultimately want to able to generate all kinds of
synthetic data with a lot of knobs to control dimensionality (e.g. in
the case of OSC sequences: valid/invalid, length, operation types,
etc.).
2025-05-15 20:19:37 -07:00
Mitchell Hashimoto
e1de7a99e8 macos: add "Check for Updates" action, menu item & key-binding support (#7361)
Resolve #7325
2025-05-15 15:45:24 -07:00
Mitchell Hashimoto
5826b8b142 Gamma correct image scaling (#7368)
Fixes the gamma error noted in #7367 for both Metal and OpenGL by using
sRGB image formats for the textures.

This branch also includes the commits from #7367, so it'd probably be
best to review and merge that first.
2025-05-15 15:36:12 -07:00
Qwerasd
ea79fdea11 fix(OpenGL): use sRGB texture format for gamma correct interpolation
otherwise images will be too dark when scaled
2025-05-15 12:44:44 -06:00
Qwerasd
e2f3b6211f fix(Metal): use sRGB texture format for gamma correct interpolation
otherwise images will be too dark when scaled
2025-05-15 12:44:44 -06:00
Mitchell Hashimoto
1d0cb1a9b0 fix(renderer): Don't force images to grid/cell sizes. (#7367)
Also fixed Metal not interpolating scaled images.

See commit message for more details.

|`main` (Metal)|`main` (OpenGL)|Kitty|fixed (Metal)|fixed (OpenGL)|
|-|-|-|-|-|

|![image](https://github.com/user-attachments/assets/bfe09451-0a41-4952-8a55-5d7a9e5b2813)|![image](https://github.com/user-attachments/assets/70ec6775-ba00-40b7-a32d-dcaaa70671b1)|![image](https://github.com/user-attachments/assets/6d03729b-9b8e-4b25-850d-913e76f6183b)|![image](https://github.com/user-attachments/assets/aedfccf0-220c-4575-b5e4-8b467de6d5df)|![image](https://github.com/user-attachments/assets/300a080a-73f0-4c69-9603-df342767a83f)|

<sup>(Zoom in for details.)</sup>

> [!NOTE]
> This comparison reveals a separate problem we have with image scaling,
which Kitty gets right but we don't -- the interpolation is too dark
because of gamma error, we need to be interpolating in linear space but
instead we're interpolating in gamma compressed space. I'll try to
figure out the best way to resolve this.
2025-05-15 11:42:05 -07:00
Qwerasd
ed207514e9 typo 2025-05-15 11:59:17 -06:00
Qwerasd
709b0214a0 fix(renderer): Don't force images to grid/cell sizes
This problem was introduced by f091a69 (PR #6675).

I've gone ahead and overhauled the placement positioning logic as well;
it was doing a lot of expensive calls before, I've significantly reduced
that.

Clipping partially off-screen images is now handled entirely by the
renderer, rather than while preparing the placement, and as such the
grid position passed to the image shader is now signed.
2025-05-15 11:41:12 -06:00
Aaron Ruan
f343e1ba46 Fix comma typo 2025-05-16 00:40:25 +08:00
Leah Amelia Chen
cc65dfc90e gtk(command_palette): focus fixes 2025-05-15 18:11:19 +02:00
Leah Amelia Chen
2800e0c99b gtk(command_palette): address feedback related to selections
See #7173, #7175
2025-05-15 18:11:19 +02:00
Leah Amelia Chen
7293d91f10 translations(zh_CN): update 2025-05-15 18:11:19 +02:00
Leah Amelia Chen
91f811bfbf translations: update 2025-05-15 18:11:19 +02:00
Leah Amelia Chen
e97dfc2e19 gtk(command_palette): filter out certain actions 2025-05-15 18:11:19 +02:00
Leah Amelia Chen
3b013b1174 gtk: add command palette to titlebar menu 2025-05-15 18:11:19 +02:00
Leah Amelia Chen
048e4acb2c gtk: implement command palette 2025-05-15 18:11:19 +02:00
Aaron Ruan
f6d56f4f03 Handle check_for_updates as unimplemented action 2025-05-15 23:26:47 +08:00
Jeffrey C. Ollie
9ff43cd345 gtk: implement custom audio bell (#5326)
Fixes #2710 

Adds support for custom audio bell notifications.
2025-05-15 10:09:39 -05:00
Aaron Ruan
7ccc181332 macos: add "Check for Updates" action, menu item & key-binding support 2025-05-15 13:34:44 +08:00
Qwerasd
55c1ef779f fix(Metal): interpolate kitty images
uint textures can't be interpolated apparently
2025-05-14 21:12:20 -06:00
Mitchell Hashimoto
a74e352726 bench: add --mode=gen-osc to generate synthetic OSC sequences
This commit adds a few new mode flags to the `bench-stream` program
to generator synthetic OSC sequences. The new modes are `gen-osc`,
`gen-osc-valid`, and `gen-osc-invalid`. The `gen-osc` mode generates
equal parts valid and invalid OSC sequences, while the suffixed variants
are for generating only valid or invalid sequences, respectively.

This commit also fixes our build system to actually be able to build the
benchmarks. It turns out we were just rebuilding the main Ghostty binary
for `-Demit-bench`. And, our benchmarks didn't run under Zig 0.14, which
is now fixed.

An important new design I'm working towards in this commit is to split
out synthetic data generation to a dedicated package in
`src/bench/synth` although I'm tempted to move it to `src/synth` since
it may be useful outside of benchmarks.

The synth package is a work-in-progress, but it contains a hint of
what's to come. I ultimately want to able to generate all kinds of
synthetic data with a lot of knobs to control dimensionality (e.g. in
the case of OSC sequences: valid/invalid, length, operation types,
etc.).
2025-05-14 12:26:31 -07:00
Mitchell Hashimoto
a090e8eeed url: restrict file paths regex to one slash (#7355)
Fixes https://github.com/ghostty-org/ghostty/discussions/7351.

This restricts the valid path prefixes to prevent false matches caused
by literal dot.
2025-05-14 10:32:08 -07:00
Weizhao Ouyang
528814da79 url: restrict file paths regex to one slash
This restricts the valid path prefixes to prevent false matches caused
by literal dot.

Signed-off-by: Weizhao Ouyang <o451686892@gmail.com>
2025-05-14 23:20:09 +08:00
Jeffrey C. Ollie
ba08b0cce5 gtk custom bell audio: optional -> required 2025-05-13 10:01:54 -05:00
Jeffrey C. Ollie
0e8b266662 Use std.math.clamp
Co-authored-by: Leah Amelia Chen <github@acc.pluie.me>
2025-05-13 10:01:54 -05:00
Jeffrey C. Ollie
8d0c3c7b7c gtk: implement custom audio for bell 2025-05-13 10:01:54 -05:00
Mitchell Hashimoto
6984b1ec48 input: add backwards compatible alias for plus to + (#7342)
From #7320
Discussion #7340

There isn't a `physical` alias because there is no physical plus key
defined for the W3C keycode spec.
2025-05-12 15:39:39 -07:00
Mitchell Hashimoto
507e808a7c input: add backwards compatible alias for plus to +
From #7320
Discussion #7340

There isn't a `physical` alias because there is no physical plus key
defined for the W3C keycode spec.
2025-05-12 15:32:32 -07:00
Mitchell Hashimoto
7dc65adb1f snap: Build with cpu=baseline as documented in PACKAGING.md (#7341)
Ensures baseline instruction set
2025-05-12 15:07:03 -07:00
Ken VanDine
e2daf04cba snap: Build with cpu=baseline as documented in PACKAGING.md 2025-05-12 17:40:48 -04:00
Mitchell Hashimoto
00829ca2cc macos: do not send UTF-8 PUA codepoints to key events (#7338)
Fixes #7337

AppKit encodes functional keys as PUA codepoints. We don't want to send
that down as valid text encoding for a key event because KKP uses that
in particular to change the encoding with associated text.

I think there may be a more specific solution to this by only doing this
within the KKP encoding part of KeyEncoder but that was filled with edge
cases and I didn't want to risk breaking anything else.
2025-05-12 11:45:04 -07:00
Mitchell Hashimoto
ecda5ec327 macos: do not send UTF-8 PUA codepoints to key events
Fixes #7337

AppKit encodes functional keys as PUA codepoints. We don't want to send
that down as valid text encoding for a key event because KKP uses that
in particular to change the encoding with associated text.

I think there may be a more specific solution to this by only doing this
within the KKP encoding part of KeyEncoder but that was filled with edge
cases and I didn't want to risk breaking anything else.
2025-05-12 11:42:05 -07:00
Mitchell Hashimoto
6723c308be input: bracket right was mapped to left, a typo (#7334)
From #7320
2025-05-12 10:00:17 -07:00
Mitchell Hashimoto
6c6cdf4c4f input: bracket right was mapped to left, a typo 2025-05-12 09:57:10 -07:00
Mitchell Hashimoto
3f54601df0 Use W3C key code specification for keybindings (Breaking Change) (#7320)
Fixes #7315
Fixes #7314 
Fixes #7310 
Fixes #7309

**This PR has breaking changes, noted later.**

This changes our internal key events to match the [W3C key event code
specification](https://www.w3.org/TR/uievents-code/). With these
changes, apprts are expected to produce key codes within that spec and
everything follows from there. This gives us a standard cross-platform
keycode behavior.

Previously, due to our history, we based our key codes on GLFW and Linux
more generally (since Ghostty was on Linux first). This served us
surprisingly well through today, but has been riddled with various
issues (many fixed, but note how many bugs this PR is fixing). From a
user experience perspective, it also caused confusion about how
Ghostty's keybinds interact with keyboard layouts which led to various
complicated features like `physical:` (which is removed in this PR).

## Overview of Changes

* `physical:` is now gone. Physical keys are now specified by the W3C
key codes. Example: `ctrl+KeyA` will always match the "a" key on a US
physical layout (the name `KeyA` lining up with US keyboards is mandated
by the spec, not us). Note when we say "physical" here we mean the
keycode sent by the OS or GUI framework; these can often be overridden
using programs to remap keys at the "hardware" level but software
layouts do not do this.

* All single codepoint characters match the character produced by the
keyboard layout (i.e. are layout-dependent). So `ctrl+c` matches the
physical "c" key on a US standard keyboard with a US layout, but matches
the "i" key on a Dvorak layout. This also works for international
characters. Codepoints are case-insensitive and match via Unicode case
folding (this is how both Windows and macOS treat keyboard shortcuts).

* W3C key names replace all previous non-character names and always
match _physical keys_. For example, `ctrl+grave_accent` (Ghostty 1.1x)
is now `ctrl+backquote` to match the W3C spec. This PR maintains
backwards compatibility so the old values are aliased to the new values.

* W3C key names can be both snake case and match the spec exactly. e.g.
`KeyA` and `key_a` are both valid. This is an aesthetic choice, because
I think the capitalization is really ugly. We have tests to verify this
mapping so its officially supported.

* Because we support W3C keys, we now support significantly more media
keys such as `context_menu`, `browser_home` and so many more. These work
as long as your OS and keyboard can produce the valid key codes.

## Breaking Changes

* Key names have changed, e.g. `grave_accent` is now `backquote`. The
new names are all W3C standard. There are backwards compatible aliases,
so **old configurations will still work.** But the `+list-keybinds` CLI
will always output the new versions.

* `physical:` is gone, all W3C names are always physical and all code
points are always logical. There are backwards compatible aliases for
unambiguous keys, so **most old configurations will still work.** If
there is ambiguity, old configurations will error, but I don't expect
this to be common at all.

* Physical keybinds always take priority over logical keybinds. This was
_inconsistent_ before. Physical keybinds are relatively rare so I don't
think this will impact people but just noting this is not an explicit,
tested, documented behavior.
2025-05-12 09:18:28 -07:00
Mitchell Hashimoto
8f40d1331e ensure ctrl++ parses, clarify case folding docs 2025-05-12 09:08:00 -07:00
Mitchell Hashimoto
0eebebb75e Update iTerm2 colorschemes (#7326)
Upstream revision:
93eb37fadd
2025-05-11 14:45:30 -07:00
Mitchell Hashimoto
c4f1c78fcf macOS: treat C-/ specially again to prevent beep
Fixes #7310
2025-05-11 07:15:46 -07:00
mitchellh
db1608ff16 deps: Update iTerm2 color schemes 2025-05-11 00:14:21 +00:00
Mitchell Hashimoto
ed1194cd75 fix tests 2025-05-10 08:51:08 -07:00
Mitchell Hashimoto
1752edd9eb input: implement case folding for binding matching 2025-05-10 07:22:44 -07:00
Mitchell Hashimoto
ca2ead9647 input: kitty add missing numpad keycodes since we support those now 2025-05-09 11:09:22 -07:00
Mitchell Hashimoto
ebabdb322c input: ignore control characters for backspace/enter/escape special case 2025-05-09 11:05:42 -07:00
Mitchell Hashimoto
a26310e83f macOS: app key is binding check should include utf-8 chars 2025-05-09 10:45:43 -07:00
Mitchell Hashimoto
293a67cd01 input: control-encode right control properly 2025-05-09 10:16:21 -07:00
Mitchell Hashimoto
54bd701ba9 input: bindings should match on single-codepoint utf-8 text too 2025-05-09 10:01:06 -07:00
Mitchell Hashimoto
5dc88bda6a macOS: send proper UTF-8 text for more key events 2025-05-09 10:01:06 -07:00