Commit Graph

114 Commits (e28e4facf01b07509ac299939f4e5ec18e29fc30)

Author SHA1 Message Date
Mitchell Hashimoto 1fdc0c0b9f
terminal: CSI S compatiblity improvements
Fixes #9905

This fixes a major compatibility issues with the CSI S sequence:

When our top margin is at the top (row 0) without left/right
margins, we should be creating scrollback. Previously, we were
only deleting.
2025-12-14 14:36:42 -08:00
Mitchell Hashimoto 86cd489701
terminal/tmux: introduce command queue for viewer 2025-12-08 09:00:38 -08:00
Mitchell Hashimoto ec5a60a119
terminal/tmux: make sure we always have space for one action 2025-12-08 07:27:37 -08:00
Mitchell Hashimoto b26c42f4a6
terminal/tmux: better formatting for notifications and actions 2025-12-08 07:00:44 -08:00
Mitchell Hashimoto 52dbca3d26
termio: hook up tmux viewer 2025-12-08 07:00:43 -08:00
Mitchell Hashimoto 0d75a78747
terminal/tmux: start viewer state machine 2025-12-08 07:00:43 -08:00
Qwerasd 212598ed66 perf: add branch hints based on real world data
+ move stream ESC state entry outside of `nextNonUtf8`
2025-11-18 20:43:31 -07:00
Qwerasd 6d5b4a3426 perf: replace `std.debug.assert` with inlined version
See doc comment in `quirks.zig` for reasoning
2025-11-17 12:13:56 -07:00
Mitchell Hashimoto 580f9f057b
convert t.screen to t.screens.active 2025-11-14 15:40:31 -08:00
Mitchell Hashimoto 3aff5f0aff
ScreenSet 2025-11-14 15:08:10 -08:00
Mitchell Hashimoto 2daecd94a5
renderer: use terminal color state, remove color messages 2025-10-30 09:52:39 -07:00
Mitchell Hashimoto 77343bb06e
terminal: move color state fully into the terminal for fg/bg/cursor 2025-10-30 09:33:21 -07:00
Mitchell Hashimoto cabca0aca8
terminal: unify palette functionality into shared type DynamicPalette 2025-10-30 09:15:43 -07:00
Mitchell Hashimoto 1d03451d4f
terminal: OSC color operations 2025-10-25 07:03:21 -07:00
Mitchell Hashimoto e13f9b9e8c
terminal: kitty color 2025-10-25 06:42:20 -07:00
Mitchell Hashimoto e49694439c
terminal: setAttribute 2025-10-24 11:53:25 -07:00
Mitchell Hashimoto 5ba451d073
terminal: configureCharset 2025-10-24 11:27:48 -07:00
Mitchell Hashimoto 4d028dac1f
terminal: some osc types 2025-10-24 11:17:31 -07:00
Mitchell Hashimoto bce1164ae6
terminal: cursor style 2025-10-24 07:26:04 -07:00
Mitchell Hashimoto fd0f9bb843
terminal: device attributes 2025-10-24 07:17:44 -07:00
Mitchell Hashimoto e347ab6915
terminal: device attributes 2025-10-24 07:08:34 -07:00
Mitchell Hashimoto 109376115b
terminal: convert dcs 2025-10-23 21:29:18 -07:00
Mitchell Hashimoto 6902d89d91
terminal: convert APC 2025-10-23 21:24:31 -07:00
Mitchell Hashimoto b91149f0fe
terminal: simple esc dispatch 2025-10-23 21:18:51 -07:00
Mitchell Hashimoto 9cd4594356
terminal: active status display 2025-10-23 21:14:21 -07:00
Mitchell Hashimoto f68ea7c907
terminal: many more conversions 2025-10-23 21:10:25 -07:00
Mitchell Hashimoto 2520e27aef
terminal: kitty keyboard actions 2025-10-23 20:55:08 -07:00
Mitchell Hashimoto b7ea979f38
terminal: zero-arg actions 2025-10-23 20:47:02 -07:00
Mitchell Hashimoto 0df4d5c5a4
terminal: margins 2025-10-23 20:37:34 -07:00
Mitchell Hashimoto c1e57dd330
terminal: setprotectedmode 2025-10-23 20:31:17 -07:00
Mitchell Hashimoto 25eee9379d
terminal: request mode 2025-10-23 20:26:14 -07:00
Mitchell Hashimoto b6ac4c764f
terminal: modify_other_keys 2025-10-23 20:26:11 -07:00
Mitchell Hashimoto 94a8fa05cb
terminal: convert modes 2025-10-23 20:07:45 -07:00
Mitchell Hashimoto dc5406781f
terminal: many more conversions 2025-10-23 19:56:13 -07:00
Mitchell Hashimoto 37016d8b89
terminal: erase/insert lines, characters, etc. 2025-10-23 16:44:49 -07:00
Mitchell Hashimoto b0fb3ef9a9
terminal: erase display conversion 2025-10-23 16:38:10 -07:00
Mitchell Hashimoto b5da54d925
terminal: horizontal tab 2025-10-23 16:28:38 -07:00
Mitchell Hashimoto ccd821a0ff
terminal: convert cursor movements 2025-10-23 16:22:43 -07:00
Mitchell Hashimoto 2ef89c153a
terminal: convert C0 2025-10-23 15:52:42 -07:00
Mitchell Hashimoto f7189d14b9
terminal: convert Stream to use Action tagged union 2025-10-23 15:50:56 -07:00
Mitchell Hashimoto 014a2e0042
termio: color change operations must gracefully handle renderer mailbox full (#9224)
Fixes #9191

This changes our color change operations from writing to the renderer
mailbox directly to using our `rendererMailboxWriter` function which
handles the scenario where the mailbox is full by yielding the lock,
waking up the renderer, and retrying later.

This is a known deadlock scenario we've worked around since the private
beta days, but unfortunately this slipped through and I didn't catch it
in review.

What happens here is it's possible with certain escape sequences for the
IO thread to saturate other mailboxes with messages while holding the
terminal state lock. This can happen to any thread. This ultimately
leads to starvation and all threads deadlock.

Our IO thread is the only thread that produces this kind of massive
stream of events while holding the lock, so we have helpers in it to
attempt to queue (cheap, fast) and if that fails then to yield the lock,
wakeup the target thread, requeue, and grab the lock again (expensive,
slow).
2025-10-15 16:01:26 -07:00
Jon Parise e5247f6d10
termio: reimplement OSC 7 URI handling (#9193)
This reimplements the MAC address-aware URI parsing logic used by the
OSC 7 handler and adds an additional .raw_path option that returns the
full, unencoded path string (including query and fragment values), which
is needed for compliant kitty-shell-cwd:// handling.

Notably, this implementation takes an options-based approach that allows
these additional behaviors to be enabled at runtime. It also leverages
two std.Uri.parse guarantees:

1. Return slices point into the original text string.
2. .raw components don't require unescaping (.percent_encoded does).

The implementation is in a new 'os.uri' module because its now generic
enough to not be hostname-oriented.

We use os.uri.parseUri and its parsing options to reimplement our OSC 7
file-style URI handling. This has two advantages:

First, it fixes kitty-shell-cwd scheme handling. This scheme expects the
full, unencoded path string, whereas the file scheme expects normal URI
percent encoding. This was preventing paths containing "special" URI
characters (like "path?") from working correctly in our bash, zsh, and
elvish shell integrations, which report working directories using the
kitty-shell-cwd scheme. (fish uses file URIs, which work as expected.)

Second, we can greatly simplify our hostname and path string handling
because we can now rely on the "raw" std.Uri component form to always
provide the correct representation.

Lastly, this lets us remove the previous URI-related code from the
os.hostname module, restoring its focus to hostname-related functions.

See: #5289
2025-10-14 12:12:45 -07:00
Mitchell Hashimoto d59d754e29
Zig 0.15: zig build GTK exe 2025-10-03 07:10:43 -07:00
Jeffrey C. Ollie 1c23ebc6f1
address review comments 2025-10-02 12:57:53 -05:00
Jeffrey C. Ollie 07124dba64
core: add 'command finished' notifications
Fixes #8991

Uses OSC 133 esc sequences to keep track of how long commands take to
execute. If the user chooses, commands that take longer than a user
specified limit will trigger a notification. The user can choose between
a bell notification or a desktop notification.
2025-10-02 12:40:40 -05:00
Qwerasd 43dd712053 termio: make trivial stream handler callbacks inline
Supported by benchmarks (vtebench on Apple M3 Max)
2025-09-30 07:27:40 -07:00
Mitchell Hashimoto d7c2a829bb
termio: don't send extra OSC terminator for color reports
Fixes #8613

I reiterate my comment in my own PR that this needs to be extracted so
we can unit test this. :)
2025-09-12 21:19:16 -07:00
Mitchell Hashimoto 3afc8019d5
terminal: update parser to use new color parser and stream handler 2025-09-11 12:32:31 -07:00
Jeffrey C. Ollie 7a60fb2d08
core/gtk: add support for displaying a progress bar with OSC 9;4
Ghostty has had support for a while (since PR #3124) for parsing progress
reports but never did anything with them. This PR adds the core
infrastructure and an implementation for GTK.

On GTK, the progress bar will show up as a thin bar along the top of
the terminal. Under normal circumstances it will use whatever you have
set as your accent color. If the progam sending the progress report
indicates an error, it will change to a reddish color.
2025-07-17 22:36:27 -05:00
Mitchell Hashimoto fb9c52ecf4
Nuke GLFW from Orbit
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-04 14:12:18 -07:00