5905 Commits

Author SHA1 Message Date
Qwerasd
b44ebed798 Fix a scenario that could cause issues under some conditions
I don't know if this actually occurs in a way that can cause serious
problems, but it's better to nip it in the bud.
2024-12-23 15:45:30 -05:00
Qwerasd
a51871a3f7 RefCountedSet: simplify insert logic, cleanup, improve comments
Previous logic had multiple issues that were hiding in edge cases of
edge cases with the ressurected item handling among other things; the
added assertIntegrity method finds these issues, the primary one being
an edge case where an ID is present in two different buckets.

Added more comments to explain logic in more detail and fixed a couple
little things like always using `+%` when incrementing the probe pos,
and replacing a silent return on an integrity issue that should be
impossible (`table[item.meta.bucket] != id`) with an assert.
2024-12-23 15:43:57 -05:00
Iain H
19e8651247 apprt/gtk: move new tab button to start of header bar
According to the GNOME human interface guidelines, buttons for the main
user actions, such as new, add, open, and back should be placed at the
start of the header bar. (https://developer.gnome.org/hig/patterns/containers/header-bars.html#header-bar-buttons)

Moving the new tab button to the start of the header bar brings Ghostty
in line with other GNOME applications such as gedit and gnome-terminal.
2024-12-23 11:48:22 -05:00
Qwerasd
9f4d9dc36e font/sprite: fix z2d StaticPath accounting + undefined use
Annotate the node count of all uses of z2d `StaticPath` to verify
correctness, adjusted the size of a couple which were oversized, and
changed all painter calls that take node slices from `StaticPath`s to
use the slice from the wrapped `ArrayList` so that we don't include any
potentially `undefined` nodes at the end of the list, which I think was
causing a crash before.
2024-12-23 04:21:33 -05:00
Qwerasd
98651ab0e5 fmt 2024-12-23 04:18:48 -05:00
Mitchell Hashimoto
12dd99ddd9 apprt/gtk: prevent a new split from being smaller than 2x2
Fixes #2092

This isn't perfect because it only prevents _new_ splits from being
too small. You can still resize the window to make them smaller. This
just helps prevent the very-easy-to-trigger crash of #2092.

We don't need to do this to macOS because it doesn't crash in the same
way with zero-sized splits.

Long term we should really chase down what breaks in GTK at a root level
when we have zero-sized splits. But this is a quick fix for now to
prevent the easy crash I feel like people might stress test and run into
with the 1.0 release.
2024-12-22 20:36:09 -08:00
Mitchell Hashimoto
8c2233fe0c macOS: change default keybinds for equalize splits, jump to prompt -1/+1
From: https://github.com/ghostty-org/ghostty/discussions/2363#discussioncomment-11645228

The justification there makes sense to me and I think it would be a good
change to make. Copied here:

> There are a few bindings that feel a little weird on macOS. My suggestions:
>
> (1) Equalize Splits
> ```
> keybind = shift+opt+equal=unbind
> keybind = ctrl+cmd+equal=equalize_splits
> ```
> The default hijacks the `±` character on US keyboards. Believe it or not, I do use ± in the terminal. Ctrl+cmd+equal matches the arrow key bindings in the Window > Resize Split menu and thus looks more elegant and is easier to memorize.
>
> (2) Jump to Prompt
> ```
> keybind = cmd+up=jump_to_prompt:-1
> keybind = cmd+down=jump_to_prompt:1
> ```
> These are the bindings in Terminal.app. The default shift-cmd-up/down is usually associated with extending a selection. Cmd-up/down are available (they currently act as simple up/down). I bind them additionally to the defaults.
2024-12-22 20:05:32 -08:00
Mitchell Hashimoto
c56dde58b0 core: don't try opening config files that are anything but files (#3046)
In a [Discord
thread](https://discord.com/channels/1005603569187160125/1319727495473397791)
someone was having problems running Ghostty because they had
accidentally created a directory called `~/.config/ghostty/config`.
Instead of erroring out Ghostty would hang trying to "read" the
directory. Crashes can also happen if the argument to `--config-file` on
the CLI or a recursively loaded config file.

This patch prevents those hangs or crashes by refusing to read anything
but a plain file (symbolic links to plain files continue to work as
well).
2024-12-22 19:07:53 -08:00
Qwerasd
b920352c39 deps: update z2d to v0.4.0
Introduces static path methods and a reworked context API that makes
things generally cleaner.

This update incidentally fixed a bug we had before where the corner
triangle shade characters were drawn solid rather than medium shade.
2024-12-22 16:07:05 -05:00
Jeffrey C. Ollie
5d38336823 core: don't read config files that are not files 2024-12-22 14:53:37 -06:00
Mitchell Hashimoto
28c40f9bae font: add cursor-height metric, and adjust- config for it. (#3062)
Subsumes #2580 (which has multiple conflicts with main due to recent
changes to metrics); I figured it'd be easier to just implement it this
way.

#2580 claimed to solve #2487 but I don't think it really does- ideally
we can think of a good way to configure each individual cursor type, but
I don't wanna just do something ad hoc and add a bunch of config keys
blindly so I limited the scope of this.
2024-12-22 10:46:52 -08:00
Nico Weber
44e1df5df3 add a comment 2024-12-22 13:16:30 -05:00
Qwerasd
3b6d8f3175 fix tests for coretext to include cursor_height 2024-12-22 12:52:04 -05:00
Qwerasd
d624db30c6 test(metrics): fix to initialize cursor height + add comment 2024-12-22 12:38:17 -05:00
Qwerasd
08ebb6b64d fix tests for freetype to include cursor_height metric 2024-12-22 12:34:43 -05:00
Mitchell Hashimoto
eb7b056fba font: add sprites for the separated block quadrants (#2975)
Unicode 16 added "Separated Block Quadrants" from CP 0x0x1CC21 through
0x1CC2F:

𜰡 𜰢 𜰣 𜰤 𜰥 𜰦 𜰧 𜰨 𜰩 𜰪 𜰫 𜰬 𜰭 𜰮 𜰯

To test, use the following command:

```
printf "\U0001CC21\U0001CC22\U0001CC23\U0001CC24\U0001CC25\U0001CC26\U0001CC27\U0001CC28\U0001CC29\U0001CC2A\U0001CC2B\U0001CC2C\U0001CC2D\U0001CC2E\U0001CC2F\n"
```

Which should look like this:

![Screenshot From 2024-12-15
13-15-31](https://github.com/user-attachments/assets/fcf825e1-c824-4f56-8c7d-b4e126401c2b)

cc @qwerasd205 @rockorager
2024-12-22 07:25:27 -08:00
Mitchell Hashimoto
bef28524dc CLI: add +show-face action (#3000)
This adds a `+show-face` CLI action to show what font face Ghostty will
use to display a particular codepoint. The codepoint can either be
specified via a single integer or via UTF-8 encoded string.

![Screenshot From 2024-12-17
12-32-31](https://github.com/user-attachments/assets/5a47e672-5ea2-4463-a1dc-7cd6d897e0a8)
2024-12-22 07:25:10 -08:00
Mitchell Hashimoto
1861a391c8 config: quick terminal auto hide (#3059)
## Description

Introduce a setting allowing to customize the behavior of the quick
terminal when it loses focus. By default, the quick terminal will
automatically hide. However, you can now configure it to remain open by
setting `quick-terminal-autohide: false`.

Resolves #2558
2024-12-22 07:06:10 -08:00
Nico Weber
79d84af56e comment 2024-12-22 08:52:38 -05:00
Nico Weber
6a2597a6d6 macos: Make "Settings…" menu item open config file in Application Support
...unless ~/.config/ghostty/config already exists, then that is opened.
(Or whatever $XDG_CONFIG_HOME points to.)

If both files exists, ghostty reads first the one in ~/.config/ghostty/config
and then the one in Application Support, and merges the settings. In that case,
the menu item opens the file at ~/.config.

Fixes #2890.
2024-12-22 08:45:45 -05:00
deftdawg
a469191311 Merge branch 'ghostty-org:main' into alt-keybindings-copy-and-paste 2024-12-22 02:06:54 -05:00
Mitchell Hashimoto
4681719e43 config: mark as experimental 2024-12-21 19:57:50 -08:00
Mitchell Hashimoto
1f468202d4 macos: add macos-icon-frame and some custom frame styles 2024-12-21 19:48:24 -08:00
Mitchell Hashimoto
bcced34726 config: additional macos-icon docs 2024-12-21 19:31:31 -08:00
Mitchell Hashimoto
e4b6b89951 config: ensure formatting can only return OOM 2024-12-21 19:31:31 -08:00
Mitchell Hashimoto
abf713feec macos: support the macos-icon configurations 2024-12-21 19:31:30 -08:00
Mitchell Hashimoto
29929a473d config: macos-icon configurations 2024-12-21 19:31:30 -08:00
Mitchell Hashimoto
298d6194f4 config: change color to a defined C struct for libghostty 2024-12-21 19:31:30 -08:00
Qwerasd
077dad11b4 font: add cursor-height metric, and adjust- config for it. 2024-12-21 20:15:53 -05:00
Anund
e8d79ed035 bash: move functions and variables out of global scope 2024-12-22 11:33:41 +11:00
Damien MEHALA
196af6f2ca config: quick terminal auto hide
Introduce a setting allowing to customize the behavior of the quick terminal
when it loses focus. By default, the quick terminal will automatically hide.
However, you can now configure it to remain open by setting
`quick-terminal-autohide: false`.

Resolves #2558
2024-12-22 01:08:47 +01:00
Mitchell Hashimoto
a74b555c42 bash: standardize on shorthand escape sequences (#3055)
We used a mix of shorthand and octal representations when printing these
control characters. Standardize on the shorter, more readable shorthand
notation because that's what we use in the other shell integration
scripts.
2024-12-21 12:02:23 -08:00
Jon Parise
76cd6b8b2e bash: standardize on shorthand escape sequences
We used a mix of shorthand and octal representations when printing these
control characters. Standardize on the shorter, more readable shorthand
notation because that's what we use in the other shell integration
scripts.
2024-12-21 10:19:58 -05:00
Mitchell Hashimoto
fc297da834 surface: don't early return when clearing hyperlinks (#3033)
When outside the viewport, other actions such as scrolling might be
happening, and doing an early return when clearing hyperlinks prevents
scrolling upwards.

We reposition the check, and do not early return so we can process
scrolling when it happens.

This fixes #2645, restoring the ability to scroll upwards while
retaining the behavior of hyperlinks when outside the viewport.

(and, yes I still permit my commits to be relicensed to MIT)

## Before
[Screen Recording 2024-12-21 at
01.36.02.webm](https://github.com/user-attachments/assets/bf144455-ff26-4d4e-9eff-c3d632c02c17)

## After
[Screen Recording 2024-12-21 at
01.36.44.webm](https://github.com/user-attachments/assets/308a795f-971d-4807-b4ba-91bd3685c185)
2024-12-21 07:18:31 -08:00
Mitchell Hashimoto
457bedc540 Bash complex completions (#3044)
Given https://github.com/ghostty-org/ghostty/discussions/2994 revert
f1728f594a.
Add documentation to help point people towards the discussion and needed
changes to handle `COMP_WORDBREAKS` not including expected characters.

We know macOS and nixos defaults to including `=` so explicit handling
to change behaviour should only be required if it turns out some
systematically used tool brings in a completion function that changes
`COMP_WORDBREAKS` away from the default. (something they should not be
doing)

If necessary I can create a issue to track handling unexpected word
breaks usage. This change improves the current completions.

I agree to re-license my commits to MIT
2024-12-21 07:10:08 -08:00
Mitchell Hashimoto
75a45f5692 config: blank title docs 2024-12-21 07:09:35 -08:00
Anund
9c96a80f8b bash: document COMP_WORDBREAKS interaction 2024-12-21 14:09:18 +11:00
Anund
3f94c84c80 Revert "bash: remove quoted completions while sorting possible portability issue"
This reverts commit f1728f594a681941b85a8d2fa8a136d625d9b633.
2024-12-21 13:43:41 +11:00
Mitchell Hashimoto
8f15f1a066 Make Ghostty release channel aware
Ghostty now has a release channel build configuration. Current valid
values are "tip" and "stable" but I imagine more will be added in the
future.

The release channel is inferred whether the version we specify with the
`-Dversion-string` build flag has a prerelease tag or not. If it does,
the release channel is "tip". If it doesn't, the release channel is
"stable".

This also adds a configuration to specify the release channel for
auto-updates for the macOS application.
2024-12-20 14:21:59 -08:00
moni
819b7e066d surface: don't early return when clearing hyperlinks
When outside the viewport, other actions such as scrolling might be happening, and doing an early return when clearing hyperlinks prevents scrolling upwards.

We do not early return so we can process scrolling when it happens.
2024-12-21 04:24:00 +08:00
Mitchell Hashimoto
5bb05996eb avoid asserting working directory is absolute (#3028)
`std.fs.accessAbsolute` asserts if the user proposed path is absolute,
which we are seemingly passing as-is with no validating that it is.

When running with safety checks on, passing non-absolute path to
--working-directory will make ghostty crash.

I changed it to use `Dir.access`, which is just `accessAbsolute` without
the check.

This has the side effect of also allowing relative working directory.
2024-12-20 08:25:51 -08:00
Mitchell Hashimoto
0f588d72c7 Change to F3 legacy encoding with modifiers (#3019)
The [fixterms](http://www.leonerd.org.uk/hacks/fixterms/) "Really
Special Keypresses" section suggests using CSI 1 ; Ps R for F3, but this
is also a valid cursor position report. The intention was to make
back-compatible changes, so this is fairly considered a specification
bug.

This changes F3 in legacy mode to send CSI 13 ; Ps ~ instead, this is a
variant listed in fixterms, is what kitty protocol uses, and lacks the
problematic overlap with cursor positions.

The KeyEncoder.zig unit test has been changed accordingly, and all tests
pass on my machine.
2024-12-20 08:25:30 -08:00
Khang Nguyen Duy
239056c90f avoid asserting working directory is absolute
`std.fs.accessAbsolute` asserts if the user proposed path is absolute,
which we are seemingly passing as-is with no validating that it is.

When running with safety checks on, passing non-absolute path to
--working-directory will make ghostty crash.

I changed it to use `Dir.access`, which is just `accessAbsolute` without
the check.

This has the side effect of also allowing relative working directory.
2024-12-20 22:41:28 +07:00
Mitchell Hashimoto
270d454c4e webgen: update config to support callouts, emit keybind actions 2024-12-19 17:15:39 -08:00
Sam Atman
8cadc7030c Change to F3 legacy encoding with modifiers
The [fixterms](http://www.leonerd.org.uk/hacks/fixterms/) "Really
Special Keypresses" section suggests using CSI 1 ; Ps R for F3, but this
is also a valid cursor position report.  The intention was to make back-
compatible changes, so this is fairly considered a specification bug.

This changes F3 in legacy mode to send CSI 13 ; Ps ~ instead, this is a
variant listed in fixterms, is what kitty protocol uses, and lacks the
problematic overlap with cursor positions.

The KeyEncoder.zig unit test has been changed accordingly, and all tests
pass on my machine.
2024-12-19 17:05:29 -05:00
Mitchell Hashimoto
d6e7685816 Docfix: correct comment for modifyOtherKeys sequence (#3018)
The comment in `function_keys.zig` was missing the `>` character for the
sequence. I've confirmed that this was just the comment, Ghostty treats
the original as an SGR sequence, which it is. Conversely, it does treat
`\x1b[>4;2m` as activating modifyOtherKeys.
2024-12-19 14:02:56 -08:00
Sam Atman
d885a266d4 Docfix: correct comment for modifyOtherKeys sequence
The comment in `function_keys.zig` was missing the `>` character for the
sequence.  I've confirmed that this was just the comment, Ghostty treats
the original as an SGR sequence, which it is.  Conversely, it does treat
`\x1b[>4:2m` as activating modifyOtherKeys.
2024-12-19 16:51:28 -05:00
Mitchell Hashimoto
fa3896be03 Fix emoji size and atlas padding (#3016)
Fixes a bug where emojis got smaller when font thicken was enabled
because they were constrained for some reason, here demonstrated by
artificially narrowing the cells with `adjust-cell-width=-45%`:
|`font-thicken`|main|this PR|
|-|-|-|
|`false`|<img width="328" alt="image"
src="https://github.com/user-attachments/assets/c5c25d94-ea73-47e1-80e9-ed3baff76511"
/>|<img width="328" alt="image"
src="https://github.com/user-attachments/assets/f74a35e1-ab7e-470d-b873-f33e63c1c9bb"
/>|
|`true`|<img width="328" alt="image"
src="https://github.com/user-attachments/assets/e7c1e096-4a54-456c-afb0-5adcb94eaf00"
/>|<img width="328" alt="image"
src="https://github.com/user-attachments/assets/80d3d7dd-f572-489a-ab56-d2d5ca9f3508"
/>|

And reworks the CoreText atlas margin/padding calculations to be more
efficient, you can see comparisons with and without thicken both before
and after this change here:
<details>
<summary>Atlas Textures</summary>

### main
|`font-thicken`|gray|color|
|-|-|-|

|`false`|![image](https://github.com/user-attachments/assets/d73a8963-ebfc-44d7-8b57-92db54612336)|![image](https://github.com/user-attachments/assets/4305243b-6459-45aa-bd42-bb263f3b0a9f)|

|`true`|![image](https://github.com/user-attachments/assets/94810d04-ea30-40f9-8d08-07b487b98ad1)|![image](https://github.com/user-attachments/assets/be5f1a2a-7c11-4805-977b-edf8aa7232a1)|

### this PR
|`font-thicken`|gray|color|
|-|-|-|

|`false`|![image](https://github.com/user-attachments/assets/e1debdcb-36bd-44d3-8776-27f4a2285821)|![image](https://github.com/user-attachments/assets/5cdc5eb8-6122-4bf7-8525-93a1b83d2bf0)|

|`true`|![image](https://github.com/user-attachments/assets/423bfb38-2657-4f48-a6fb-77986d049615)|![image](https://github.com/user-attachments/assets/136e970f-25e7-4ec5-8819-5a981381d18f)|
</details>

The atlas padding calculations were also affecting the issue with the
emojis getting smaller when thicken was enabled, because they were given
extra space to account for the thickening but they're bitmap so they
don't get affected by thickening.
2024-12-19 13:31:06 -08:00
Qwerasd
0e21293d43 font(coretext): improve atlas padding calculations
- Simplifies and clarifies the math for how the bounding box for
rendered glyphs is computed
- Reduces margin from 2px between glyphs to 1px by only padding the
bottom and right side of each glyph
- Avoids excessive padding to glyph box when font thicken is enabled or
when using a synthetic bold (it was previously 4x as much padding as
necessary in some cases)
2024-12-19 13:30:52 -08:00
Niclas van Eyk
7d71eabae8 docs: fix referenced toggle window decorations action name 2024-12-19 22:05:59 +01:00