6734 Commits

Author SHA1 Message Date
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
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
Jonatan Borkowski
21c97aa9d6 add support for buffer switching with CSI ? 47 h/l 2025-05-27 11:48:14 -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
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
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
alex-huff
113c196078 gtk: use 'gio.Application.idIsValid' instead of 'isValidAppId' 2025-05-25 15:23:13 -05: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
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
Alan Moyano
7bf01b97ca Merge branch 'ghostty-org:main' into main 2025-05-23 17:21:00 -03:00
Mitchell Hashimoto
f1c42c9f8c synthetic package
This introduces a new package `src/synthetic` for generating synthetic
data, currently primarily for benchmarking but other use cases can
emerge.

The synthetic package exports a runtime-dispatched type `Generator` that
can generate data of various types. To start, we have a bytes, utf8,
and OSC generator. The goal of each generator is to expose knobs to tune the
probabilities of various outcomes. For example, the UTF-8 generator has
a knob to tune the probability of generating 1, 2, 3, or 4-byte UTF-8
sequences.

Ultimately, the goal is to be able to collect probability data
empirically that we can then use for benchmarks so we can optimize
various parts of the codebase on real-world data shape distributions.
2025-05-21 10:20:09 -07:00
Mitchell Hashimoto
e2df9fa759 build: add unwind tables and frame pointers to debug/test builds (#7398)
This fixes an issue where stack traces were unreliable on some platforms
(namely aarch64-linux in a MacOS VM). I'm unsure if this is a bug in Zig
(defaults should be changed?) or what, because this isn't necessary on
other platforms, but this works around the issue.

I've unconditionally enabled this for all platforms, depending on build
mode (debug/test) and not the target. This is because I don't think
there is a downside for other platforms but if thats wrong we can fix
that quickly.

Some binaries have this unconditionally enabled regardless of build mode
(e.g. the Unicode tables generator) because having symbols in those
cases is always useful.

Some unrelated GTK test fix is also included here. I'm not sure why CI
didn't catch this (perhaps we only run tests for none-runtime) but all
tests pass locally and we can look into that elsewhere.

I also updated all our build API calls to be non-deprecated fields.
2025-05-19 19:56:22 -07:00
Mitchell Hashimoto
3d2bc3dca1 build: add unwind tables and frame pointers to debug/test builds
This fixes an issue where stack traces were unreliable on some platforms
(namely aarch64-linux in a MacOS VM). I'm unsure if this is a bug in Zig
(defaults should be changed?) or what, because this isn't necessary on
other platforms, but this works around the issue.

I've unconditionally enabled this for all platforms, depending on build
mode (debug/test) and not the target. This is because I don't think
there is a downside for other platforms but if thats wrong we can fix
that quickly.

Some binaries have this unconditionally enabled regardless of build mode
(e.g. the Unicode tables generator) because having symbols in those
cases is always useful.

Some unrelated GTK test fix is also included here. I'm not sure why CI
didn't catch this (perhaps we only run tests for none-runtime) but all
tests pass locally and we can look into that elsewhere.
2025-05-19 17:12:39 -07:00
Alan Moyano
5f3e5afb88 Add Argentinian Spanish translation and locale support 2025-05-19 20:32:30 -03:00
Mitchell Hashimoto
ac6aa8d395 Add selection-clear-on-typing
Fixes #7392

Docs:

> Whether to clear selected text when typing. This defaults to `true`.
> This is typical behavior for most terminal emulators as well as
> text input fields. If you set this to `false`, then the selected text
> will not be cleared when typing.
>
> "Typing" is specifically defined as any non-modifier (shift, control,
> alt, etc.) keypress that produces data to be sent to the application
> running within the terminal (e.g. the shell). Additionally, selection
> is cleared when any preedit or composition state is started (e.g.
> when typing languages such as Japanese).
>
> If this is `false`, then the selection can still be manually
> cleared by clicking once or by pressing `escape`.
2025-05-19 13:56:26 -07:00
Leah Amelia Chen
60d8c42509 gtk: implement global shortcuts (#7083) 2025-05-19 08:18:28 +02:00
Leah Amelia Chen
6827dc0964 config: document global: support on Linux
Compiling this list of known supported and unsupported platforms has been
amazingly painful. Never change, Linux desktop.
2025-05-18 22:40:31 +02:00
Leah Amelia Chen
54dbd1990a gtk: implement global shortcuts
It's been a lot of D-Bus related pain and suffering, but here it is.

I'm not sure about how well this is integrated inside App, but I'm fairly
proud of the standalone logic.
2025-05-18 22:40:31 +02:00
Leah Amelia Chen
b1af4a597f gtk: implement command palette (#7167)
Closes #7156
2025-05-16 22:16:48 +02:00
Mitchell Hashimoto
2d29fe0494 bench: add --mode=gen-osc to generate synthetic OSC sequences (#7359)
cc @qwerasd205 

This commit adds a few new mode flags to the `bench-stream` program to
generator synthetic OSC sequences. The new modes are `gen-osc`,
`gen-osc-valid`, and `gen-osc-invalid`. The `gen-osc` mode generates
equal parts valid and invalid OSC sequences, while the suffixed variants
are for generating only valid or invalid sequences, respectively.

This commit also fixes our build system to actually be able to build the
benchmarks. It turns out we were just rebuilding the main Ghostty binary
for `-Demit-bench`. And, our benchmarks didn't run under Zig 0.14, which
is now fixed.

An important new design I'm working towards in this commit is to split
out synthetic data generation to a dedicated package in
`src/bench/synth` although I'm tempted to move it to `src/synth` since
it may be useful outside of benchmarks.

The synth package is a work-in-progress, but it contains a hint of
what's to come. I ultimately want to able to generate all kinds of
synthetic data with a lot of knobs to control dimensionality (e.g. in
the case of OSC sequences: valid/invalid, length, operation types,
etc.).
2025-05-15 20:19:37 -07:00
Mitchell Hashimoto
e1de7a99e8 macos: add "Check for Updates" action, menu item & key-binding support (#7361)
Resolve #7325
2025-05-15 15:45:24 -07:00
Qwerasd
ea79fdea11 fix(OpenGL): use sRGB texture format for gamma correct interpolation
otherwise images will be too dark when scaled
2025-05-15 12:44:44 -06:00
Qwerasd
e2f3b6211f fix(Metal): use sRGB texture format for gamma correct interpolation
otherwise images will be too dark when scaled
2025-05-15 12:44:44 -06:00
Mitchell Hashimoto
1d0cb1a9b0 fix(renderer): Don't force images to grid/cell sizes. (#7367)
Also fixed Metal not interpolating scaled images.

See commit message for more details.

|`main` (Metal)|`main` (OpenGL)|Kitty|fixed (Metal)|fixed (OpenGL)|
|-|-|-|-|-|

|![image](https://github.com/user-attachments/assets/bfe09451-0a41-4952-8a55-5d7a9e5b2813)|![image](https://github.com/user-attachments/assets/70ec6775-ba00-40b7-a32d-dcaaa70671b1)|![image](https://github.com/user-attachments/assets/6d03729b-9b8e-4b25-850d-913e76f6183b)|![image](https://github.com/user-attachments/assets/aedfccf0-220c-4575-b5e4-8b467de6d5df)|![image](https://github.com/user-attachments/assets/300a080a-73f0-4c69-9603-df342767a83f)|

<sup>(Zoom in for details.)</sup>

> [!NOTE]
> This comparison reveals a separate problem we have with image scaling,
which Kitty gets right but we don't -- the interpolation is too dark
because of gamma error, we need to be interpolating in linear space but
instead we're interpolating in gamma compressed space. I'll try to
figure out the best way to resolve this.
2025-05-15 11:42:05 -07:00
Qwerasd
ed207514e9 typo 2025-05-15 11:59:17 -06:00
Qwerasd
709b0214a0 fix(renderer): Don't force images to grid/cell sizes
This problem was introduced by f091a69 (PR #6675).

I've gone ahead and overhauled the placement positioning logic as well;
it was doing a lot of expensive calls before, I've significantly reduced
that.

Clipping partially off-screen images is now handled entirely by the
renderer, rather than while preparing the placement, and as such the
grid position passed to the image shader is now signed.
2025-05-15 11:41:12 -06:00
Leah Amelia Chen
d6dea79bde gtk: add option to always display the tab bar
Also fixes crashes in both vanilla GTK and Adwaita implementations of
`closeTab`, which erroneously close windows twice when there are no
more tabs left (we probably already handle it somewhere else).
2025-05-15 19:05:46 +02:00
Leah Amelia Chen
cc65dfc90e gtk(command_palette): focus fixes 2025-05-15 18:11:19 +02:00
Leah Amelia Chen
2800e0c99b gtk(command_palette): address feedback related to selections
See #7173, #7175
2025-05-15 18:11:19 +02:00
Leah Amelia Chen
e97dfc2e19 gtk(command_palette): filter out certain actions 2025-05-15 18:11:19 +02:00
Leah Amelia Chen
3b013b1174 gtk: add command palette to titlebar menu 2025-05-15 18:11:19 +02:00
Leah Amelia Chen
048e4acb2c gtk: implement command palette 2025-05-15 18:11:19 +02:00
Aaron Ruan
f6d56f4f03 Handle check_for_updates as unimplemented action 2025-05-15 23:26:47 +08:00
Jeffrey C. Ollie
9ff43cd345 gtk: implement custom audio bell (#5326)
Fixes #2710 

Adds support for custom audio bell notifications.
2025-05-15 10:09:39 -05:00
Aaron Ruan
7ccc181332 macos: add "Check for Updates" action, menu item & key-binding support 2025-05-15 13:34:44 +08:00