10546 Commits

Author SHA1 Message Date
Jeffrey C. Ollie
f0fc82c80f OSC: account for 32-bit systems in comptime Command size check 2025-05-29 11:37:09 -05:00
Jeffrey C. Ollie
5fb32fd8a0 OSC: add comptime check for size of OSC Command 2025-05-29 11:37:09 -05:00
Jeffrey C. Ollie
bcf4d55dad OSC: nest ColorOperation-related structs 2025-05-29 11:37:08 -05:00
Jeffrey C. Ollie
fa03115f01 OSC: don't use arena during testing 2025-05-29 11:37:08 -05:00
Jeffrey C. Ollie
35384670c4 OSC: fix typo 2025-05-29 11:37:08 -05:00
Jeffrey C. Ollie
e0ddc7a2fa OSC: clean up color_operation handling 2025-05-29 11:37:08 -05:00
Jeffrey C. Ollie
f2dfd9f677 OSC: improve formatting of ColorOperationSource 2025-05-29 11:37:07 -05:00
Jeffrey C. Ollie
bd4d1950ce OSC: remove unused code 2025-05-29 11:37:07 -05:00
Jeffrey C. Ollie
479fa9f809 OSC: use std.SegmentedList instead of custom data structure 2025-05-29 11:37:07 -05:00
Jeffrey C. Ollie
397a8b13e0 OSC: more tests 2025-05-29 11:37:07 -05:00
Jeffrey C. Ollie
1d9d253e4d OSC: fix bug with buffer disappearing 2025-05-29 11:37:07 -05:00
Jeffrey C. Ollie
04e8e52171 OSC: reflow comment 2025-05-29 11:37:06 -05:00
Jeffrey C. Ollie
1288296fdc OSC: add a datastructure to prevent some (most?) allocations 2025-05-29 11:37:06 -05:00
Jeffrey C. Ollie
5bb7492955 OSC: convert OSC 110, 111, and 112 and add more tests 2025-05-29 11:37:06 -05:00
Jeffrey C. Ollie
5ec1c15ecf OSC: add more tests 2025-05-29 11:37:06 -05:00
Jeffrey C. Ollie
9c1abf487e OSC: start adding structure to allow multiple color operations per OSC 2025-05-29 11:37:06 -05:00
Mitchell Hashimoto
b2f3c7f309 fix: properly intialize key event in GlobalEventTap (#7462)
Fixes #7215. The issue was that `GlobalEventTap` didn't fully initialize
the key event before passing it to `ghostty_app_key`. In particular, it
didn't set the `unshifted_codepoint` field, which is needed to find a
match when calling `keybind.set.getEvent`, because `keybind.set` stores
bindings by codepoint, not physical key (i.e., the trigger to match is
`ctrl+p`, not `ctrl+key_p`, et cetera).

The fix was to make `GlobalEventTap` initialize the key event using
`event.ghosttyKeyEvent`, like it's done in `SurfaceView.keyAction` and
`AppDelegate.localEventKeyDown`.

This is my first time touching either Zig or Swift, so I'm a bit green.
In particular, I don't know if it's possible to write a test covering
this, and if so, how and where to put it. Please edit or request changes
as you see fit.
2025-05-29 08:48:10 -07:00
Daniel Wennberg
d1501a4925 fix: properly intialize key event in GlobalEventTap 2025-05-27 22:33:15 -07:00
Mitchell Hashimoto
8a00aa8223 code style: use @splat where possible (#7461)
As of Zig 0.14.0, `@splat` can be used for array types, which eliminates
a lot of redundant syntax and makes things generally cleaner.

I've explicitly avoided applying this change in the renderer files for
now since it would just create rebasing conflicts in my renderer rework
branch which I'll be PR-ing pretty soon.
2025-05-27 21:30:23 -07:00
Qwerasd
6f7e9d5bea code style: use @splat where possible
As of Zig 0.14.0, `@splat` can be used for array types, which eliminates
a lot of redundant syntax and makes things generally cleaner.

I've explicitly avoided applying this change in the renderer files for
now since it would just create rebasing conflicts in my renderer rework
branch which I'll be PR-ing pretty soon.
2025-05-27 21:55:28 -06:00
Mitchell Hashimoto
ad632f1068 Add support for buffer switching with CSI ? 47 h/l (#7443)
This PR adds support for handling the escape sequences CSI ? 47 h/l,
which are related to alternate screen buffer switching. This is in
response to the issue reported in
[ghostty-org/ghostty#7386](https://github.com/ghostty-org/ghostty/issues/7386).

I'm unsure where to add tests for this change. Would it make sense to
add visual tests for this behavior, or is there a preferred approach or
location for testing such functionality? I tested it locally using the
following commands:
```bash
echo -e "\e[?47h"
echo "Printed on the alt screen"
echo -e "\e[?47l"
```
2025-05-27 11:54:28 -07:00
Jonatan Borkowski
21c97aa9d6 add support for buffer switching with CSI ? 47 h/l 2025-05-27 11:48:14 -07:00
Mitchell Hashimoto
d72a1511fe Rework mouse selection logic (#7444)
This PR fixes the problem discussed in #5058 and #7434 by reworking the
selection logic in a way that better handles edge cases as well as being
generally cleaner.

This rework does change how selection behaves slightly, especially
rectangular selection, but the new behavior of rectangular selection is
more in line with other terminals I tested (Terminal.app, Kitty).

There are some TODO comments for adding unit tests- I ran out of steam
tonight, but if this PR is still open tomorrow I'll go ahead and add
them.
2025-05-27 10:12:31 -07:00
Mitchell Hashimoto
ba02f0ae22 decl literal 2025-05-27 09:55:54 -07:00
Qwerasd
6aa84d0e92 test: introduce helper function for mouse selection tests
Removes a lot of repeated code and makes the test cases easier to
understand at a glance.
2025-05-27 09:38:36 -07:00
Qwerasd
4d11673318 unit test mouse selection logic
Adds many test cases for expected behavior of the selection logic, this
will allow changes to be made more confidently in the future without
fear of regressions.
2025-05-27 09:38:36 -07:00
Qwerasd
ecdac8c8c1 terminal: rework selection logic in core surface
This logic is cleaner and produces better behavior when selecting by
dragging the mouse outside the bounds of the surface, previously when
doing this on the left side of the surface selections would include the
first cell of the next row, this is no longer the case.

This introduces methods on PageList.Pin which move a pin left or right
while wrapping to the prev/next row, or clamping to the ends of the row.
These need unit tests.
2025-05-27 09:38:36 -07:00
Qwerasd
58592d3f65 GTK: Don't clamp cursorpos, allow negative values
Other apprts don't do this, so this should be consistent.
2025-05-27 09:38:36 -07:00
Qwerasd
1ce6544945 Wrap comment at 80 cols 2025-05-27 09:38:36 -07:00
Mitchell Hashimoto
04db2f664b Miscellaneous TODOs (#7451)
See commit messages for details.

If some of the commits in this PR have problems with them I'm perfectly
fine with the others being cherry-picked out while the problems are
addressed.

The biggest/broadest reaching changes in this PR come from converting a
lot of code to use decl literals where possible, so there are a lot of
files where only a handful of lines are modified very slightly.
2025-05-27 07:17:45 -07:00
Mitchell Hashimoto
6b1b5ca0e9 nix: update to Nix 25.05 and Zig 0.14.1 (#7447)
Update to Nix 25.05 which gets us GTK 4.18, libadwaita 1.7, and Zig
0.14.1.

Since Nix updated to Zig 0.14.1, the devshell has been switched to Zig
0.14.1 from zig-overlay as well.

Fixes #7305
2025-05-27 07:12:17 -07:00
Mitchell Hashimoto
483cb42088 Correct $XDG_CONFIG_DIR to $XDG_CONFIG_HOME (#7454)
Ghostty doesn't support `$XDG_CONFIG_DIR`, it only supports
`$XDG_CONFIG_HOME`, so the documentation was incorrect. Not to be
confused with `$XDG_CONFIG_DIRS` nor `$XDG_RUNTIME_DIR` (very
consistent…).

Furthermore, `$XDG_CONFIG_HOME` is the correct XDG path:

> <ins>$XDG_CONFIG_HOME</ins> defines the base directory relative to
which user-specific configuration files should be stored. If
<ins>$XDG_CONFIG_HOME</ins> is either not set or empty, a default equal
to <ins>$HOME</ins>/.config should be used.
> […]
> <ins>$XDG_CONFIG_DIRS</ins> defines the preference-ordered set of base
directories to search for configuration files in addition to the
<ins>$XDG_CONFIG_HOME</ins> base directory. The directories in
<ins>$XDG_CONFIG_DIRS</ins> should be separated with a colon ':'.

— [XDG Base Directory Specification § Environment variables][xdgvars]

Cross-reference:
https://github.com/ghostty-org/ghostty/discussions/7431#discussioncomment-13283139.

[xdgvars]:
https://specifications.freedesktop.org/basedir-spec/latest#variables
2025-05-27 07:10:17 -07:00
Kat
468bfce091 Correct $XDG_CONFIG_DIR to $XDG_CONFIG_HOME in theme documentation. 2025-05-27 22:40:01 +10:00
Qwerasd
2384bd69cc style: use decl literals
This commit changes a LOT of areas of the code to use decl literals
instead of redundantly referring to the type.

These changes were mostly driven by some regex searches and then manual
adjustment on a case-by-case basis.

I almost certainly missed quite a few places where decl literals could
be used, but this is a good first step in converting things, and other
instances can be addressed when they're discovered.

I tested GLFW+Metal and building the framework on macOS and tested a GTK
build on Linux, so I'm 99% sure I didn't introduce any syntax errors or
other problems with this. (fingers crossed)
2025-05-26 21:50:14 -06:00
Qwerasd
2fe2ccdbde font/sprite: use decl literals in box drawing code
Cleaner and less visual noise, easy change to make, there are many other
areas in the code which would benefit from decl literals as well, but
this is an area that benefits a lot from them and is self-contained.
2025-05-26 19:56:35 -06:00
Qwerasd
2905b47279 font: use labeled switch continue pattern for feature string parser
In this case it does result in a little repeated code for reading bytes,
but I find the control flow easier to follow, so it's worth it IMO.
2025-05-26 19:39:39 -06:00
Jeffrey C. Ollie
695e0b3e57 nix: temporarily remove snapcraft from the devshell 2025-05-26 11:43:52 -05:00
Jeffrey C. Ollie
48b6807ac9 nix: fix typos 2025-05-26 11:12:30 -05:00
Jeffrey C. Ollie
98309e3226 nix: update to Nix 25.05 and Zig 0.14.1
Update to Nix 25.05 which gets us GTK 4.18, libadwaita 1.7, and Zig 0.14.1.

Since Nix updated to Zig 0.14.1, the devshell has been switched to Zig 0.14.1
from zig-overlay as well.

Fixes #7305
2025-05-26 10:47:43 -05:00
Qwerasd
25a708ed98 terminal/style: compare packed styles directly, no cast needed
Woohoo, Zig 0.14!
2025-05-25 22:53:50 -06:00
Qwerasd
19db2e2755 CircBuf: non-allocating rotateToZero
We can call `std.mem.rotate` for this.
2025-05-25 22:25:23 -06:00
Jeffrey C. Ollie
3f6c02b49e gtk: improve app id validation (#7442)
'g_application_id_is_valid' doesn't allow empty elements or elements
that start with digits.
This commit updates 'isValidAppId' to be more consistant with
'g_application_id_is_valid' avoiding the app id defaulting to 'GTK
Application' for app ids like '0foo.bar' or 'foo..bar'.
2025-05-25 16:11:26 -05:00
alex-huff
113c196078 gtk: use 'gio.Application.idIsValid' instead of 'isValidAppId' 2025-05-25 15:23:13 -05:00
Mitchell Hashimoto
6697dc6642 Add new and update Norwegian split translations (#7423)
This change changes the wording on the split pane functionality. The new
wording is taken from the macOS terminal app when the whole system is
translated to Norwegian.

macOS uses "Del opp vindu" and "Lukk delt vindu" for "Split Pane" and
"Close Split Pane". So instead of using "split" the verb in question is
always "del". Personally I find this translation to be better rooted in
Norwegian.

When looking at the German translation, which is often a good indicator
for Norwegian as well, one can see the same wording being used.
2025-05-25 12:27:40 -07:00
Mitchell Hashimoto
731d0f0444 Update iTerm2 colorschemes (#7435)
Upstream revision:
273a780bcd
2025-05-25 12:21:17 -07:00
alex-huff
0415a65083 gtk: improve app id validation
'g_application_id_is_valid' doesn't allow empty elements or elements
that start with digits.
This commit updates 'isValidAppId' to be more consistant with
'g_application_id_is_valid' avoiding the app id defaulting to 'GTK
Application' for app ids like '0foo.bar' or 'foo..bar'.
2025-05-25 11:43:40 -05:00
mitchellh
b94d2da567 deps: Update iTerm2 color schemes 2025-05-25 00:15:05 +00:00
Mitchell Hashimoto
034c1c12ef add cut/copy/paste keys (#7430)
The origin of these keys are old sun keyboards.
They are getting picked up by the custom (progammable) keyboard scene
(see https://github.com/manna-harbour/miryoku for a popular layout).
Support in ghosty is quite handy because it allows to bind copy/paste in
a way that doesn't overlap with ctrl-c/ctrl-v, which can have special
bindings in some terminal applications.
2025-05-24 07:17:49 -07:00
Jörg Thalheim
a8651882a7 add cut/copy/paste keys
The origin of these keys are old sun keyboards.
They are getting picked up by the custom (progammable) keyboard scene
(see https://github.com/manna-harbour/miryoku for a popular layout).
Support in ghosty is quite handy because it allows to bind copy/paste in
a way that doesn't overlap with ctrl-c/ctrl-v, which can have special
bindings in some terminal applications.
2025-05-24 00:29:53 +02:00
Mitchell Hashimoto
26a42fac0e Update Turkish translations (#7408) 2025-05-23 07:15:46 -07:00