Commit Graph

12499 Commits

Author SHA1 Message Date
Mitchell Hashimoto
87b77e1980 ci: cleanup 2025-10-03 07:10:43 -07:00
Mitchell Hashimoto
4e3e0ed056 Zig 0.15: Flatpak 2025-10-03 07:10:43 -07:00
Mitchell Hashimoto
e1b5464bab Zig 0.15: build snap 2025-10-03 07:10:43 -07:00
Mitchell Hashimoto
2af424268a Zig 0.15: emit bench 2025-10-03 07:10:43 -07:00
Mitchell Hashimoto
9ec3b1b152 Zig 0.15: webdata 2025-10-03 07:10:43 -07:00
Mitchell Hashimoto
f0cfaa9580 zig 0.15: build on macOS 2025-10-03 07:10:43 -07:00
Mitchell Hashimoto
0112607532 Zig 0.15: zig build test macOS 2025-10-03 07:10:43 -07:00
Mitchell Hashimoto
d59d754e29 Zig 0.15: zig build GTK exe 2025-10-03 07:10:43 -07:00
Mitchell Hashimoto
cb295b84a0 Zig 0.15: zig build test 2025-10-03 07:10:43 -07:00
Mitchell Hashimoto
3770f97608 terminal: Zig 0.15, lib-vt and test-lib-vt work 2025-10-03 07:10:43 -07:00
Mitchell Hashimoto
913d2dfb23 unicode: fix lookup table generation 2025-10-03 07:10:43 -07:00
Mitchell Hashimoto
7ec57aeebd Zig 0.15: zig fmt 2025-10-03 07:10:43 -07:00
Mitchell Hashimoto
d02770d292 zig-15: build binary builds 2025-10-03 07:10:41 -07:00
Mitchell Hashimoto
dfa2354fec Implement and use generic approx equality tester (#8979)
Seems like there needs to be a general, easy-to-use solution for
approximate equality testing of containers holding floats (see, e.g.,
https://github.com/ghostty-org/ghostty/pull/8563#pullrequestreview-3281357931).
How's this?
2025-10-03 07:10:16 -07:00
Mitchell Hashimoto
f8ef51fc61 core: add 'command finished' notifications (#8992)
Fixes #8991

Uses OSC 133 esc sequences to keep track of how long commands take to
execute. If the user chooses, commands that take longer than a user
specified limit will trigger a notification. The user can choose between
a bell notification or a desktop notification.
2025-10-03 06:58:29 -07:00
Mitchell Hashimoto
7ac9de7d83 gtk: fix duplicate signal handlers (#9001)
Signal handlers are connected to surface objects in two spots - when a
tab is added to a page and when the split tree changes. This resulted in
duplicate signal handlers being added for each surface. This was most
noticeable when copying the selection to the clipboard - you would see
two "Copied to clipboard" toasts. Ensure that there is only one signal
handler by removing any old ones before adding the new ones.
2025-10-03 06:53:29 -07:00
Mitchell Hashimoto
8ed3a98db2 Fix Weird Behavior in CoreText Shaper (#9002)
You can pretty simply reproduce a crash on `main` in `Debug` mode by
running `printf "مرحبًا \n"` with your primary font set to one that
supports Arabic such as Cascadia Code/Mono or Kawkab Mono, which will
cause CoreText to output the shaped glyphs non-monotonically which hits
the assert we have in the renderer.

In `ReleaseFast` this assert is skipped and because we already moved
ahead to the space glyph (which belongs at the end but is emitted first)
all of the glyphs up to that point are lost. I believe this is probably
the cause of #8280, I tested and this change seems to fix it at least.

Included in this PR is a little optimization: we were allocating buffers
to copy glyphs etc. from runs to every time, even though CoreText
provides `CTRunGet*Ptr` functions which get *pointers* to the internal
storage of these values- these aren't guaranteed to return a usable
pointer but in that case we can always fall back to allocating again.
Also avoided allocation while processing glyphs by ensuring capacity
beforehand immediately after creating the `CTLine`.

The performance impact of this PR is negligible on my machine and
actually seems to be positive, probably due to avoiding allocations if I
had to guess.
2025-10-02 15:36:02 -07:00
Jeffrey C. Ollie
c8ed3031bc gtk: improve signal handler management
Instead of making two separate passes over the surfaces in a split tree
to manage signal handlers, do it in one pass.
2025-10-02 17:22:52 -05:00
Jeffrey C. Ollie
10adef3092 gtk: fix duplicate signal handlers 2025-10-02 17:22:52 -05:00
Qwerasd
efc6e0d673 fix(font/coretext): always prevent shaper from emitting rtl
The solution we had before worked in most cases but there were some
which caused problems still. This is what HarfBuzz's CoreText shaper
backend does, it uses a CTTypesetter with the forced embedding level
attribute. This fixes the failure case I found that was causing non-
monotonic outputs which can have all sorts of unexpected results, and
causes a crash in Debug modes because we assert the monotonicity while
rendering.
2025-10-02 15:32:21 -06:00
Qwerasd
d6063428bd font/coretext: tiny shaper improvements
Reduce potential allocation while processing glyphs by ensuring capacity
in the buffer ahead of time and also using CTRunGet*Ptr functions first
and only allocating for those if that didn't work (it should almost
always work in practice.)
2025-10-02 14:06:58 -06:00
Mitchell Hashimoto
052857b58b fix(config): Make macos-custom-icon null-terminated (#8999)
The config option `macos-custom-icon` wasn't working because, to pass
successfully through the C API to Swift, the string must be
null-terminated.

Fixes
https://discord.com/channels/1005603569187160125/1423192859112116224
2025-10-02 11:44:43 -07:00
Mitchell Hashimoto
16dab3b8dc crash: remove minidump parser (#9000)
We never used it because our minidump files on Linux didn't contain
meaningful information. With Zig's Writergate, let's drop this and
rewrite it later, we can always resurrect it from the git history.

Rejoice @pluiedev
2025-10-02 11:23:45 -07:00
Mitchell Hashimoto
f76dd96c7e crash: remove minidump parser
We never used it because our minidump files on Linux didn't contain
meaningful information. With Zig's Writergate, let's drop this and
rewrite it later, we can always resurrect it from the git history.
2025-10-02 11:09:51 -07:00
Jeffrey C. Ollie
1c23ebc6f1 address review comments 2025-10-02 12:57:53 -05:00
Jeffrey C. Ollie
07124dba64 core: add 'command finished' notifications
Fixes #8991

Uses OSC 133 esc sequences to keep track of how long commands take to
execute. If the user chooses, commands that take longer than a user
specified limit will trigger a notification. The user can choose between
a bell notification or a desktop notification.
2025-10-02 12:40:40 -05:00
Daniel Wennberg
e615b11b2c fix(config): Make macos-custom-icon null-terminated 2025-10-02 10:28:18 -07:00
Mitchell Hashimoto
9c8d2e577e fix(font): Let powerline glyphs be wide (#8994)
#8829 fixed the interaction of Powerline glyphs with other symbols, but
regressed in the handling of the Powerline glyphs themselves by letting
them get caught in an early exit that imposes a constraint width of 1.
This PR fixes the regression and adds corresponding tests. Tried to be
somewhat principled about why the special treatment is warranted, hence
the new helper function `isGraphicsElement`.

**Before**
<img width="270" height="44" alt="Screenshot 2025-10-02 at 00 16 54"
src="https://github.com/user-attachments/assets/9e975434-114c-44d5-a4ed-ac6a954b9d00"
/>

**After**
<img width="270" height="44" alt="Screenshot 2025-10-02 at 00 16 11"
src="https://github.com/user-attachments/assets/20545e74-c9f9-4a6b-9bf0-a7cf1d38c3a0"
/>
2025-10-02 10:08:24 -07:00
Mitchell Hashimoto
f11a4f7a68 Convert framegen to C, add compressed data to source tarball (#8989)
Zig 0.15 removed the ability to compress from the stdlib, which makes
porting our framegen tool to Zig 0.15+ more work than it's worth. We
already depend on and have the ability to build zlib, and Zig is a full
blown C compiler, so let's just use C.

The framegen C program doesn't free any memory, because it is meant to
exit quickly. It otherwise behaves pretty much the same as the old Zig
codebase.

The build scripts were modified to build the C program and run it, but
also to include the framedata in the generated source tarball so that
downstream packagers don't have to do this (although they'll have all
the deps anyways).

**AI disclosure:** The Zig to C conversion was done by Amp. I know C and
reviewed the code. The build system improvements are partially done by
Amp as well but I finished it all out. I've reviewed everything. Full
thread:
https://ampcode.com/threads/T-4e0a80af-3d2a-48d6-bf59-3e2f05eb7673
2025-10-02 06:57:50 -07:00
Daniel Wennberg
85c879f112 fix(font): Let powerline glyphs be wide 2025-10-02 00:12:00 -07:00
Mitchell Hashimoto
1ec74f8e39 Convert framegen to C, add compressed data to source tarball
Zig 0.15 removed the ability to compress from the stdlib, which makes
porting our framegen tool to Zig 0.15+ more work than it's worth. We
already depend on and have the ability to build zlib, and Zig is a full
blown C compiler, so let's just use C.

The framegen C program doesn't free any memory, because it is meant to
exit quickly. It otherwise behaves pretty much the same as the old Zig
codebase.

The build scripts were modified to build the C program and run it, but
also to include the framedata in the generated source tarball so that
downstream packagers don't have to do this (although they'll have all
the deps anyways).
2025-10-01 14:03:49 -07:00
Mitchell Hashimoto
a5aff0e347 feat: add GHOSTTY_BIN_DIR to path via shell integration (#8976)
Closes #8956

Elvish written by Copilot, the rest was written by me with AI
documentation.
2025-10-01 07:52:12 -07:00
Jon Parise
6f596ee7c3 shell-integration: append $GHOSTTY_BIN_DIR to $PATH
For consistency with the termio/Exec.zig implementation, we always
append to the PATH (lowest priority).
2025-10-01 10:42:33 -04:00
Jon Parise
4989f92c71 shell-integration: remove redundant comments
I think the conditions are sufficiently self-descriptive.
2025-10-01 10:27:42 -04:00
Mitchell Hashimoto
d7cfc51a4e build: isolate XCFramework.Target so runtime code doesn't depend on it (#8983)
This fixes the lazyImport importing outside of the build root. The build
root for the build binary is always the root `build.zig` (which we
want), but our `src/build_config.zig` transitively imported SharedDeps
which led to issues with Zig 0.15.

This back ports to main early (outside our Zig 0.15 PR) because its
compatible and will simplify that one.
2025-10-01 07:18:05 -07:00
Mitchell Hashimoto
09e4c1e6f2 build: isolate XCFramework.Target so runtime code doesn't depend on it
This fixes the lazyImport importing outside of the build root. The build
root for the build binary is always the root `build.zig` (which we
want), but our `src/build_config.zig` transitively imported SharedDeps
which led to issues.
2025-10-01 07:04:54 -07:00
Matthew Hrehirchuk
9407e0fd0d fix: cleaned up elvish and fish integrations for bin_dir 2025-09-30 22:26:07 -06:00
Daniel Wennberg
3feff75c99 Add proper Zig stdlib attribution 2025-09-30 13:58:41 -07:00
Daniel Wennberg
26b70e3125 Implement and use generic approx equality tester 2025-09-30 12:38:29 -07:00
Mitchell Hashimoto
f41e61cd31 nuke ziglyph from orbit (#8978)
Since we now use uucode, we don't need ziglyph anymore. Ziglyph was kept
around as a test-only dep so we can verify matching but this is
complicating our Zig 0.15 upgrade because ziglyph doesn't support Zig
0.15. Let's just drop it.

cc @jacobsandlund
2025-09-30 12:22:10 -07:00
Mitchell Hashimoto
16deea2761 nuke ziglyph from orbit
Since we now use uucode, we don't need ziglyph anymore. Ziglyph was kept
around as a test-only dep so we can verify matching but this is
complicating our Zig 0.15 upgrade because ziglyph doesn't support Zig
0.15. Let's just drop it.
2025-09-30 12:17:10 -07:00
Matthew Hrehirchuk
4cc663fc60 feat: add GHOSTTY_BIN_DIR to path via shell integration 2025-09-30 11:26:20 -06:00
Mitchell Hashimoto
ceac472af0 Revert "renderer: slightly optimize screen copy" (#8974)
This reverts commit fcea09e413 because it
appears to be causing memory leaks.
2025-09-30 09:29:00 -07:00
Jeffrey C. Ollie
86fb03677a Revert "renderer: slightly optimize screen copy"
This reverts commit fcea09e413.
2025-09-30 11:07:25 -05:00
Mitchell Hashimoto
150fb18ca1 Inline All The Things (#8946)
I used the new CPU counter mode in Instruments.app to track down
functions that had instruction delivery bottlenecks (indicating i-cache
misses) and picked a bunch of trivial functions to mark as inline (plus
a couple that are only used once or twice and which benefit from
inlining).

The size of `macos-arm64/libghostty-fat.a` built with `zig build
-Doptimize=ReleaseFast -Dxcframework-target=native` goes from
`145,538,856` bytes on `main` to `145,595,952` on this branch, a
negligible increase.

These changes resulted in some pretty sizable improvements in vtebench
results on my machine (Apple M3 Max):
<img width="983" height="696" alt="image"
src="https://github.com/user-attachments/assets/cac595ca-7616-48ed-983c-208c2ca2023f"
/>

With this, the only vtebench test we're slower than Alacritty in (on my
machine, at 130x51 window size) is `dense_cells` (which, IMO, is so
artificial that optimizing for it might actually negatively impact real
world performance).

I also did a pretty simple improvement to how we copy the screen in the
renderer, gave it its own page pool for less memory churn. Further
optimization in that area should be explored since in some scenarios it
seems like as much as 35% of the time on the `io-reader` thread is spent
waiting for the lock.

> [!NOTE]
> Before this is merged, someone really ought to test this on an x86
processor to see how the performance compares there, since this *is*
tuning for my processor specifically, and I know that M chips have
pretty big i-cache compared to some x86 processors which could impact
the performance characteristics of these changes.
2025-09-30 08:13:39 -07:00
Qwerasd
c57c205672 fix test failures
Very weird failures, not 100% sure of the cause; regardless, this fixes
them.
2025-09-30 07:27:40 -07:00
Qwerasd
0388a2b396 terminal: inline all the things
A whole bunch of inline annotations, some of these were tracked down
with Instruments.app, others are guesses / just seemed right because
they were trivial wrapper functions.

Regardless, these changes are ultimately supported by improved vtebench
results on my machine (Apple M3 Max).
2025-09-30 07:27:40 -07:00
Qwerasd
43dd712053 termio: make trivial stream handler callbacks inline
Supported by benchmarks (vtebench on Apple M3 Max)
2025-09-30 07:27:40 -07:00
Qwerasd
4136c469fa datastruct: make trivial linked list ops inline
Supported by benchmarks (vtebench on Apple M3 Max)
2025-09-30 07:27:40 -07:00
Qwerasd
fcea09e413 renderer: slightly optimize screen copy
Changes it so that the renderer retains its own MemoryPool for PageList
pages so that new pages rarely need to be allocated when cloning the
screen. Also switches to using an arena allocator in `updateFrame` to
avoid having to deinit the cloned screen since instead we can just throw
out the memory.
2025-09-30 07:27:40 -07:00