5828 Commits

Author SHA1 Message Date
Leah Amelia Chen
98d77788f4 feat(config): generate default template when config file is not found
Closes #3203
2024-12-30 14:28:38 -08:00
Jeffrey C. Ollie
220d40e99a gtk: make sure that window-decoration is honored on all paths 2024-12-30 16:10:14 -06:00
Mitchell Hashimoto
d54817607c gtk: don't use gtk_window_set_titlebar if adwaita is enabled but it's older than 1.4.0 (#4110)
Fix #4097
2024-12-30 13:02:48 -08:00
Jeffrey C. Ollie
ffe1b7a872 gtk: don't use gtk_window_set_titlebar if adwaita is enabled but it's older than 1.4.0 2024-12-30 14:44:56 -06:00
Mitchell Hashimoto
0da8801dc9 Fix clipboard confirmation window typo (#4124)
uh just fixes a typo of appliclication instead of application for an
osc_52_read request
2024-12-30 12:41:40 -08:00
kaizo
bdeb93fe87 Fix clipboard confirmation window typo 2024-12-30 15:23:16 -05:00
Mitchell Hashimoto
e9edd21bed os: don't return stack memory
A regression from adcaff7137ef
2024-12-30 12:21:28 -08:00
Mitchell Hashimoto
ef542c6e63 Enable bitmap font usage under CoreText (#4115)
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

Reverts #3550 for obvious reasons, and may close issue #2168 because
this should now mean that bitmap fonts are properly supported under both
font backends due to #3837 - unless `otb` fonts are still not properly
supported under FreeType (they are not supported under CoreText because
CoreText does not know how to handle them).

I tested this change with the `.dfont` distribution of
[Cozette](https://github.com/slavfox/Cozette) v1.25.2 and saw no visual
issues.
2024-12-30 12:05:57 -08:00
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
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
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
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
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
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
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
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
Arvin Verain
cfeed2b7a2 gtk: Install 1024x1024 icon 2024-12-30 13:05:57 +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
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
Iain H
936d0c0d58 Add unit tests 2024-12-29 21:01:18 -06:00
Tristan Partin
7256ebe13d apprt/gtk: fix website link in about window 2024-12-29 16:47:44 -06:00
Caleb Norton
479e735e7f macos: restore 0 blur-radius when reloading config 2024-12-29 16:25:30 -06:00
Iain H
b3290f6887 Correct the comptime GTK atLeast() function
The comptime path of the GTK `atLeast()` version function fails to take
the preceeding 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).

For example, building against GTK 4.17.1:
Before: version.atLeast(4,16,2) -> false
After:  version.atLeast(4,16,2) -> true
2024-12-29 16:20:20 -06:00
Daniel Patterson
3e11476d32 Add "top" and "bottom" aliases 2024-12-29 22:05:28 +00:00
Mitchell Hashimoto
84a03aa202 Allow startup without $HOME writable
Fixes #3202

Two changes to get here:

1. Do not fail startup if crash reporting initialization fails. This is a
   non-critical feature and should not prevent the terminal from starting.

2. Avoid freeing Sentry transport on error path. This segfaults.
   Upstream issue will be reported separately.
2024-12-29 13:59:39 -08:00
Mitchell Hashimoto
5698358c2f apprt/gtk: style the tab overview when window-theme=ghostty (#3920)
This requires libadwaita main (to be 1.8).

Signed-off-by: Tristan Partin <tristan@partin.io>


https://github.com/user-attachments/assets/057abec5-f85b-4fbb-980c-c58a20e7ddc7
2024-12-29 13:30:44 -08:00
Mitchell Hashimoto
ff6e60be56 Fix typo in list-themes browser (#3919)
This is a small PR to fix a tiny continuity typo I noticed in the
list-themes viewer.

#### Before and After


![image](https://github.com/user-attachments/assets/c95b23bb-01ad-4e82-8f9b-0b8559d006ba)
2024-12-29 13:29:41 -08:00
Mitchell Hashimoto
db0da9a273 Fix typo in config reference: window-decorations -> window-decoration (#3930)
I made the same PR to the autogenerated reference here:
https://github.com/ghostty-org/website/pull/168.
2024-12-29 13:28:44 -08:00
Tristan Partin
27ddc2a9b2 apprt/gtk: create the tab overview even if gtk-titlebar=false
self.isAdwWindow() obscures that check a bit.

Signed-off-by: Tristan Partin <tristan@partin.io>
2024-12-29 14:45:45 -06:00