6865 Commits

Author SHA1 Message Date
Jon Parise
65a7c81c94 bash: conditionally add cursor shape sequences
In #7808, we stopped using PS0 to reset the cursor shape because
restoring PS0 in __ghostty_preexec was causing issues (#7802).

The alternate approach of printing the cursor reset escape sequence
directly from __ghostty_preexec caused a new issue: the input cursor
would persist longer than intended, such as when a suspended vim process
was restored to the foreground.

This change takes a different approach. We now conditionally add the
cursor shape escape sequences to PS0 (and PS1, for consistency) when
they don't already appear. The fixes the cursor shape reset problem.

The main downside to this approach is that PS0 will continue to contain
this escape sequence; it won't be cleared/reset in __ghostty_preexec for
the reasons described in #7808. This feels like an acceptable outcome
because there's no harm in the modified PS0 existing for the life of the
bash session (rather than it being modified and then restored for each
command cycle), and it's consistent with how some other terminals' bash
integration works (e.g. kitty).
2025-07-06 18:39:32 -04:00
Qwerasd
d3aece21d8 font: more generic bearing adjustments
This generally adjusts the bearings of any glyph whose original advance
was narrower than the cell, which helps a lot with proportional fallback
glyphs so they aren't just left-aligned. This only applies to situations
where the glyph was originally narrower than the cell, so that we don't
mess up ligatures, and this centers the old advance width in the new one
rather than adjusting proportionally, because otherwise we can mess up
glyphs that are meant to align with others when placed vertically.
2025-07-06 16:34:31 -06:00
Mitchell Hashimoto
cbcb0b795c Fallback to cross-platform minimal open when apprt is not available 2025-07-06 15:15:48 -07:00
Jeffrey C. Ollie
70a2a0afd5 better ABI check for apprt.Action.CValue 2025-07-06 15:02:48 -07:00
Jeffrey C. Ollie
9583ea1b7a core/gtk: open urls using an apprt action instead of doing it directly
Partial implementation of #5256

This implements the core changes necessary to open urls using an apprt
action rather than doing it directly from the core.

Implements the open_url action in the GTK and GLFW apprts.

Note that this should not be merged until a macOS-savvy developer can add
an implementation of the open_url action for the macOS apprt.
2025-07-06 15:02:48 -07:00
Qwerasd
b10b0f06c3 font: remove unused fields from Glyph
We can reintroduce `advance` if we ever want to do proportional string
drawing, but we don't use it anywhere right now. And we also don't need
`sprite` anymore since that was just there to disable constraints for
sprites back when we did them on the GPU.
2025-07-06 15:53:59 -06:00
Sl (Shahaf Levi)
3ff11cdd86 Add Hebrew Translations 2025-07-06 23:38:22 +03:00
Mitchell Hashimoto
185a4ea10b Added bold-color option (#7168)
As discussed in https://github.com/ghostty-org/ghostty/discussions/3134

To allow for the option to render bold text in a different colour for
better visibility as an extension of `bold-is-bright`.

This is a feature that is available in other terminals.
2025-07-06 12:59:04 -07:00
Robert Ian Hawdon
52790fb92c Added bold-color option 2025-07-06 12:56:43 -07:00
Jeffrey C. Ollie
f40c9a4d38 keybind: add copy_title_to_clipboard action (#7833)
Fixes #7829

This will copy the terminal title to the clipboard. If the terminal
title is not set or the title is empty the action has no effect.
2025-07-06 14:34:20 -05:00
Jeffrey C. Ollie
7884872d4e keybind: don't clobber the clipboard if the title is empty 2025-07-06 14:15:11 -05:00
Mitchell Hashimoto
04c5bb2984 Add link-previews option (#7831)
Implement the `link-previews` option from
https://github.com/ghostty-org/ghostty/discussions/7727.

The feature request isn't accepted yet, but I had a bit of free time to
write this up and it was pretty quick, so I figure there's no harm in
proposing an implementation.

Demo of `link-previews = osc8`:



https://github.com/user-attachments/assets/17a72ab2-c727-4a85-9edd-9b6e7da05d98
2025-07-06 12:09:39 -07:00
Jeffrey C. Ollie
a23b5328a5 keybind: rename copy_title to copy_title_to_clipboard
Co-authored-by: Jon Parise <jon@indelible.org>
2025-07-06 13:12:00 -05:00
Qwerasd
c7e65b0c1c font: respect cell width attributes in nerd font constraints
This mostly applies to powerline glyphs, but is also relevant for heavy
bracket characters, which need to always be 1 wide otherwise they look
silly because they misalign depending on if there's a space after them
or not.
2025-07-06 11:23:49 -06:00
Jeffrey C. Ollie
3cf56b8af3 keybind: add copy_title action
Fixes #7829

This will copy the terminal title to the clipboard. If the terminal
title is not set it has no effect.
2025-07-06 12:12:27 -05:00
Qwerasd
8f989f6bfd font: fix nerd font codegen to handle ypadding properly
Previously `ypadding` was effectively ignored, since it's mutually
exclusive with `overlap`. This had a noticeable effect on the heavy
bracket characters U+276C...U+2771, which were much taller than they
should have been.

I also fixed the vertical overlap limit, since negative `overlap` values
are used in the nerd font attributes to create padding on all sides of
the cell, so we don't want to limit the magnitude of the overlap for
vertical padding, we only want to limit it if the value is positive.

That change fixed the vertical padding for a handful of ranges, which
should give more consistent results.
2025-07-06 11:02:00 -06:00
Qwerasd
7de4d569b0 Revert "rely on stdin/stdout instead of hardcoded paths"
This reverts commit 2fca0477bc7f3c955daf40a0d4663d63ef3d76a1.

The idea of using stdin and stdout was the integrate it in to the build
script, but since we don't want to do that because it contains an eval,
it just makes it more annoying to use.
2025-07-06 10:49:49 -06:00
Mitchell Hashimoto
43083f3af5 Add linux kernel information to +version (#7790)
Adds basic kernel information to `ghostty +version`. 
`ghostty +version` on my machine now prints:
```
Ghostty 1.1.4-kernel-version-info+cdbc78bce

Version
  - version: 1.1.4-kernel-version-info+cdbc78bce
  - channel: tip
Build Config
  - Zig version   : 0.14.1
  - build mode    : builtin.OptimizeMode.Debug
  - app runtime   : apprt.Runtime.gtk
  - font engine   : font.main.Backend.fontconfig_freetype
  - renderer      : renderer.generic.Renderer(renderer.OpenGL)
  - libxev        : io_uring
  - kernel version: 6.15.4-200.fc42.x86_64
  - desktop env   : other
  - GTK version   :
    build         : 4.18.5
    runtime       : 4.18.5
  - libadwaita    : enabled
    build         : 1.7.4
    runtime       : 1.7.4
  - libX11        : enabled
  - libwayland    : enabled

```


PS This is my first time writing prod code in Zig, so any suggestions
and guidelines are welcome
2025-07-06 07:01:26 -07:00
Jeffrey C. Ollie
eb5694794c keybind: add set_font_size
Fixes #7795

This allows the font size to be set to an absolute value.
2025-07-06 06:42:14 -07:00
Gregory Anders
9f3f9205d8 Add link-previews option 2025-07-06 08:33:11 -05:00
Jeffrey C. Ollie
b752ade112 gtk: don't allow focusing on tab overview or menu buttons
This prevents GTK from focusing on those buttons, which would prevent
focus from returning to the terminal after those buttons had been used.
2025-07-06 01:05:17 -05:00
Qwerasd
dc18f1a2b9 "Better Glyph Constraint Logic" follow-up (#7822)
Follow-up to #7809, a handful of small fixes/improvements, explained
individually in each commit message.

> [!NOTE]
> Similar to the inverted "monochrome" ft flag fix from #7809, it was
pointed out that "force-autohint" was also inverted, so I did invert
that too, this has the same result of no impact on users who haven't
explicitly set it, but a breaking behavior change for users who have set
it. *These changes definitely need to be pointed out in the 1.2 release
notes!*
2025-07-05 23:04:09 -06:00
Mitchell Hashimoto
104a46cfa4 macos: support configuration via CLI arguments (#7823)
This makes it so `zig build run` can take arguments such as
`--config-default-files=false` or any other configuration. Previously,
it only accepted commands such as `+version`.

Incidentally, this also makes it so that the app in general can now take
configuration arguments via the CLI if it is launched as a new instance
via `open`. For example:

    open -n Ghostty.app --args --config-default-files=false

This previously didn't work. This is kind of cool.

To make this work, the libghostty C API was modified so that
initialization requires the CLI args, and there is a new C API to try to
execute an action if it was set.
2025-07-05 21:44:12 -07:00
Mitchell Hashimoto
753f3ea72b refactor nerd font codegen script (#7819)
Mainly added type annotations, cleaned up weird AI slop and used more
idiomatic stuff.
This requires Python 3.12 to run (I can downgrade it if need be).
2025-07-05 21:36:04 -07:00
Mitchell Hashimoto
984d123fe4 macos: support configuration via CLI arguments
This makes it so `zig build run` can take arguments such as
`--config-default-files=false` or any other configuration. Previously,
it only accepted commands such as `+version`.

Incidentally, this also makes it so that the app in general can now take
configuration arguments via the CLI if it is launched as a new instance
via `open`. For example:

    open -n Ghostty.app --args --config-default-files=false

This previously didn't work. This is kind of cool.

To make this work, the libghostty C API was modified so that
initialization requires the CLI args, and there is a new C API to try to
execute an action if it was set.
2025-07-05 21:31:23 -07:00
Qwerasd
8f50c7f269 font/sprite: no more margin in atlas region
We no longer need a margin in the atlas because we always sample with
nearest neighbor and our glyphs are always pixel perfect, no worry about
interpolation between adjacent glyphs anymore!
2025-07-05 22:13:26 -06:00
Qwerasd
87f35bd1c1 renderer/opengl: explicit texture options
This sets up for a couple improvments (see TODO comments) and also sets
the glyph atlas textures to nearest neighbor sampling since we can do
that now that we never scale glyphs.
2025-07-05 22:10:39 -06:00
Mitchell Hashimoto
8c3caee15c macOS: zig build run disables window saved state 2025-07-05 19:58:17 -07:00
Qwerasd
02d82720d2 font/freetype: fix negated force-autohint flag
The behavior of this flag was the opposite of its description in the
docs- luckily, at the same time, the default (true) was the opposite
from what the default actually is in freetype, so users who haven't
explicitly set this flag won't see a behavior difference from this.
2025-07-05 20:40:12 -06:00
Qwerasd
fff16bff69 font/coretext: fix bitmap size calculation, prevent clipping
Previously, many glyphs were having their top and right row/column of
pixels clipped off due to not accounting for the slight bearing in the
width and height calculation here.
2025-07-05 20:36:35 -06:00
trag1c
2fca0477bc rely on stdin/stdout instead of hardcoded paths 2025-07-06 02:28:28 +02:00
trag1c
4b6c461d6f refactor nerd font codegen script 2025-07-06 02:08:46 +02:00
Jason Rayne
f242c6b5c4 Merge branch 'main' into ssh-integration 2025-07-05 14:54:31 -07:00
Mitchell Hashimoto
b799462745 Better Glyph Constraint Logic (#7809)
This is a big'un.

- **Glyph constraint logic is now done fully on the CPU** at the
rasterization stage, so it only needs to be done once per glyph instead
of every frame. This also lets us eliminate padding between glyphs on
the atlas because we're doing nearest-neighbor sampling instead of
interpolating-- which ever so slightly increases our packing efficiency.
- **Special constraints for nerd font glyphs** are applied based roughly
on the constraints they use in their patcher. It's a simplification of
what they do, the largest difference being that they scale groups of
glyphs based on a shared bounding box so that they maintain relative
size to one another, but that would require loading all glyphs on the
group and I'd want to do that on font load TBH and at that point I'd
basically be re-implementing the nerd fonts patcher in Zig to patch
fonts at load time which is way beyond the scope I want to have. (Fixes
#7069)
- These constraints allow for **perfectly sized and centered emojis**,
this is very nice.
- **Changed the default embedded fonts** from 4 copies (regular, italic,
bold, bold italic) of a patched (and outdated) JetBrains Mono to a
single JetBrains Mono variable font and a single Nerd Fonts Symbols Only
font. This cuts the weight of those down from 9MB to 3MB!
- **FreeType's `renderGlyph` is significantly reworked**, and the new
code is, IMO, much cleaner- although there are probably some edge case
behavior differences I've introduced.

> [!NOTE]
> One breaking change I definitely introduced is changing the
`monochrome` freetype load flag config from its previous completely
backwards meaning to instead the correct one (I also changed the
default, so this won't affect any user who hasn't touched it, but users
who set the `monochrome` flag will find their fonts quite crispy after
this change because they will have no anti-aliasing anymore)

### Future work

Following this change I want to get to work on automatic font size
matching (a la CSS
[`font-size-adjust`](https://developer.mozilla.org/en-US/docs/Web/CSS/font-size-adjust)).
I set the stage for that quite some time ago so it shouldn't be too much
work and it will be a big benefit for users who regularly use multiple
writing systems and so have multiple fonts for them that aren't
necessarily size-compatible.
2025-07-05 14:37:46 -07:00
Mitchell Hashimoto
390812828a Nuke GLFW, make zig build run on macOS build the Xcode project (#7815)
This PR does two things.

1. Build system improvements to make developing on macOS more enjoyable 
2. Delete the GLFW apprt

## Build System Improvements (macOS)

On macOS, there are a few major improvements:

* `zig build` now produces a full macOS app bundle and copies it into
`zig-out`
* `zig build run` now builds the macOS app and runs it, streaming logs
directly into the terminal
* `-Demit-macos-app` can control whether app bundle is created
* `-Dxcframework-target` can be set to one of `native` or `universal` to
control whether the xcframework uses only your target machines arch or
creates a universal one with macOS and iOS. This defaults to `native`
for the `run` command and `universal` for all others.
* The general flow of the `build.zig` file was improved to be more
declarative

## Nuke GLFW

> This deletes the GLFW apprt from the Ghostty codebase.
> 
> The GLFW apprt was the original apprt used by Ghostty (well, before
> Ghostty even had the concept of an "apprt" -- it was all just a single
> application then). It let me iterate on the core terminal features,
> rendering, etc. without bothering about the UI. It was a good way to
get
> started. But it has long since outlived its usefulness.
> 
> We've had a stable GTK apprt for Linux (and Windows via WSL) and a
> native macOS app via libghostty for awhile now. The GLFW apprt only
> remained within the tree for a few reasons:
> 
>   1. Primarily, it provided a faster feedback loop on macOS because
>      building the macOS app historically required us to hop out of the
>      zig build system and into Xcode, which is slow and cumbersome.
> 
>   2. It was a convenient way to narrow whether a bug was in the
> core Ghostty codebase or in the apprt itself. If a bug was in both
>      the glfw and macOS app then it was likely in the core.
> 
>   3. It provided us a way on macOS to test OpenGL.
> 
> All of these reasons are no longer valid. Respectively:
> 
> 1. Our Zig build scripts now execute the `xcodebuild` CLI directly and
>      can open the resulting app, stream logs, etc. This is the same
> experience we have on Linux. (Xcode has always been a dependency of
>      building on macOS in general, so this is not cumbersome.)
> 
>   2. We have a healthy group of maintainers, many of which have access
>      to both macOS and Linux, so we can quickly narrow down bugs
>      regardless of the apprt.
> 
> 3. Our OpenGL renderer hasn't been compatible with macOS for some time
>      now, so this is no longer a useful feature.
> 
> At this point, the GLFW apprt is just a burden. It adds complexity
> across the board, and some people try to run Ghostty with it in the
real
> world and get confused when it doesn't work (it's always been lacking
in
> features and buggy compared to the other apprts).
> 
> So, it's time to say goodbye. Its bittersweet because it is a big part
> of Ghostty's history, but we've grown up now and it's time to move on.
> Thank you, goodbye.
> 
> (NOTE: If you are a user of the GLFW apprt, then please fork the
project
> prior to this commit or start a new project based on it. We've warned
> against using it for a very, very long time now.)
2025-07-05 13:49:24 -07:00
Mitchell Hashimoto
0929f39e89 build: xcodebuild properly sets up resources 2025-07-05 13:36:31 -07:00
Jason Rayne
2d2df4b99f Merge branch 'main' into ssh-integration 2025-07-05 13:34:47 -07:00
Jason Rayne
a727b59b2b fix: replace custom const with std lib, remove dead-weight test
- Replaced custom const `SECONDS_PER_DAY` with `std.time.s_per_day`
- Removed concurrent access test - would need real file ops to be
meaningful
2025-07-05 13:24:59 -07:00
Jason Rayne
a22074a85c fix: optimize SSH integration and improve error handling
- Replace dual-loop SSH config parsing with efficient single-pass case
statement
- Remove overly cautious timeout logic from cache checks for simplicity
- Add base64 availability check with xterm-256color fallback when
missing
- Include hostname in terminfo setup messages for better UX
- Maintain SendEnv/SetEnv dual approach for maximum OpenSSH
compatibility (relying on SetEnv alone seems to drop some vars during my
tests, despite them being explicitly included in AcceptEnv on the remote
host)
2025-07-05 13:24:59 -07:00
Mitchell Hashimoto
8653229607 ci: don't use the new macOS app emit yet 2025-07-05 07:26:02 -07:00
Mitchell Hashimoto
8b44d0b3bb build: make zig build run on macOS work with an empty zig-out 2025-07-05 07:22:42 -07:00
Mitchell Hashimoto
5fc0bbc58f build: add -Demit-macos-app 2025-07-05 07:05:36 -07:00
Mitchell Hashimoto
f04a388f00 bash: stop using PS0 for the 'cursor' feature (#7808)
Our use of PS0 (which bash runs before command execution) was causing
raw command sequences to be printed between multiple commands in a
sequence.

    $ alias garbage='echo start
    > echo end'

    $ garbage
    start
    �\���dend

I wasn't able to definitely track down all of the reasons for why this
only happens in the command sequence case, but I suspect it's related to
the way that __ghostty_preexec runs from within the bash DEBUG trap (by
way of bash-preexec).

This problem occurs when PS0 is set to _any_ string (even "") inside of
__ghostty_preexec, which also rules out most/any Ghostty-specific code.
PS1 and PS2 appear to be safe to (re)set in this context.

Fortunately, we can avoid using PS0 entirely by instead printing the
cursor reset escape sequence directly from __ghostty_precmd because it
also runs just before command execution.

Fixes #7802
2025-07-04 21:05:41 -07:00
Daniel
1a4b128af3 replace nested if for readability 2025-07-04 21:36:17 -04:00
Jon Parise
b8931dd1db bash: stop using PS0 for the 'cursor' feature
Our use of PS0 (which bash runs before command execution) was causing
raw command sequences to be printed between multiple commands in a
sequence.

    $ alias garbage='echo start
    > echo end'

    $ garbage
    start
    �\���dend

I wasn't able to definitely track down all of the reasons for why this
only happens in the command sequence case, but I suspect it's related to
the way that __ghostty_preexec runs from within the bash DEBUG trap (by
way of bash-preexec).

This problem occurs when PS0 is set to _any_ string (even "") inside of
__ghostty_preexec, which also rules out most/any Ghostty-specific code.
PS1 and PS2 appear to be safe to (re)set in this context.

Fortunately, we can avoid using PS0 entirely by instead printing the
cursor reset escape sequence directly from __ghostty_precmd because it
also runs just before command execution.
2025-07-04 20:06:06 -04:00
Daniel
0b4a1e2154 added test for other cursor style 2025-07-04 18:54:55 -04:00
Daniel
a9fc3b6fa0 enable drawing cursor on top or bottom based on style 2025-07-04 18:50:23 -04:00
Daniel
de3e77570e add second cursor list 2025-07-04 18:26:27 -04:00
Qwerasd
41ff0b440b fix tests 2025-07-04 16:10:36 -06:00
Mitchell Hashimoto
91ee75ae4d build: add -Dxcframework-target to specify the target for builds 2025-07-04 15:01:14 -07:00