8825 Commits

Author SHA1 Message Date
Mitchell Hashimoto
41df2d9805 font/freetype: hardcode DPI in test to avoid variation between OS 2024-12-30 12:01:46 -08:00
Mitchell Hashimoto
d20446e4de feat: support for short hex colors in config (#4112)
closes #4111
2024-12-30 11:59:08 -08:00
acsetter
a6eec4cbe2 feat: support for short hex colors in config 2024-12-30 11:55:49 -08:00
Qwerasd
7a4215abd7 font/coretext: properly resolve metrics for bitmap-only fonts
macOS bitmap-only fonts are a poorly documented format, which are often
distributed as `.dfont` or `.dfon` files. They use a 'bhed' table in
place of the usual 'head', but the table format is byte-identical, so
enabling the use of bitmap-only fonts only requires us to properly fetch
this table while calculating metrics.

ref: https://fontforge.org/docs/techref/bitmaponlysfnt.html
2024-12-30 14:44:46 -05:00
Qwerasd
31f101c970 Revert "coretext: exclude bitmap fonts from discovery"
This reverts commit 322f166ca50eb495aba3e49d24fda280e2b0a759.
2024-12-30 14:39:07 -05:00
Mitchell Hashimoto
2f6860fbc5 font/freetype: Enable bitmap glyphs for non-color faces (#3837)
This allows for crisp bitmap font rendering once again. Tested with
Terminus (TTF), and at both 1x and 2x DPI the font renders perfectly
(click for 1:1 size):

![Terminus (TTF), size 12, 96
DPI](https://github.com/user-attachments/assets/181ba561-ebe4-49df-aa41-68fc782f92b8)

<img alt="Terminus (TTF), size 12, 192 DPI"
src="https://github.com/user-attachments/assets/d34804fe-4966-42e8-bf9e-bd10570ad443"
width="384" height="50" />
2024-12-30 11:16:17 -08:00
Mitchell Hashimoto
f8c3dc1bbf fix: quick terminal focus-follows-mouse behaviour (#3814)
# Description

Quick Terminal now focuses on the surface under the mouse pointer when
`focus-follows-mouse` is enabled.

Fixes #3337
2024-12-30 11:10:38 -08:00
Damien Mehala
ade07c4c3c fix: quick terminal focus-follows-mouse behaviour
Quick Terminal now focuses on the surface under the mouse
pointer when `focus-follows-mouse` is enabled.

Fixes #3337
2024-12-30 11:04:21 -08:00
Mitchell Hashimoto
68318e2830 Set alpha component for fullscreen background colour (#3834)
This fixes a bug in the fullscreen behaviour on MacOS.

As per discussion #2840 native fullscreen on MacOS should set the
background to be opaque. Colours are incorrectly set due to the alpha
channel.

## Original behaviour:
When windowed:
<img width="810" alt="Screenshot 2024-12-28 at 9 02 09 PM"
src="https://github.com/user-attachments/assets/59bd4380-2744-42e6-99c7-6d7b19919206"
/>

When fullscreened:
<img width="1470" alt="Screenshot 2024-12-28 at 9 01 46 PM"
src="https://github.com/user-attachments/assets/a18f82ea-8cce-4d9b-8bb2-c279e2a753f0"
/>

## After the fix:
When fullscreened:
<img width="1470" alt="Screenshot 2024-12-28 at 9 13 17 PM"
src="https://github.com/user-attachments/assets/6c3f31ae-c206-4234-8bde-1886ce16c837"
/>
2024-12-30 10:55:48 -08:00
Mitchell Hashimoto
a15473d9bd fix(gtk): fix issue detecting preferred color scheme on older systems (#4035)
On my system (pop-os 22.04 LTS) with system theme and seperate light and
dark themes, ghostty always defaults to light mode. Switches between
light and dark mode are properly handled.

In the logs this error is reported:

error(gtk): unable to get current color scheme:
GDBus.Error:org.freedesktop.DBus.Error.UnknownMethod: No such method
“ReadOne”

The spec notes that the other functions are "[Deprecated, use ReadOne
instead.](https://flatpak.github.io/xdg-desktop-portal/docs/doc-org.freedesktop.portal.Settings.html)"
so using ReadOne is cerainly the correct path.

I've managed to fix this on my system by checking for the error and
falling back to an implementation using the deprecated Read.

Discussion: https://github.com/ghostty-org/ghostty/discussions/3704
Issue: https://github.com/ghostty-org/ghostty/issues/4038
2024-12-30 10:53:32 -08:00
Mitchell Hashimoto
397bf41ec3 Ensure correct coordinate ordering in selection file write (#4078)
## Description

Fix an issue where `write_selection_file` would create empty files when
selecting multiple lines. This occurred because the selection
coordinates were not properly ordered when writing to file.

## Problem

When selecting multiple lines from bottom to top , the resulting file
would be empty. This happened because:

1. Selection coordinates were used directly without proper ordering

2. `start()` and `end()` don't guarantee top-to-bottom, left-to-right
ordering

## Solution

Use `topLeft()` and `bottomRight()` methods to ensure correct coordinate
ordering when writing selection to file.


## Testing

Tested the following scenarios:

- Selecting multiple lines from top to bottom 

- Selecting multiple lines from bottom to top 


## Known Behavior

When selecting a single word, the entire line containing that word is
written to the file. This is consistent with the current terminal
behavior as noted in the [original
discussion](https://github.com/ghostty-org/ghostty/discussions/3594).

Fixes ghostty-org/ghostty#3594
2024-12-30 10:51:38 -08:00
Jan200101
c87e3e98a3 give strip option a proper description 2024-12-30 18:37:59 +01:00
Bryan Lee
a1f7a95763 Add pin order assertion in Pin.pageIterator 2024-12-31 01:14:56 +08:00
Bryan Lee
c62f64866c Ensure correct coordinate ordering in selection file write
When writing selected text to file, use `topLeft` and `bottomRight` instead of
`start` and `end` to ensure correct coordinate ordering. This fixes an issue
where selection files could be empty when selecting text in reverse order.

- Use `terminal.Selection.topLeft()` for start coordinate
- Use `terminal.Selection.bottomRight()` for end coordinate
2024-12-31 01:14:56 +08:00
Mitchell Hashimoto
716848cb58 macos: always have terminal fullscreen style (#3831)
~~When processing toggle_fullscreen actions, multiple FullscreenStyle
derived objects would register observers on the same window and
subsequently remove them when the old style was deinited.~~

~~This change passes ownership of the fullscreenNotification observers
to TerminalController while still allowing FullscreenStyles access to
the window for style specific actions.~~

We need to have at least one fullscreen style (even if it is not being
used) to make sure that observers for fullscreen state changes are set
up. An alternative approach would be the first version of this PR (for
which my reasoning was wrong but the end change was correct) which
registers the fullscreen observers at either the TerminalController or
BaseTerminalController level.

Fixes #3553
2024-12-30 08:56:19 -08:00
Mitchell Hashimoto
a7c93cdfb1 apprt/gtk: fix the combination of gtk-titlebar=false and gtk-tabs-location=hidden (#3957)
Fixes: #3178
2024-12-30 08:55:22 -08:00
Mitchell Hashimoto
e17bb69645 config: edit opens AppSupport over XDG on macOS, prefers non-empty paths (#4004)
Fixes #3953
Fixes #3284

This fixes two issues. In fixing one issue, the other became apparent so
I fixed both in this one commit.

The first issue is that on macOS, the `open` command should take the
`-t` flag to open text files in a text editor. To do this, the `os.open`
function now takes a type hint that is used to better do the right
thing.

Second, the order of the paths that we attempt to open when editing a
config on macOS is wrong. Our priority when loading configs is well
documented:
https://ghostty.org/docs/config#macos-specific-path-(macos-only). But
open_config does the opposite. This makes it too easy for people to have
configs that are being overridden without them realizing it.

This commit changes the order of the paths to match the documented
order. If neither path exists, we prefer AppSupport.
2024-12-30 08:52:55 -08:00
Mitchell Hashimoto
318641f5a1 surface: handle hyperlinks more reliably (#3903)
We refresh the link hover state in two (generic) cases

1. When the modifiers change
2. When the cursor changes position

Each of these have additional state qualifiers. Modify the qualifiers
such that we refresh links under the following scenarios:

1. Modifiers change
  - Control is pressed (this is handled in the renderer)
  - Mouse reporting is off
    OR
    Mouse reporting is on AND shift is pressed AND we are NOT reporting
    shift to the terminal

2. Cursor changes position
  - Control is pressed (this is handled in the renderer)
  - We previously were over a link
  - The position changed (or we had no previous position)
  - Mouse reporting is off
    OR
    Mouse reporting is on AND shift is pressed AND we are NOT reporting
    shift to the terminal

This fixes a few issues with the previous implementation:

1. If mouse reporting was on and you were over a link, pressing ctrl
   would enable link hover state. If you moved your mouse, you would
   exit that state. The logic in the keyCallback and the
   cursorPosCallback was not the same. Now, they both check for the same
   set of conditions
2. If mouse reporting was off, you could hold control and move the mouse
   to discover links. If mouse reporting was on, holding control + shift
   would not allow you to discover links. You had to be hovering one
   when you pressed the modifiers. Previously, we only refreshed links
   if we *weren't* reporting the mouse event. Now, we refresh links even
   even if we report a mouse event (ie a mouse motion event with the
   shift modifier pressed *will* hover links and also report events)

## Old Behavior

Notice that the state of the hyperlink is erratic in `comlink`. When I
am over it and press ctrl the link is underlined and the url hint in the
lower left shown for one frame, but then the state is dropped.


https://github.com/user-attachments/assets/52d6a8c8-8459-4d67-85eb-5d91f9833771

## New Behavior

State is retained when holding ctrl+shift. And the link only underlines
if I press both ctrl+shift. If I move the mouse around while holding
these keys, I can discover new links.


https://github.com/user-attachments/assets/78fa8e97-eb0c-4618-bd96-fe40d6bc67ce
2024-12-30 08:50:35 -08:00
Mitchell Hashimoto
26b1888494 apprt/gtk: move some static CSS to the style.css file (#4011) 2024-12-30 08:47:55 -08:00
Mitchell Hashimoto
1a27ce0797 bash: improved 'sudo' command wrapper (#4080)
The previous approach to wrapping `sudo` had a few shortcomings:

1. We were (re)defining our 'sudo' function wrapper in the "precmd"
path. It only needs to be defined once in the shell session.
2. If there was an existing 'sudo' alias, the function definition would
conflict and result in a syntax error.

Fix (1) by hoisting the 'sudo' function into global scope. I also
considered only defining our wrapper if an executable `sudo` binary
could be found (e.g. `-x $(builtin command -v sudo)`, but let's keep the
existing behavior for now. This allows for a `sudo` command to be
installed later in the shell session and still be wrapped.

Address (2) by defining the wrapper function using `function sudo`
(instead of `sudo()`) syntax. An explicit function definition won't
clash with an existing 'sudo' alias, although the alias will continue to
take precedence (i.e. our wrapper won't be called). If the alias is
defined _after_ our 'sudo' function is defined, our function will call
the aliased command.

This ordering is relevant because it can result in different behaviors
depending on when a user defines their aliases relative to sourcing the
shell integration script. Our recommendation remains that users either
use automatic shell injection or manually source the shell integration
script _before_ other things in their `.bashrc`, so that aligns with the
expected behavior of the 'sudo' wrapper with regard to aliases. Given
that, I don't think we need any more explicit user-facing documentation
on this beyond the script-level comments.
2024-12-30 08:44:47 -08:00
Mitchell Hashimoto
adcaff7137 config: edit opens AppSupport over XDG on macOS, prefers non-empty paths
Fixes #3953
Fixes #3284

This fixes two issues. In fixing one issue, the other became apparent so
I fixed both in this one commit.

The first issue is that on macOS, the `open` command should take the
`-t` flag to open text files in a text editor. To do this, the `os.open`
function now takes a type hint that is used to better do the right
thing.

Second, the order of the paths that we attempt to open when editing a
config on macOS is wrong. Our priority when loading configs is well documented:
https://ghostty.org/docs/config#macos-specific-path-(macos-only). But
open_config does the opposite. This makes it too easy for people to have
configs that are being overridden without them realizing it.

This commit changes the order of the paths to match the documented
order. If neither path exists, we prefer AppSupport.
2024-12-30 08:43:59 -08:00
Mitchell Hashimoto
c2c578789b Correct comptime GTK atLeast() version comparison (#3977)
The comptime path of the GTK `atLeast()` version function fails to take
the proceeding portion of the version into account. For example version
5.1.0 is incorrectly marked as less than 4.16.7 due to the minor version
(1) being less than the minor we are comparing against (16).

This update required that the major versions be equal when comparing
minor versions and the major and minor versions be equal when comparing
micro versions.

For example, building against GTK 4.17.1:
Before: version.atLeast(4,16,2) -> false
After:  version.atLeast(4,16,2) -> true
2024-12-30 08:39:56 -08:00
Mitchell Hashimoto
1c2532c184 gtk: correct comptime adwaita.versionAtLeast() comparison (#4084)
Companion to #3977
2024-12-30 08:39:47 -08:00
Mitchell Hashimoto
ff50b5539e fix: quick terminal CPU spikes (#4055)
# Description

The following code is causing an infinite loop that causes a CPU spikes
until the quick terminal is displayed:

87bd0bb744/macos/Sources/Features/QuickTerminal/QuickTerminalController.swift (L314-L317)

## Reproduce steps
1. Open Ghostty.
2. Open the Quick Terminal.
3. Close the Quick Terminal.
4. Reload the configuration (Ghostty > Reload Configuration or
`shift+cmd+,`).
5. Observe CPU spike.

## Fix
Now, `syncAppearance` doesn't postpone the process until it can be
consumed, and the appearance is synchronized once the animation is done
and the quick terminal is visible.

Fixes #3998
2024-12-30 08:21:21 -08:00
Jeffrey C. Ollie
f2ac9b85e3 gtk: correct comptime adwaita.versionAtLeast() comparison 2024-12-30 09:52:21 -06:00
Ayman Bagabas
66681f94e0 fix: handle intermediate bytes in CSI and ESC sequences
This adds missing handling for CSI and ESC commands.

Fixes: https://github.com/ghostty-org/ghostty/issues/3122
2024-12-30 18:26:05 +03:00
Damien Mehala
011c17da41 fix: quick terminal CPU spikes
Fixes #3998
2024-12-30 07:24:35 -08:00
Mitchell Hashimoto
da186fb9df bash: remove "request for experts" comment (#4081)
We now have a multiple folks who have pitched in to improve this script.
2024-12-30 07:22:25 -08:00
Jon Parise
0dc3ea35c0 bash: remove "request for experts" comment
We now have a multiple folks who have pitched in to improve this script.
2024-12-30 10:19:55 -05:00
Jon Parise
4e7982fc2b bash: improved 'sudo' command wrapper
The previous approach to wrapping `sudo` had a few shortcomings:

1. We were (re)defining our 'sudo' function wrapper in the "precmd"
   path. It only needs to be defined once in the shell session.
2. If there was an existing 'sudo' alias, the function definition would
   conflict and result in a syntax error.

Fix (1) by hoisting the 'sudo' function into global scope. I also
considered only defining our wrapper if an executable `sudo` binary
could be found (e.g. `-x $(builtin command -v sudo)`, but let's keep the
existing behavior for now. This allows for a `sudo` command to be
installed later in the shell session and still be wrapped.

Address (2) by defining the wrapper function using `function sudo`
(instead of `sudo()`) syntax. An explicit function definition won't
clash with an existing 'sudo' alias, although the alias will continue to
take precedence (i.e. our wrapper won't be called). If the alias is
defined _after_ our 'sudo' function is defined, our function will call
the aliased command.

This ordering is relevant because it can result in different behaviors
depending on when a user defines their aliases relative to sourcing the
shell integration script. Our recommendation remains that users either
use automatic shell injection or manually source the shell integration
script _before_ other things in their `.bashrc`, so that aligns with the
expected behavior of the 'sudo' wrapper with regard to aliases. Given
that, I don't think we need any more explicit user-facing documentation
on this beyond the script-level comments.
2024-12-30 10:15:04 -05:00
Iain H
4f2110bce0 Be more idiomatic in tests when comparing to booleans 2024-12-30 08:25:03 -06:00
Mitchell Hashimoto
89e5ca2fb4 macos: add generated Nvim files to app bundle (#4031)
resolves #3966

<img width="689" alt="image"
src="https://github.com/user-attachments/assets/a969e1ee-2302-44cf-857d-f71345d4840b"
/>
2024-12-30 06:23:44 -08:00
Damien Mehala
33b1131a14 fix: selected text remains after clear_screen action
Fixes #3414
2024-12-30 11:03:59 +01:00
Maciej Bartczak
d01b2397f1 fish: handle short boolean flags 2024-12-30 10:39:43 +01:00
Maciej Bartczak
aed61b62ae zsh: handle short boolean flags 2024-12-30 10:29:28 +01:00
Leigh Oliver
e9bc033b88 fix(gtk): fix issue detecting preferred color scheme 2024-12-30 09:17:46 +00:00
Bryan Lee
c011c4622d macos: add generated Nvim files to app bundle 2024-12-30 17:01:48 +08:00
Tristan Partin
057dd3e209 apprt/gtk: move some static CSS to the style.css file
Signed-off-by: Tristan Partin <tristan@partin.io>
2024-12-29 23:51:29 -06:00
Mitchell Hashimoto
87bd0bb744 gtk: Install 1024x1024 icon (#4003)
Fixes #3967

Include the 1024x1024 icon in the files installed by `build.zig` when
building the package for Linux with the GTK app runtime.
2024-12-29 21:18:41 -08:00
Arvin Verain
cfeed2b7a2 gtk: Install 1024x1024 icon 2024-12-30 13:05:57 +08:00
Mitchell Hashimoto
d2d6f8b9f4 apprt/gtk: make window-decoration=false with gtk-titlebar=true look better (#3999)
Before this change, there seemed to be some artifacting in the window
corners due to the window border no longer outlining the content
properly. By detecting the situation, we can turn the window border
radius off.
2024-12-29 21:01:01 -08:00
Tristan Partin
31c9a2fe59 apprt/gtk: make window-decoration=false with gtk-titlebar=true look better
Before this change, there seemed to be some artifacting in the window
corners due to the window border no longer outlining the content
properly. By detecting the situation, we can turn the window border
radius off.

Signed-off-by: Tristan Partin <tristan@partin.io>
2024-12-29 22:57:48 -06:00
moni-dz
4d983a2083 surface: don't issue mode 2031 DSR reports when colors are changed by a VT sequence 2024-12-30 12:33:05 +08:00
Tristan Partin
0fd65035c5 apprt/gtk: fix the combination of gtk-titlebar=false and gtk-tabs-location=hidden
Fixes: #3178
Signed-off-by: Tristan Partin <tristan@partin.io>
2024-12-29 22:12:37 -06:00
Mitchell Hashimoto
3059d9036b macos: Help menu goes to website docs (#3990) 2024-12-29 19:32:13 -08:00
Mitchell Hashimoto
37c5f5a123 macos: Help menu goes to website docs 2024-12-29 19:27:22 -08:00
Mitchell Hashimoto
35eefd4240 Add back quotes for variables in the zsh shell integration to improve compatibility (#3989)
https://github.com/ghostty-org/ghostty/pull/3332#issuecomment-2564526118
According to this comment, using variables without quoting may not work
with `setopt SH_WORD_SPLIT`.

We don't need to quote variables in `[[ ]]` because it works
differently.
2024-12-29 19:26:09 -08:00
Caleb Norton
8607b1f844 macos: correctly save terminal fullscreen style 2024-12-29 21:24:48 -06:00
XiaoYan Li
a9c1a5c73c Add back quotes for variables in the zsh shell integration to improve compatibility
https://github.com/ghostty-org/ghostty/pull/3332#issuecomment-2564526118
According to this comment, using variables without quoting may not work with `setopt SH_WORD_SPLIT`.

We don't need to quote variables in `[[ ]]` because it works differently.
2024-12-30 11:24:39 +08:00
Mitchell Hashimoto
06389b280a macos: restore 0 blur-radius when reloading config (#3954)
If a blur radius config value was previously set but then removed or set
to 0, the new blur radius would not take effect on config reload due to
the early return clause.
2024-12-29 19:17:25 -08:00