8621 Commits

Author SHA1 Message Date
Mitchell Hashimoto
28190a6844 terminal: PageList.pin doesn't allow out of bounds x values (#3092)
Fixes #2958

The y was alround bounded but we allowed any x value and assumed the
caller would handle it. This is not the case so we now check the x and
return null if it's out of bounds (same as y, which was already doing
this).
2024-12-23 13:29:42 -08:00
Mitchell Hashimoto
809593473b terminal: PageList.pin doesn't allow out of bounds x values
Fixes #2958

The y was alround bounded but we allowed any x value and assumed the
caller would handle it. This is not the case so we now check the x and
return null if it's out of bounds (same as y, which was already doing
this).
2024-12-23 13:27:19 -08:00
Qwerasd
cb60f9d1da fix(RefCountedSet): Gracefully handle pathological cases
Poor hash uniformity and/or a crafted or unlucky input could cause the
bounds of the PSL stats array to be exceeded, which caused memory
corruption (not good!) -- we avoid such cases now by returning an
OutOfMemory error if we're about to insert and there's an item with a
PSL in the last slot.
2024-12-23 16:03:26 -05:00
Mitchell Hashimoto
1584fc1d77 macos: update content scale whenever the screen changes (#3091)
Related to #2731

I'm not fully sure if this will fix this issue since I can't reproduce
it but I don't see a downside to doing this and it might fix it.
2024-12-23 13:02:51 -08:00
Mitchell Hashimoto
53ac0aa975 macos: update content scale whenever the screen changes
Related to #2731

I'm not fully sure if this will fix this issue since I can't reproduce
it but I don't see a downside to doing this and it might fix it.
2024-12-23 13:02:22 -08:00
Mitchell Hashimoto
5daf778e70 kittygfx: z-index handling fixes (#3089)
Fixes #2921

Our z-index handling was pretty much completely broken, hence I can't
think of a better initial commit message. We were splitting the
placements at the wrong points and just generally putting images in the
wrong z-index. I'm shocked this didn't come up earlier.
2024-12-23 12:50:28 -08:00
Mitchell Hashimoto
a908aca563 kittygfx: z-index handling fixes
Fixes #2921

Our z-index handling was pretty much completely broken, hence I can't
think of a better initial commit message. We were splitting the
placements at the wrong points and just generally putting images in the
wrong z-index. I'm shocked this didn't come up earlier.
2024-12-23 12:46:46 -08:00
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
Mitchell Hashimoto
f92f5f7cfd Fix z2d StaticPath usage (#3084)
There was an accidental use of `undefined` which I believe is the source
of crashes people are experiencing when drawing Powerline chevrons
(#3083). I've resolved this by using the slice from the path's internal
`ArrayList` instead of the backing array (`z2d` should probably
introduce a `getNodes()` method or similar to `StaticPath`), and also
annotated all `StaticPath` uses counting the maximum number of nodes
that may be required.

(**Edit**: confirmed, fixes #3083)
2024-12-23 06:50:25 -08: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
2e14017b87 apprt/gtk: prevent a new split from being smaller than 2x2 (#3079)
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:38:32 -08: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
93de811804 macOS: change default keybinds for equalize splits, jump to prompt -1/+1 (#3078)
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:08:26 -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
dc9a19bc62 macos: set NSAppearance on windowDidLoad (#3077)
Fixes #3072

Previously, when `window-theme = auto`, the appearance was delayed
enough on the DispatchQueue that the window was already visible. This
would result in the window appearing with the wrong appearance before
switching to the correct one.

For annoying reasons, we can't set the NSApplication.shared.appearance
in `applicationDidFinishLaunching` because it results in a deadlock with
AppKit.

This commit moves to set the `NSWindow.appearance` in `windowDidLoad`
(and any config sync) to ensure that the appearance is set before the
window is visible.

This is probably the right solution anyways because this allows windows
with different background colors to each have their own distinct
appearance.
2024-12-22 19:41:43 -08:00
Mitchell Hashimoto
9d6b9d78d8 macos: set NSAppearance on windowDidLoad
Fixes #3072

Previously, when `window-theme = auto`, the appearance was delayed
enough on the DispatchQueue that the window was already visible. This
would result in the window appearing with the wrong appearance before
switching to the correct one.

For annoying reasons, we can't set the NSApplication.shared.appearance
in `applicationDidFinishLaunching` because it results in a deadlock with
AppKit.

This commit moves to set the `NSWindow.appearance` in `windowDidLoad`
(and any config sync) to ensure that the appearance is set before the
window is visible.

This is probably the right solution anyways because this allows windows
with different background colors to each have their own distinct
appearance.
2024-12-22 19:33:01 -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
Mitchell Hashimoto
010e73517d nix: move vimfiles instead of copying (#3073) 2024-12-22 19:07:41 -08:00
Mitchell Hashimoto
8124421523 deps: update z2d to v0.4.0 (#3075)
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.

### `Box_test_diff.ppm`:

![image](https://github.com/user-attachments/assets/64bf0a82-21a0-4fae-a423-bde6c5851648)
2024-12-22 19:07:28 -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
Jeffrey C. Ollie
b41db4f288 nix: move vimfiles instead of copying 2024-12-22 14:25:36 -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
Mitchell Hashimoto
ec8d2aaf06 Fix unfocused split color balance (#3066)
After upgrading Ghostty to the latest release, b92fb2d9, the unfocused
split color was quite different:

<img width="931" alt="image"
src="https://github.com/user-attachments/assets/9ff21db8-0280-416f-8119-2b0d1f08efc4"
/>

This was surprising because I don't set `unfocused-split-fill` so it
should use the background color.

I traced this to 298d6194f4c4de6727b6391b631d4d7f54d7f6b1 where the blue
and green components are divided by 255 but not the red.

Although I'm sure this should be easy to reproduce, the relevant bits of
my configuration file are included below:

```
theme = catppuccin-frappe

unfocused-split-opacity = 0.95
```

This fixes #3065.
2024-12-22 06:08:11 -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
Troels Thomsen
0611ca414f Divide red component of unfocused split fill color 2024-12-22 09:59:15 +01:00
Mitchell Hashimoto
b92fb2d901 macOS: Customize Ghostty Icon (#3063)
This is some last minute flare to get into the 1.0 release. 😄 

This introduces some new configurations to let you customize the macOS
app icon at runtime. The runtime icon only applies to certain areas such
as the dock, cmd-tab, etc. It does not change the icon in Finder or on
disk since Apple requires those icons are bundled as files with the
signed app bundle (i.e. you can't change it later without resigning).

I still think this introduces a lot of fun into the macOS app. 😄 

I'm still finalizing the exact customization options that will exist for
the icon, so I documented this option as experimental. I'm feeling
pretty good about what's there but I may add other options in the
future.

## Demo

### Beige Yellow

```
macos-icon = custom-style
macos-icon-frame = beige
macos-icon-ghost-color = yellow
macos-icon-screen-color = dark goldenrod,dark khaki
```

![CleanShot 2024-12-21 at 19 55
49@2x](https://github.com/user-attachments/assets/50d782ae-f30c-4a14-afc9-150b98b1659c)

### Laker Nation

```
macos-icon = custom-style
macos-icon-ghost-color = yellow
macos-icon-screen-color = purple,maroon
```

![CleanShot 2024-12-21 at 19 56
26@2x](https://github.com/user-attachments/assets/f82c901c-27a2-4fdb-8c46-9d1a5d8e5f39)
2024-12-21 20:07:42 -08: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
Mitchell Hashimoto
adba2036e3 macos: custom app icon goes into About window 2024-12-21 19:31:30 -08:00
Mitchell Hashimoto
c4bec781b0 macos: colorized Ghostty icon begins! 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
Mitchell Hashimoto
e97ebc5f7d bash: move functions and variables out of global scope (#3060)
Leave only `_ghostty` as a bash global.

I agree to re-license my commits to MIT
2024-12-21 17:11:10 -08:00
Mitchell Hashimoto
4524a16522 Update iTerm2 colorschemes (#3061)
Upstream revision:
d6c42066b3
2024-12-21 17:08:41 -08:00