Commit Graph

7451 Commits

Author SHA1 Message Date
Mitchell Hashimoto
950d3755ff renderer/opengl: minimum contrast for black sets proper color (#8782)
Fixes #8745

When rendering black for minimum contrast we were setting opacity to 0
making it invisible.
2025-09-19 09:58:50 -07:00
Mitchell Hashimoto
c42ed70758 renderer/opengl: minimum contrast for black sets proper color
Fixes #8745

When rendering black for minimum contrast we were setting opacity to 0
making it invisible.
2025-09-19 09:45:08 -07:00
Jeffrey C. Ollie
f375ec7c65 gtk: add glib log writer function
This will funnel GLib/GObject/GTK logging messages through Zig's logging
system rather than just dumping them directly to stderr.
2025-09-19 09:35:35 -05:00
Mitchell Hashimoto
b9a5cad562 build: explicitly suffix Zig files 2: Electric Boogaloo (#8769)
Of *course* I missed one
2025-09-18 16:58:50 -07:00
Leah Amelia Chen
6d2576abee build: explicitly suffix Zig files 2: Electric Boogaloo
Of *course* I missed one
2025-09-19 01:23:06 +02:00
عبد الرحمن صباهي
d6e58ef1fc slightly improve logs 2025-09-19 01:00:17 +03:00
Leah Amelia Chen
9b40e03c40 build: explicitly suffix generated Zig source files
Previously we're just feeding the compiler source files generated via
capturing stdout, which all by default have the filename `stdout`.
Under some particular yet uncertain circumstances in Zig 0.14 (only
factor we've found so far is a large amount of cores/compilation shards)
the compiler will actually crash on an unreachable code path that assumes
all source files either end in .zig or .zon, causing crashes for packagers
for distros like Nixpkgs and Gentoo.

Given this has been explicitly made illegal in Zig 0.15
(see ziglang/zig#24957) I don't really see why we shouldn't fix this for
1.2 too. We have to do this at some point no matter what anyways.
2025-09-18 23:02:03 +02:00
Mitchell Hashimoto
92effb37db documentation: fix MacOSDockDropBehavior valid values (#8752)
The documentation shows that the enum values should be "new-window" and
"new-tab",
However, "new-window" currently fails, but "window" is still accepted.
2025-09-18 12:46:54 -07:00
Mitchell Hashimoto
a453681615 renderer: create explicit sampler state for custom shaders
The GLSL to MSL conversion process uses a passed-in sampler state for
the `iChannel0` parameter and we weren't providing it. This magically
worked on Apple Silicon for unknown reasons but failed on Intel GPUs.

In normal, hand-written MSL, we'd explicitly create the sampler state as
a normal variable (we do this in `shaders.metal` already!), but the
Shadertoy conversion stuff doesn't do this, probably because the exact
sampler parameters can't be safely known.

This fixes a Metal validation error when using custom shaders:

```
-[MTLDebugRenderCommandEncoder validateCommonDrawErrors:]:5970: failed 
assertion `Draw Errors Validation Fragment Function(main0): missing Sampler 
binding at index 0 for iChannel0Smplr[0].
```
2025-09-18 09:25:37 -07:00
Matthias von Arx
a22a1771b5 documentation: fix MacOSDockDropBehavior valid values 2025-09-18 18:09:10 +02:00
Mitchell Hashimoto
cb0e60c3e5 renderer/metal: provide MTLTextureUsage render target for custom shaders
This fixes a Metal validation error in Xcode when using custom shaders. 
I suspect this is one part of custom shaders not working properly on
Intel macs (probably anything with a discrete GPU).

This happens to work on Apple Silicon but this is undefined behavior and
we're just getting lucky.

There is one more issue I'm chasing down that I think is also still
blocking custom shaders working on Intel macs.
2025-09-18 07:29:26 -07:00
Daniel Wennberg
6781fbda93 Measure ascii height and use to upper bound ic_width 2025-09-17 12:44:42 -07:00
Mitchell Hashimoto
4f47138ea3 selection scrolling should only depend on y value
Fixes #8683

The selection scrolling logic should only depend on the y value of the
cursor position, not the x value. This presents unwanted scroll
behaviors, such as reversing the scroll direction which was just a side
effect of attempting to scroll tick to begin with.
2025-09-16 16:33:49 -07:00
Mitchell Hashimoto
67992fde91 font-size reloads at runtime if the font wasn't manually set
This was a very common pitfall for users. The new logic will reload the
font-size at runtime, but only if the font wasn't manually set by the
user using actions such as `increase_font_size`, `decrease_font_size`,
or `set_font_size`. The `reset_font_size` action will reset our state
to assume the font-size wasn't manually set.

I also updated a comment about `font-family` not reloading at runtime;
this wasn't true even prior to this commit.
2025-09-16 15:39:34 -07:00
Mitchell Hashimoto
f7e622e8af config: fix binding parsing to allow values containing =
Fixes #8667

The binding `a=text:=` didn't parse properly.

This is a band-aid solution. It works and we have test coverage for it
thankfully. Longer term we should move the parser to a fully
state-machine based parser that parses the trigger first then the
action, to avoid these kind of things.
2025-09-16 13:53:16 -07:00
Mitchell Hashimoto
a32d4988f7 config: update theme names in docs (#8655)
They were renamed, see:
https://github.com/mbadolato/iTerm2-Color-Schemes/commits/master/ghostty/Rose%20Pine
2025-09-16 07:01:43 -07:00
Mitchell Hashimoto
07243789be docs: add lacking version information (#8653)
According to the release note
(https://ghostty.org/docs/install/release-notes/1-2-0#quick-terminal-size),
`quick-terminal-size` option is available since 1.2.0.
At first, I opened a PR in ghostty-org/website
(https://github.com/ghostty-org/website/pull/370). Then the bot
commented that the part was auto-generated content, so I created this
PR.
2025-09-16 06:05:19 -07:00
Simon Olofsson
fd03a146ba config: update theme names in docs
They were renamed, see: https://github.com/mbadolato/iTerm2-Color-Schemes/commits/master/ghostty/Rose%20Pine
2025-09-16 10:37:24 +02:00
カワリミ人形
a92a237b80 docs: add lacking version information
`quick-terminal-size` option is available since 1.2.0
2025-09-16 16:13:56 +09:00
rhodes-b
1397c76243 mark ssh shell-integration wrapper as a function this matches other features + fixes a case where users alias to some other command 2025-09-15 21:49:48 -05:00
dmunozv04
c6143a1539 Docs: add undo-timeout configuration setting name 2025-09-15 22:55:01 +02:00
Mitchell Hashimoto
1201bc27d2 bump the version for development 2025-09-15 11:01:14 -07:00
Mitchell Hashimoto
510f4e474c Set version to 1.2.0 2025-09-15 08:25:54 -07:00
Mitchell Hashimoto
d7c2a829bb termio: don't send extra OSC terminator for color reports
Fixes #8613

I reiterate my comment in my own PR that this needs to be extracted so
we can unit test this. :)
2025-09-12 21:19:16 -07:00
Mitchell Hashimoto
a19aa0a398 terminal: OSC 104 with no semicolon should parse as reset palette
https://github.com/ghostty-org/ghostty/pull/8590#issuecomment-3287418867
2025-09-12 21:10:07 -07:00
azhn
ac07cf5270 Use ghostty-specific themes release 2025-09-13 06:52:44 +10:00
Mitchell Hashimoto
db24f9715b Position-independent font shaper caching (#8555)
Use relative cluster positioning to allow identical texts runs in
different row positions to share the same cache entry.

I am opening this PR clean w/o the cache size change. There could be
some benefit to a larger 256->512 shaper cache, but this still performs
amazingly well and I don't know the full memory impacts of moving the
cache size up.


https://github.com/ghostty-org/ghostty/discussions/8547#discussioncomment-14329590
2025-09-12 07:27:21 -07:00
Mitchell Hashimoto
3afc8019d5 terminal: update parser to use new color parser and stream handler 2025-09-11 12:32:31 -07:00
Mitchell Hashimoto
67b7a5f267 terminal: osc 104/105 are more flexible on invalid index 2025-09-11 11:38:45 -07:00
Mitchell Hashimoto
03e2a8049e terminal: remove old color tests 2025-09-11 11:34:17 -07:00
Mitchell Hashimoto
4350804f0a terminal: osc 10-19 should use next function 2025-09-11 11:27:26 -07:00
Mitchell Hashimoto
83dd578cc5 terminal: osc 104/105 2025-09-11 11:20:54 -07:00
Mitchell Hashimoto
d7523e3e37 terminal: OSC 10-19 2025-09-11 11:12:03 -07:00
Mitchell Hashimoto
b4fdefc2c0 terminal: OSC 4/5 matches xterm 2025-09-11 10:58:55 -07:00
Mitchell Hashimoto
aba8981d28 terminal: make dedicated OSC parsing, do dynamic resets 2025-09-11 10:08:43 -07:00
Mitchell Hashimoto
4717f8d22b terminal: special/dynamic color enums 2025-09-11 07:35:32 -07:00
Yaacov Akiba Slama
b4ecadf2e9 Add default bindings for the "copy" and "paste" keyboard keys.
These keys are present in some old unix keyboards, but more importantly,
their keycodes can be mapped to physical keys in modern programmable
keyboards.
Using them in Linux is a way to be able to have the same keys for
copy/pasting in GUI apps and in terminal apps instead of switching between
ctrl-c/ctrl-v and ctrl-shift-c/ctrl-shift-v.
2025-09-11 12:17:49 +03:00
Misairuzame
5aac5a764b i18n: add Italian translation (#7074) 2025-09-10 18:17:48 +00:00
Cheru Berhanu
be6cb0f6ce terminal: fix test w/ freed config
this test previously didn't fail when accessing freed members of config
because deiniting `command_arena` was a no-op; `command_arena` was derived
from `arena`, which allocated memory after `command_arena` was created/used
2025-09-09 12:31:49 -05:00
Jacob Sandlund
77b4c52634 [benchmarks] Align buf to cache line for consistency 2025-09-08 17:59:17 -04:00
Qwerasd
31e54ff44a comment + style changes 2025-09-08 10:40:56 -06:00
Jesse Miller
ecf3e2ad7d Position-independent font shaper caching
Use relative cluster positioning to allow identical texts runs in
different row positions to share the same cache entry.
2025-09-07 16:33:35 -06:00
Qwerasd
fdd22ec786 fix(terminal): move cursor left if VS15 makes cell narrow
Without this change, a phantom space appears after any character with
default emoji presentation that is converted to text with VS15. The only
other terminal I know of that respects variation selectors is Kitty, and
it walks the cursor back, which feels like the best choice, since that
way the behavior is observable (no way to know if the terminal supports
variation selectors otherwise without hard-coding that info per term)
and "dumb" programs like `cat` will output things correctly, and not
gain a phantom space after any VS15'd emoji.
2025-09-06 13:46:14 -07:00
Mitchell Hashimoto
ae7061efb0 [benchmarks] Use std.mem.doNotOptimizeAway to avoid data collisions (#8548)
I've been playing with benchmarks over in my [branch swapping out
ziglyph for
uucode](https://github.com/ghostty-org/ghostty/compare/main...jacobsandlund:jacob/uucode?expand=1),
and I ran into an interesting issue where benchmarks were giving odd
numbers.

TL;DR: writing to `buf[0]` ends up slowing down the benchmark in
inconsistent ways because it's the same buffer that's being written and
read in the loop, so switching to `std.mem.doNotOptimizeAway` fixes
this.

## Full story:

I ran the `codepoint-width` benchmark with the following (and also did
similarly for `grapheme-bench` and `is-symbol`):

```
zig-out/bin/ghostty-gen +utf8 | head -c 200000000 > data.txt
hyperfine --warmup 4 'zig-out/bin/ghostty-bench +codepoint-width --data=data.txt --mode=table' 'zig-out/bin/ghostty-bench +codepoint-width --data=data.txt --mode=uucode'
```

... and I was surprised to see that `uucode` was 3% slower than Ghostty,
despite similar implementations. I debugged this, bringing the `uucode`
implementation to the exact same assembly (minus offsets) as Ghostty,
even re-using the same table data (fun fact I learned is that even
though these tables are large, zig or LLVM saw they were byte-by-byte
equivalent and optimized them down to one table). Still though, 3%
slower.

Then I realized that if I wrote to a separate `buf` on `self` the
difference went away, and I figured out it's this writing to `buf[0]`
that is tripping up the CPU, because in the next outer loop it'll write
over that again when reading from the data file, and then it's read as
part of getting the code point.

### with buf[0]

```
Benchmark 1: zig-out/bin/ghostty-bench +codepoint-width --data=data.txt --mode=table
  Time (mean ± σ):     944.7 ms ±   0.8 ms    [User: 900.2 ms, System: 42.8 ms]
  Range (min … max):   943.4 ms … 945.9 ms    10 runs

Benchmark 2: zig-out/bin/ghostty-bench +codepoint-width --data=data.txt --mode=uucode
  Time (mean ± σ):     974.0 ms ±   0.7 ms    [User: 929.3 ms, System: 43.1 ms]
  Range (min … max):   973.3 ms … 975.2 ms    10 runs

Summary
  zig-out/bin/ghostty-bench +codepoint-width --data=data.txt --mode=table ran
    1.03 ± 0.00 times faster than zig-out/bin/ghostty-bench +codepoint-width --data=data.txt --mode=uucode
```

### with mem.doNotOptimizeAway

```
Benchmark 1: zig-out/bin/ghostty-bench +codepoint-width --data=data.txt --mode=table
  Time (mean ± σ):     929.4 ms ±   2.7 ms    [User: 884.8 ms, System: 43.0 ms]
  Range (min … max):   926.7 ms … 936.3 ms    10 runs

Benchmark 2: zig-out/bin/ghostty-bench +codepoint-width --data=data.txt --mode=uucode
  Time (mean ± σ):     931.2 ms ±   2.5 ms    [User: 886.6 ms, System: 42.9 ms]
  Range (min … max):   927.3 ms … 935.7 ms    10 runs

Summary
  zig-out/bin/ghostty-bench +codepoint-width --data=data.txt --mode=table ran
    1.00 ± 0.00 times faster than zig-out/bin/ghostty-bench +codepoint-width --data=data.txt --mode=uucode
```

### with buf[0], mode = .uucode

Another interesting thing is that with `buf[0]`, it's highly dependent
on the offsets somehow. If I switched the default mode line from `mode:
Mode = .noop` to `mode: Mode = .uucode`, it shifts the offsets ever so
slightly and even though that default mode is not getting used (since
it's passed in), it flips the results of the benchmark around:

```
Benchmark 1: zig-out/bin/ghostty-bench +codepoint-width --data=data.txt --mode=table
  Time (mean ± σ):     973.3 ms ±   2.2 ms    [User: 928.9 ms, System: 42.9 ms]
  Range (min … max):   968.0 ms … 975.9 ms    10 runs

Benchmark 2: zig-out/bin/ghostty-bench +codepoint-width --data=data.txt --mode=uucode
  Time (mean ± σ):     945.8 ms ±   1.4 ms    [User: 901.2 ms, System: 42.8 ms]
  Range (min … max):   943.5 ms … 948.5 ms    10 runs

Summary
  zig-out/bin/ghostty-bench +codepoint-width --data=data.txt --mode=uucode ran
    1.03 ± 0.00 times faster than zig-out/bin/ghostty-bench +codepoint-width --data=data.txt --mode=table
```

looking at the assembly with `mode: Mode = .noop`:

```
# table.txt:

   165 	                // away
** 166 	                buf[0] = @intCast(width);

ghostty-bench[0x100017370] <+508>: strb   w11, [x21, #0x4]
ghostty-bench[0x100017374] <+512>: b      0x100017288               ; <+276> at CodepointWidth.zig:168:9
ghostty-bench[0x100017378] <+516>: mov    w0, #0x0                  ; =0 

# uucode.txt:

** 229 	                buf[0] = @intCast(width);

ghostty-bench[0x1000177bc] <+508>: strb   w11, [x21, #0x4]
ghostty-bench[0x1000177c0] <+512>: b      0x1000176d4               ; <+276> at CodepointWidth.zig:231:9
ghostty-bench[0x1000177c4] <+516>: mov    w0, #0x0                  ; =0 
```

vs `mode: Mode = .uucode`:

```
# table.txt:

** 166 	                buf[0] = @intCast(width);

ghostty-bench[0x100017374] <+508>: strb   w11, [x21, #0x4]
ghostty-bench[0x100017378] <+512>: b      0x10001728c               ; <+276> at CodepointWidth.zig:168:9
ghostty-bench[0x10001737c] <+516>: mov    w0, #0x0                  ; =0 

# uucode.txt:

** 229 	                buf[0] = @intCast(width);

ghostty-bench[0x1000177c0] <+508>: strb   w11, [x21, #0x4]
ghostty-bench[0x1000177c4] <+512>: b      0x1000176d8               ; <+276> at CodepointWidth.zig:231:9
ghostty-bench[0x1000177c8] <+516>: mov    w0, #0x0                  ; =0 
```

... shows the only difference is the offsets, which somehow have a large
impact on the result of the benchmark.
2025-09-06 12:48:40 -07:00
Jacob Sandlund
113e89b389 [benchmarks] Use std.mem.doNotOptimizeAway to avoid data collisions 2025-09-06 15:06:00 -04:00
Mitchell Hashimoto
6e1d6f3afe config: probable cli should return false on macOS for desktop launch
Fixes #8542

The comment explains why this is needed.
2025-09-06 07:09:09 -07:00
Mitchell Hashimoto
e4c3a56242 Micro-optimize GlyphKey Context (#8536)
Use fast hash function on key for better distribution.

Direct compare glyph in eql to avoid Packed.from() if not neccessary.

16% -> 6.4% reduction during profiling runs.
2025-09-05 15:25:14 -07:00
Jesse Miller
cf39d5c512 Glphkey.hash CityHash64 -> hash.int 2025-09-05 15:21:47 -07:00
Mitchell Hashimoto
6b21662219 Fix off-by-one error & adjust overline pos in cell height mod (#8022)
I noticed that there was an off-by-one error in cell height adjustment
when the number of pixels to add/subtract is odd. The metrics measured
from the top would be shifted by one less than they should, so, for
example, the underline position would move one pixel closer to the
baseline than it had been (or one pixel further away if subtracting).

Also noticed that the overline position was missing here, so added that.
2025-09-05 13:10:17 -07:00
Jesse Miller
8824256059 Micro-optimize GlyphKey Context
Use fast hash function on key for better distribution.

Direct compare glyph in eql to avoid Packed.from() if not neccessary.

16% -> 6.4% reduction during profiling runs.
2025-09-05 13:37:39 -06:00