9431 Commits

Author SHA1 Message Date
Yappaholic
3423cfdc71 Fix elvish sudo integration and update documentation 2025-03-23 14:31:55 -07:00
Mikhail Borisov
b2a8211f9e Fix Terminal Inspector option turns inactive if toggled in the Quick Terminal 2025-03-23 14:31:19 -07:00
Bryan Lee
f1c510f9fe Make equalize_splits action only affect current window 2025-03-23 14:29:36 -07:00
Mitchell Hashimoto
3264051f8d apprt/embedded: utf8 encoding buffer lifetime must extend beyond call
Fixes #6821

UTF8 translation using KeymapDarwin requires a buffer and the buffer was
stack allocated in the coreKeyEvent call and returned from the function.
We need the buffer to live longer than this.

Long term, we're removing KeymapDarwin (there is a whole TODO comment in
there about how to do it), but this fixes a real problem today.
2025-03-23 14:28:37 -07:00
Mitchell Hashimoto
b2ad90fe18 apprt/gtk: any preedit change should note a composing state
Fixes #6772

When typing Korean with the fcitx5-hangful input method, moving between
graphemes does not trigger a preedit end/start cycle and instead just
clears the preexisting preedit and reuses the started state.

Every other input method we've tested up until now doesn't do this. We
need to mark composing set to "false" in "commit" because some input
methods on the contrary fail to ever call END.

What is the point of start/end events if they are just ignored depending
on the whim of the input method? Nothing. That's what. Its all a mess
that GTK should be protecting us from but it doesn't and now its the app
developer's problem. I'm frustrated because I feel like the point of an
app framework is to mask this kind of complexity from the app developer
and I'm playing whack-a-mole with input methods.

Well, here's another whack. Let's see if it works.
2025-03-23 14:26:10 -07:00
Qwerasd
9d5e64a76f fix(Metal): force a full rebuild in setFontGrid
This was causing garbled text due to a non-rebuilt rows referencing an
outdated atlas when the DPI changed but not the grid dimensions, which
could be caused by a variety of things such as the quick terminal
slide-in, dpi scaling changes on sleep/wake, moving windows between
displays because of closing/opening the laptop lid, etc.
2025-03-23 14:23:10 -07:00
Mitchell Hashimoto
691fbccbfc terminal: increase CSI max params to 24 to accept Kakoune sequence
See #5930

Kakoune sends a real SGR sequence with 17 parameters. Our previous max
was 16 so we through away the entire sequence. This commit increases the
max rather than fundamentally addressing limitations.

Practically, it took us this long to witness a real world sequence that
exceeded our previous limit. We may need to revisit this in the future,
but this is an easy fix for now.

In the future, as the comment states in this diff, we should probably
look into a rare slow path where we heap allocate to accept up to some
larger size (but still would need a cap to avoid DoS). For now,
increasing to 24 slightly increases our memory usage but shouldn't
result in any real world issues.
2025-03-23 14:21:33 -07:00
rhodes-b
92bd6b6244 dont use shift+equal combo 2025-03-23 14:19:38 -07:00
Tim Culverhouse
ccf72dfbf7 termio: use modified backend
In Termio.init, we make a copy of backend and modify it by calling
initTerminal. However, we used the original in the struct definition.
This lead to the pty being opened with a size 0,0.
2025-03-23 14:18:48 -07:00
Tim Culverhouse
196bc55757 termio: prevent responses to non-query OSC 21 sequences
The Ghostty implementation of OSC 21 (Kitty color protocol) currently
responds to *all* OSC 21 sequences. It should not respond to a set, nor
a reset command. Fix the implementation so that we only respond if a
query was received.
2025-03-23 14:18:13 -07:00
David Wales
f458d48f9b gtk: work around oversized drag handle for GtkPaned
Improves #3020.

Based on recommendation from upstream Gtk issue:
https://gitlab.gnome.org/GNOME/gtk/-/issues/4484#note_2362002

Without this, it's not possible to select the first character on the
right-hand side of a split.
2025-03-23 14:15:18 -07:00
Maciej Bartczak
adf7c87cb2 gtk: update the window title when grabbing tab focus 2025-03-23 14:13:47 -07:00
Mitchell Hashimoto
c9ca09af90 update build.zig.zon.nix 2025-03-23 14:04:59 -07:00
Mitchell Hashimoto
e30b5efd5d apprt/gtk: make GL context current in unrealize
Fixes #6872

This commit explicitly acquires the GL context in the `unrealize`
signal handler of the GTK Surface prior to cleaning up GPU resources.

A GLArea only guarantees that the associated GdkContext is current for
the `render` signal (see the docs[1]). This is why our OpenGL renderer
"defers" various operations such as resize, font grid changing, etc.
(see the `deferred_`-prefix fields in `renderer/OpenGL.zig`).
However, we missed a spot.

The `gtk-widget::unrealize` signal is emitted when the widget is
destroyed, and it is the last chance we have to clean up our GPU
resources. But it is not guaranteed that the GL context is current at
that point, and we weren't making it current. On the NGL GTK renderer,
this was freeing GPU resources we didn't own.

As best I can understand, the old GL renderer only ever used a handful
of GL resources that were early in the ID space, so by coincidence we
were probably freeing nothing and everything was fine. But with the new
NGL renderer uses a LOT more GL resources (make a few splits and the ID
space is already in the thousands, from GTK!), so we were freeing real
resources that we didn't own, which caused rendering issues. :)

I suspect the above also resulted in VRAM memory leaks (which would be
RAM memory leaks for unified memory GPUs). This potentially relates to

The fix is to explicitly make the GL context current in the `unrealize`
handler.

[1]: https://docs.gtk.org/gtk4/method.GLArea.make_current.html
2025-03-23 14:04:59 -07:00
Mitchell Hashimoto
67650c273a up versions for development 2025-03-23 13:47:56 -07:00
Mitchell Hashimoto
ee963f6296 macOS: fix invalid kitty keyboard encoding of control characters (#5747)
Fixes #5743 

This fixes a terrible regression where by fixing one issue we introduced
another, and the other is that ctrl keys didn't work with programs with
Kitty keyboard protocol.

The problem is that our fix blindly assumed control was always consumed
for translation, which is obviously wrong but I didn't think there'd be
downstream effects. The reality is that we need to be more accurate.

This PR makes it so that:

* If macOS provides us with UTF-8 text, we assume all mods were involved
except super
* If macOS does not provide us with UTF-8 text, we use whatever
UCKeyTranslate consumed
* We never allow UCKeyTranslate to consume control because it turns it
into the masked ASCII value and we don't want that.

The only _new_ behavior which fixes the bug is point 2 above. 

Tested:

  1. Dvorak Ctrl characters
  2. Ergo-L Ctrl characters
  3. US standard Ctrl characters
  4. Japanese IME input Ctrl input to modify IME state
5. Ctrl keybindings with Kitty keyboard protocol in both Kitty and
Neovim
v1.1.2
2025-02-13 15:03:54 -08:00
Mitchell Hashimoto
b44b1086d3 apprt/embedded: proper consumed modifier state for ctrl keys 2025-02-13 14:58:41 -08:00
Mitchell Hashimoto
9978ea3b9c Revert "macos: don't remove ctrl modifier for text input"
This reverts commit 3104b217581a9e580155216a260b1a79135b701a.
2025-02-13 14:20:13 -08:00
Mitchell Hashimoto
710ea1c8d9 up all the metadata to 1.1.2 2025-02-13 13:02:06 -08:00
Mitchell Hashimoto
ed60e07257 apprt: require envmap for exec-based termio (#5742)
Supercedes #5726
v1.1.1
2025-02-13 12:27:13 -08:00
Mitchell Hashimoto
1fea8028a3 apprt: require envmap for exec-based termio
Supercedes #5726
2025-02-13 12:26:11 -08:00
Mitchell Hashimoto
c481bdf704 macos: make goto_split, goto_tab, and move_tab performable (#5740)
Fixes #5552

This makes the mentioned actions performable. This isn't perfect, but it
does so in a way that resolves the user issue in #5552. This commit
returns an action is NOT performed if it doesn't have splits or tabs
(respectiely for the actions), but also reports its ALWAYS performed if
it does.

This latter logic isn't accurate: we should only return performable if
it was actually done. So for example, goto_split:top should do nothing
if we're already at the top. But, we report it as performed today.

This is good enough to resolve the issue and fix the core problem faced
for 1.1.0.
2025-02-13 10:59:04 -08:00
Mitchell Hashimoto
5105c52ef7 macos: make goto_split, goto_tab, and move_tab performable
Fixes #5552

This makes the mentioned actions performable. This isn't perfect, but it
does so in a way that resolves the user issue in #5552. This commit
returns an action is NOT performed if it doesn't have splits or tabs
(respectiely for the actions), but also reports its ALWAYS performed if
it does.

This latter logic isn't accurate: we should only return performable if
it was actually done. So for example, goto_split:top should do nothing
if we're already at the top. But, we report it as performed today.

This is good enough to resolve the issue and fix the core problem faced
for 1.1.0.
2025-02-13 10:40:07 -08:00
Mitchell Hashimoto
20dcae876d macos: don't remove ctrl modifier for text input (#5738)
Fixes #5448

We previously removed the ctrl modifier for text commit (IME-style) to
workaround a libghostty quirk (as noted in the comment in the diff). But
this broke other keyboard layouts.

This commit attempts to clean this up slightly -- but not completely --
by removing that hack, and only modifying the ctrl behavior for the
UCKeyTranslate call.

Long term, I plan to remove UCKeyTranslate completely, as noted in the
todo comment already written just below this diff.

This fixes the aforementioned issue and hopefully doesn't regress any
other behavior. I tested the following:

  1. Dvorak Ctrl characters
  2. Ergo-L Ctrl characters
  3. US standard Ctrl characters
  4. Japanese IME input Ctrl input to modify IME state
2025-02-13 09:51:26 -08:00
Mitchell Hashimoto
3104b21758 macos: don't remove ctrl modifier for text input
Fixes #5448

We previously removed the ctrl modifier for text commit (IME-style)
to workaround a libghostty quirk (as noted in the comment in the diff).
But this broke other keyboard layouts.

This commit attempts to clean this up slightly -- but not completely --
by removing that hack, and only modifying the ctrl behavior for the
UCKeyTranslate call.

Long term, I plan to remove UCKeyTranslate completely, as noted in the
todo comment already written just below this diff.

This fixes the aforementioned issue and hopefully doesn't regress any
other behavior. I tested the following:

  1. Dvorak Ctrl characters
  2. Ergo-L Ctrl characters
  3. US standard Ctrl characters
  4. Japanese IME input Ctrl input to modify IME state
2025-02-13 09:43:07 -08:00
Mitchell Hashimoto
15e41959eb Eliminate tab content flickering during tab movement on macOS (#5729)
Fixes https://github.com/ghostty-org/ghostty/issues/5689

The flickering was caused by uncontrolled visual updates during tab
reordering. The fix uses `NSAnimationContext` to batch all visual
changes together and simplifies window focus handling to prevent
unnecessary redraws.


https://github.com/user-attachments/assets/2a6525cd-8a97-418b-8442-18dab6b4636d
2025-02-13 09:24:41 -08:00
Mitchell Hashimoto
783f4014f8 build: replace codeberg dep with self-hosted mirror (#5736)
The content hashes match so if users don't trust us they can grab from
upstream.
2025-02-13 09:24:30 -08:00
Mitchell Hashimoto
2a29f71b2c draw octants directly rather than relying on font (#5433)
* implement `yQuads()` and `draw_octant()`, pretty obvious extensions of
existing code. to allocate up to 3 potential remainder lines, consider
that octants will often appear in a rectangular subset of the terminal.
we want the distributed excess uniformly distributed across such a
region. so:
* one excess row: break symmetry in any direction (pick an arbitrary
tetrad and use it everywhere)
  * two excess rows: go to alternating tetrads
* three excess rows: break symmetry, do not use three contiguous tetrads
* our `Octant`s are octary arrays of `bool`, provided as a somewhat
opaque constant table
* the 8-line copy-and-paste draw based on the `Octant` is not the
prettiest thing in the known universe
* we could generalize `draw_sextant()` and `draw_octant()` like
notcurses did, almost certainly
  * oh bird thou never wert
 

with that said, i don't think `draw_octant()` is actually being called
lol, so let's not merge this yet. happy to hear early feedback, though.
2025-02-13 09:21:11 -08:00
Mitchell Hashimoto
5919c57527 build: replace codeberg dep with self-hosted mirror
The content hashes match so if users don't trust us they can grab from
upstream.
2025-02-13 09:18:50 -08:00
nick black
8b2f9acfb4 Implement draw_octant() and yQuads() for U16.0 2025-02-13 09:08:33 -08:00
Mitchell Hashimoto
6f4716fd60 macOS: update additional references to Sparkle 2.6.3->2.6.4 (#5734) 2025-02-13 08:49:28 -08:00
Jeffrey C. Ollie
74f222abec macOS: update additional references to Sparkle 2.6.3->2.6.4 2025-02-13 10:35:38 -06:00
Jeffrey C. Ollie
9f6067d899 gtk: fix ui/blueprint builder (#5727)
fixes issues found while making use of the new builder api
2025-02-13 08:03:49 -06:00
Bryan Lee
f72fd32bf0 Eliminate tab content flickering during tab movement on macOS 2025-02-13 14:59:14 +08:00
Jeffrey C. Ollie
e396c8538a gtk: fix ui/blueprint builder 2025-02-12 22:16:33 -06:00
Jeffrey C. Ollie
432beac315 gtk: add support for using GTK Builder UI files and Blueprints (#5714)
Adds buildtime and comptime checks to make sure that Blueprints/UI files
are availble and correctly formed. Will also compile Blueprints to UI
files so that they are available to GTK code.
2025-02-12 19:10:50 -06:00
Mitchell Hashimoto
256281c5de terminal: reflow the saved cursor if we have one (#5720)
Fixes #5718

When a terminal is resized with text reflow (i.e. soft-wrapped text),
the cursor is generally reflowed with it.

For example, imagine a terminal window 5-columns wide and you type the
following without pressing enter. The cursor is on the X.

```
OOOOO
OOX
```

If you resize the window now to 8 or more columns, this happens, as
expected:

```
OOOOOOOX
```

As expected, the cursor remains on the "X". This behaves like any other
text input...

Terminals also provide an escape sequence to
[save the cursor (ESC 7 aka
DECSC)](https://ghostty.org/docs/vt/esc/decsc). This includes, amongst
other things, the cursor position. The cursor can be restored with
[DECRC](https://ghostty.org/docs/vt/esc/decrc).

The behavior of the position of the _saved cursor_ in the context of
text reflow is unspecified and varies wildly between terminals Ghostty
does this right now (as do many other terminals):

```
OOOOOOOO
   X
```

This commit changes the behavior so that we reflow the saved cursor.
2025-02-12 13:16:11 -08:00
Jeffrey C. Ollie
f63242f7fb gtk: add support for using GTK Builder UI files and Blueprints
Adds buildtime and comptime checks to make sure that Blueprints/UI files
are availble and correctly formed. Will also compile Blueprints to UI
files so that they are available to GTK code.
2025-02-12 15:05:42 -06:00
Mitchell Hashimoto
7dac9e02b3 terminal: reflow the saved cursor if we have one
Fixes #5718

When a terminal is resized with text reflow (i.e. soft-wrapped text), the cursor
is generally reflowed with it.

For example, imagine a terminal window 5-columns wide and you type the
following without pressing enter. The cursor is on the X.

```
OOOOO
OOX
```

If you resize the window now to 8 or more columns, this happens, as expected:

```
OOOOOOOX
```

As expected, the cursor remains on the "X". This behaves like any other text
input...

Terminals also provide an escape sequence to
[save the cursor (ESC 7 aka DECSC)](https://ghostty.org/docs/vt/esc/decsc).
This includes, amongst other things, the cursor position. The cursor can be
restored with [DECRC](https://ghostty.org/docs/vt/esc/decrc).

The behavior of the position of the _saved cursor_ in the context of text
reflow is unspecified and varies wildly between terminals Ghostty does this
right now (as do many other terminals):

```
OOOOOOOO
   X
```

This commit changes the behavior so that we reflow the saved cursor.
2025-02-12 10:34:31 -08:00
Jeffrey C. Ollie
99cbc06292 gtk: use the standard path for including Adwaita header file (#5716)
As pointed out by @tristan957 the standard path for including the
Adwaita header file is simply "adwaita.h". While it may have been
necessary in the past to use a non-standard include path, that no longer
appears to be the case.
2025-02-12 11:29:38 -06:00
Jeffrey C. Ollie
749bac3d72 gtk: use the standard path for including Adwaita header file
As pointed out by @tristan957 the standard path for including the
Adwaita header file is simply "adwaita.h". While it may have been
necessary in the past to use a non-standard include path, that no longer
appears to be the case.
2025-02-12 11:14:38 -06:00
Mitchell Hashimoto
1bb87e14a5 termio: free envmap when able, fix memory leak (#5715)
Caused by #5650

I actually don't understand how this didn't happen before or why we
didn't notice it but it seems like the envmap was never freed. In the
latest debug builds prior to this build GPA reports the leak.

We should free the envmap when the subprocess is deinitialized. But also
we can free the env map as soon as we start the subprocess which saves
some small amount of memory at runtime.

Additionally, we should only be freeing the envmap on error if we
created it.
2025-02-12 09:00:56 -08:00
Mitchell Hashimoto
9ea29dc508 termio: free envmap when able, fix memory leak
Caused by #5650

I actually don't understand how this didn't happen before or why we
didn't notice it but it seems like the envmap was never freed. In the
latest debug builds prior to this build GPA reports the leak.

We should free the envmap when the subprocess is deinitialized. But also
we can free the env map as soon as we start the subprocess which saves
some small amount of memory at runtime.

Additionally, we should only be freeing the envmap on error if we
created it.
2025-02-12 08:48:26 -08:00
Mitchell Hashimoto
f2f0c6b4e9 macOS: use Nix to get Zig deps (#5699)
This should help with API rate limits being hit by macOS builders since
they can't use the Namespace cache that Linux builders can use to cache
Zig dependencies. It will need to be run by Mitchell once so that the
Cachix action can push everything up to the cache and then the full
benefits should be seen. Not sure how using `--system` on all the macOS
builds will affect things overall but it doesn't seem to have affected
the CI.
2025-02-12 07:17:13 -08:00
Jeffrey C. Ollie
1e3cd89516 macOS: use Nix to get Zig deps 2025-02-12 08:21:16 -06:00
Mitchell Hashimoto
019f789819 macOS: fix iOS build breakage from #5644 (#5713) 2025-02-12 06:18:06 -08:00
Jeffrey C. Ollie
9bac6ecbff macOS: fix iOS build breakage from #5644 2025-02-12 07:54:50 -06:00
Leah Amelia Chen
76ab6717c9 gtk: fix context menu computed location (#5710)
When a tab bar is displayed, the context menu opened with right click is
offset from the cursor.

This was due to using the incorrect coordinate space for describing
where to draw the context menu.


[gtk_popover_set_pointing_to](https://docs.gtk.org/gtk4/method.Popover.set_pointing_to.html)
uses the coordinate space of the popover's parent, however we used the
active window's coordinate space which was noticeably different when the
tab bar is visible.

Before:
![Screenshot_12-Feb_22-39-07_com mitchellh
ghostty](https://github.com/user-attachments/assets/5263dd9d-f3ab-44f6-baf2-7208d3d3bd01)
After:
![Screenshot_12-Feb_22-41-41_com mitchellh
ghostty-debug](https://github.com/user-attachments/assets/8d3e8bbd-af4e-43a6-a52d-6601a0b66ece)
2025-02-12 13:08:33 +01:00
azhn
b1ae7eea2f gtk: fix context menu computed location 2025-02-12 22:46:00 +11:00
azhn
c061d06aa1 Revert "gtk: Point right-click context menu exactly at cursor to improve behaviour at edges and closeness to cursor"
This reverts commit bf5351ed416b12575d377fe0bd5628df515cb71e.
2025-02-12 19:50:32 +11:00