6922 Commits

Author SHA1 Message Date
Daniel Wennberg
69b83e7de4 Use em size as nerd font reference metric 2025-07-15 13:04:51 -07:00
Daniel Wennberg
80e52aa6f0 Make normalization reference metric customizable per font 2025-07-15 13:04:17 -07:00
Daniel Wennberg
e4b53cc909 Move face metric fallback estimates to the FaceMetric struct 2025-07-15 12:58:41 -07:00
Mitchell Hashimoto
34af1feed3 windows: get +ssh-cache building on Windows (#7947)
There are still problems linking due to `gettext`. No idea if this
actually _works_ on Windows. File locking had to be disabled on Windows
because of a bug in the Zig std library. Adding all of the explicit
error sets happened due to disabling file locking. Fixing permissions
had to be disabled on Windows as the Windows file system does not
support permissions in the way that POSIX systems like macOS and Linux
do.
2025-07-14 19:55:56 -07:00
Jeffrey C. Ollie
15567bfc24 windows: get +ssh-cache building on Windows
There are still problems linking due to `gettext`. No idea if this
actually _works_ on Windows. File locking had to be disabled on Windows
because of a bug in the Zig std library. Adding all of the explicit
error sets happened due to disabling file locking. Fixing permissions
had to be disabled on Windows as the Windows file system does not
support permissions in the way that POSIX systems like macOS and Linux
do.
2025-07-14 18:14:09 -05:00
Jeffrey C. Ollie
38a81a7aed apprt: clean up stray struct 2025-07-14 15:58:32 -05:00
Jeffrey C. Ollie
dd3853abeb cli/gtk: move IPC/sendIPC to App/performIpc 2025-07-14 14:48:12 -05:00
Jeffrey C. Ollie
f5eb413c31 cli/gtk: clean ups and better error handling in GTK new-window IPC 2025-07-14 14:48:12 -05:00
Jeffrey C. Ollie
7d05f4c0c5 cli/gtk: don't set GHOSTTY_CLASS 2025-07-14 14:48:12 -05:00
Jeffrey C. Ollie
361d03b578 cli/gtk: remove --release and --debug flags, use optional for arguments 2025-07-14 14:48:12 -05:00
Jeffrey C. Ollie
81358c8dca cli/gtk: replace @hasDecl for performAction-style API
Instead of using @hasDecl, use a performAction-stype API. The C
interface for interfacing with macOS (or any other apprt where Ghostty
is embedded) is unfinished.
2025-07-14 14:48:11 -05:00
Jeffrey C. Ollie
72e47cf8bc cli/gtk: move actual IPC code tp apprt 2025-07-14 14:48:11 -05:00
Jeffrey C. Ollie
824185f23e cli/gtk: add -e to +new-window
This adds the `-e` flag to the `+new-window` CLI action. This allows a
command to be passed from the CLI to the running instance of Ghostty.
Nothing is done with that command besides logging its presence.
2025-07-14 14:48:11 -05:00
Jeffrey C. Ollie
721702fce4 cli/gtk: move GTK-specific code to a new file in a subdirectory 2025-07-14 14:48:11 -05:00
Jeffrey C. Ollie
340d190bf0 cli/gtk: clarify +new-window documentation and improve instance discovery
- Add a `GHOSTTY_CLASS` environment variables to any command executed by
  Ghostty to make discovering the correct application ID easier.

- Add a flag to force the relelase application ID.

- Ensure that CLI flags to `+new-window` are mutually exclusive.

- Fix documentation about D-Bus activation requirements.
2025-07-14 14:48:11 -05:00
Jeffrey C. Ollie
7845399c00 cli/gtk: add +new-window action
This will (on GTK) use a D-Bus method call to tell a running
Ghostty instance to open a new window. If D-Bus activation is
configured properly, Ghostty does not need to be running first.

This could be extended to other platforms, e.g. AppleScript on macOS
eventually.

When Ghostty develops a native API, that could be used instead to create
a new window.
2025-07-14 14:48:10 -05:00
Mitchell Hashimoto
658567bbbd fix webdata build, run it in CI
This fixes our build for `-Demit-webdata`. Turns out we weren't 
running this in CI so this adds that there.
2025-07-12 06:46:00 -07:00
Jeffrey C. Ollie
1abc3ba1da gtk: change child exited verbiage to be clearer and code cleanup 2025-07-11 22:56:22 -05:00
Jeffrey C. Ollie
9ee25e8a69 gtk: use close button in show_child_exited banner 2025-07-11 22:56:22 -05:00
Jeffrey C. Ollie
8cea111329 gtk: add some comments for show_child_exited 2025-07-11 22:56:21 -05:00
Jeffrey C. Ollie
49243db4b3 gtk: GtkBox not needed for show_child_exited 2025-07-11 22:56:21 -05:00
Jeffrey C. Ollie
7fd900647e show_child_exited: remove emojis 2025-07-11 22:56:21 -05:00
Jeffrey C. Ollie
f24ec13963 remove unused css class from gtk child exited widget 2025-07-11 22:56:21 -05:00
Jeffrey C. Ollie
bf0659f07b use checkmark for icon if child exits normally 2025-07-11 22:56:21 -05:00
Jeffrey C. Ollie
3d89a68fff fix error set for function return signature 2025-07-11 22:56:21 -05:00
Jeffrey C. Ollie
28c7083876 gtk show_child_edit: use different text for normal/abnormal exit
Without this, the only indication would be the difference between a red
or a green background which would be problematic for users with limited
vision or color blindness.
2025-07-11 22:56:21 -05:00
Jeffrey C. Ollie
5219bc51e5 show child exited: return a boolean if native GUI is shown
If a native GUI is shown by the runtime when a child exits, use the
returned boolean to determine if text should be show in the terminal to
avoid duplicating information.
2025-07-11 22:56:21 -05:00
Jeffrey C. Ollie
103772ee8f show child exited: make GTK banner transparent 2025-07-11 22:56:21 -05:00
Jeffrey C. Ollie
033d8c3099 core/gtk: add apprt action to show native GUI warning when child exits
Addresses #7649 for the core and GTK. macOS support will need to be
added later.

This adds an apprt action to show a native GUI warning of some kind when
the child process of a terminal exits.

Also adds a basic GTK implementation of this. In GTK it overlays an
Adwaita banner at the bottom of the window (similar to the banner that
shows up in at the top of windows in debug builds).
2025-07-11 22:56:20 -05:00
nferhat
991426e84e renderer: Allow the renderer to draw transparent cells
Co-authored-by: Kat <65649991+00-kat@users.noreply.github.com>
2025-07-11 06:59:01 -07:00
Mitchell Hashimoto
4aa28988a6 build: zig build test runs Xcode tests on macOS (#7909)
Related to #7879

This commit updates `zig build test` to run Xcode tests, too. These run
in parallel to the Zig tests, so they don't add any time to the test.

The Xcode tests will _not_ run when: (1) the target is not macOS, or (2)
the `-Dtest-filter` option is non-empty. This makes it so that this
change doesn't affect non-macOS and doesn't affect the general dev cycle
because you usually will run `-Dtest-filter` when developing a core
feature.

I didn't add a step to only run Xcode tests because I find that when I'm
working in Xcode I'm probably going to run the tests from there anyways.
The integration with `zig build test` is just a convenience, especially
around CI.

Speaking of CI, this change also makes it so this will run in CI.
2025-07-10 21:21:46 -07:00
Mitchell Hashimoto
9fa26387ef build: zig build test runs Xcode tests on macOS
Related to #7879

This commit updates `zig build test` to run Xcode tests, too. These run
in parallel to the Zig tests, so they don't add any time to the test.

The Xcode tests will _not_ run when: (1) the target is not macOS, or (2)
the `-Dtest-filter` option is non-empty. This makes it so that this
change doesn't affect non-macOS and doesn't affect the general dev cycle
because you usually will run `-Dtest-filter` when developing a core
feature.

I didn't add a step to only run Xcode tests because I find that when I'm
working in Xcode I'm probably going to run the tests from there anyways.
The integration with `zig build test` is just a convenience, especially
around CI.

Speaking of CI, this change also makes it so this will run in CI.
2025-07-10 21:08:51 -07:00
Jon Parise
01233a48d1 bash: preserve an existing ENV value
Our bash shell integration code uses ENV (in POSIX mode) to bootstrap
our shell integration script. This had the side effect of overwriting an
existing ENV value.

This change preserves ENV by storing it temporarily in GHOSTTY_BASH_ENV.

Note that this doesn't enable --posix mode support for automatic shell
integration. (--posix does work; we just skip shell integration when
that flag is specified.) We can reconsider implementing full --posix
support separately.
2025-07-10 15:47:55 -04:00
Qwerasd
cc646ecf46 Fix custom shader cursor uniforms not set for non-block cursors (#7897)
Fixes #7893

Previously, custom shader cursor uniforms were only updated when the
cursor glyph was in the front (block) cursor list. This caused non-block
cursors (such as bar, underline, hollow block, and lock) to be missing
from custom shader effects.

This commit adds a helper to the cell contents struct to retrieve the
current cursor glyph from either the front or back cursor lists, and
updates the renderer to use this helper when setting custom shader
uniforms. As a result, custom shaders now receive correct cursor
information for all supported cursor styles.
2025-07-10 09:26:46 -06:00
Jon Parise
530785926e elvish: revise the ssh integration (#7894)
The previous implementation wasn't quite working. This revision reworks
it in a few ways:

- Fix various syntax issues
- Redirect the `ssh` command to our 'ssh-integration' function
- Locate the `ghostty` binary using $GHOSTTY_BIN_DIR
- Use os:temp-dir to create our temporary directory

Also, consistently use 2-space indents, which is the Elvish standard.
2025-07-10 07:58:37 -04:00
ClearAspect
36a3a3ffa4 Add tests for getCursorGlyph() helper function 2025-07-10 01:48:44 -04:00
Qwerasd
1de35bbcb9 Fix viewport going out of bounds when zooming out (#7899)
The viewport pin was allowed to go below the active pin during resize,
which caused a use of null when trying to get the bottom right of the
viewport since going down by the active row count from the viewport pin
ends up below the bottom of the active area.

Ran in to this while doing font work because I was scrolled up slightly
and increasing and decreasing to see stuff at different sizes.
2025-07-09 23:15:26 -06:00
Qwerasd
ea4a056d34 test(terminal/PageList): resize keeps viewport <= active
This tests for the bug fixed in the last commit.
2025-07-09 22:47:01 -06:00
Mitchell Hashimoto
68418ecd53 Modernize our benchmarks (#7891)
This PR modernizes our benchmarks. This PR focuses on the benchmark
_framework_ and not the benchmarks themselves. That will come in later
PRs.

We now produce two binaries with `-Demit-bench`: `ghostty-bench` and
`ghostty-gen`. The former is our benchmark tool. The latter is our
synthetic data generation tool. The benchmarking CLI usually takes in
data from the synthetic generator but we want to do that offline because
synthetic data generation can be slow and CPU intensive and mess up our
benchmarks.

Our previous benchmark-specific binaries (like
`ghostty-bench-codepoint-width`) are all gone. This is all executed as
subcommands in the format similar to Ghostty users: `ghostty-bench
+codepoint-width --other --args`.

Previously, synthetic data generation was a mess and all unified with
`ghostty-bench-stream` which is just nasty. A dedicated CLI now gets us
args like `ghostty-gen +osc --p-valid=0.5`. Neat!

## Signposts and Xcode/Instruments on macOS

The benchmark framework now automatically emits
[signposts](https://developer.apple.com/documentation/os/recording-performance-data)
around the code that is under test. This is surfaced in Instruments as a
region that you can visualize and zoom in on so you can omit any of the
other overhead.

Additionally, I've integrated benchmarks with libghostty and our Xcode
project so you can just right click a benchmark to open it in
Instruments.

These are macOS-specific niceties but the core benchmarking tool is
platform-agnostic.

## Generalized CLI Actions

The `src/cli/action.zig` file was generalized so that it can be shared
amongst our three action-ized binaries. The Ghostty-specific actions are
now in `src/cli/ghostty.zig`. As an added bonus, our action parsing is
now fully unit tested.

I don't like mixing refactors in with other tasks in PRs but in this
case this one was done to enable not one but two other consumers in the
same PR, so I think it fits.

## TODO

Some things I want to do before merge.

- [ ] Add flags to `ghostty-bench` to configure once mode vs duration
mode
2025-07-09 21:42:53 -07:00
Mitchell Hashimoto
cc0d7acaef build: make the xcframework step dsym aware, even though we don't use it
This was in pursuit of trying to get line numbers in `zig build run` on
macOS to work, but I wasn't able to figure that out and this wasn't the
right path because static libs can't have dsyms. But, it may still be
useful to make the xcframework step dsym aware for future use so I'm
PRing this.
2025-07-09 21:35:02 -07:00
Qwerasd
6744e57c68 fix(terminal/PageList): update viewport in row count resize
Before, if the row count increase past the active area then we added new
rows to make sure that we had enough for the active area, but we didn't
make sure that the viewport pin wasn't below the active area pin, which
meant that later on if someone tried to get the bottom right pin for the
viewport it would overshoot and we'd use null. This resulted in either a
memory corruption bug in ReleaseFast if you scaled down the font while
scrolled up slightly, or in Debug mode it was just a crash.
2025-07-09 22:28:08 -06:00
ClearAspect
88736a2ddb Fix custom shader cursor uniforms not set for non-block cursors (#7893)
Fixes #7893

Previously, custom shader cursor uniforms were only updated when the
cursor glyph was in the front (block) cursor list. This caused non-block
cursors (such as bar, underline, hollow block, and lock) to be missing
from custom shader effects.

This commit adds a helper to the cell contents struct to retrieve the
current cursor glyph from either the front or back cursor lists, and
updates the renderer to use this helper when setting custom shader
uniforms. As a result, custom shaders now receive correct cursor
information for all supported cursor styles.
2025-07-10 00:21:21 -04:00
Jon Parise
5cdfe3d70e elvish: revise the ssh integration
The previous implementation wasn't quite working. This revision reworks
it in a few ways:

- Fix various syntax issues
- Redirect the `ssh` command to our 'ssh-integration' function
- Locate the `ghostty` binary using $GHOSTTY_BIN_DIR
- Use os:temp-dir to create our temporary directory

Also, consistently use 2-space indents, which is the Elvish standard.
2025-07-09 22:19:13 -04:00
Mitchell Hashimoto
74b94ef30a remove src/bench 2025-07-09 15:06:24 -07:00
Mitchell Hashimoto
a09452bf1b synthetic: add osc/utf8 generators 2025-07-09 15:06:24 -07:00
Mitchell Hashimoto
a28b7e9205 synthetic cli (ghostty-gen) 2025-07-09 15:06:24 -07:00
Mitchell Hashimoto
b5ff0442d4 bench: remove old benchmarks we converted 2025-07-09 15:06:24 -07:00
Mitchell Hashimoto
99ed984af2 benchmark: add GraphemeBreak and TerminalParser benchmarks 2025-07-09 15:06:24 -07:00
Mitchell Hashimoto
5890826356 benchmark: add codepoint width benchmark 2025-07-09 15:06:24 -07:00
Mitchell Hashimoto
c990d35d6d macos: add benchmark tests to our Xcode project 2025-07-09 15:06:24 -07:00