Commit Graph

756 Commits

Author SHA1 Message Date
Mitchell Hashimoto
eb335fb8dd cleanup by just scrolling in the renderer 2026-02-19 14:06:58 -08:00
benodiwal
263469755c refactor: remove unused stream handler scroll-to-bottom code
The renderer approach doesn't need termio changes.

Co-Authored-By: Sachin <sachinbeniwal0101@gmail.com>
2026-02-19 13:54:32 -08:00
benodiwal
e197b95c32 feat: scroll-to-bottom on output via renderer pin tracking
Co-Authored-By: Sachin <sachinbeniwal0101@gmail.com>
2026-02-19 13:53:27 -08:00
Jeffrey C. Ollie
1342eb5944 gtk: revamp cgroup/transient scope handling
This changes the way Ghostty assigns itself and subprocesses to
cgroups and how resource controls are applied.

* Ghostty itself no longer modifies it's own cgroup or moves itself
to a transient scope. To modify the main Ghostty process' resource
controls ensure that you're launching Ghostty with a systemd unit and
use the standard systemd methods for overriding and applying changes
to systemd units.

* If configured (on by default), the process used to run your command
will be moved to a transient systemd scope after it is forked from
Ghostty but before the user's command is executed. Resource controls
will be applied to the transient scope at this time. Changes to
the `linux-cgroup*` configuration entries will not alter existing
commands. If changes are made to the `linux-cgroup*` configuration
entries commands will need to be relaunched. Resource limits can also
be modified after launch outside of Ghostty using systemd tooling. The
transient scope name can be shown by running `systemctl --user whoami`
in a shell running inside Ghostty.

Fixes #2084.
Related to #6669
2026-02-17 12:54:26 -06:00
Mitchell Hashimoto
7895bf1d02 shell-integration: respect cursor-style-blink (#10643)
The `cursor` shell feature always used a blinking bar (beam), often to
the surprise of users who set `cursor-style-blink = false`.

This change extends our GHOSTTY_SHELL_FEATURES format to include either
`cursor:blink` (default) or `cursor:steady` based on cursor-style-blink
when the `cursor` feature is enabled, and all shell integrations have
been updated to use that additional information to choose the DECSCUSR
cursor value (5=blinking bar, 6=steady bar).

I also considered passing a DECSCUSR value in GHOSTTY_SHELL_FEATURES
(e.g. `cursor:5`). This mostly worked well, but zsh also needs the blink
state on its own for its block cursor. We also don't support any other
shell feature cursor configurability (e.g. the shape), so this was an
over generalization.

This does change the behavior for users who like the blinking bar in the
shell but have `cursor-blink-style = false` for other reasons. We could
provide additional `cursor` shell feature configurability (e.g.
`cursor:blink` in `shell-integration-features`), but I'll propose that
as its own change.

See: #2812
Closes: #8681

---

**AI Disclosure:** I did a lot of rubber ducking with Claude Code while
trying out various ideas. It was particularly useful for this kind of
feature because I could try out one thing and have it evaluate the
impact on all of the shell integration scripts at once.
2026-02-16 14:08:23 -08:00
Priyanshu
de49b7f27b rename copy_title action to copy_title_to_clipboard 2026-02-13 09:59:02 +05:30
Priyanshu
b4be13ed50 fix: copy_title_to_clipboard now respects user-overridden title
When a user renames a surface via "Change Terminal Title" and then
uses copy_title_to_clipboard, the raw terminal title was copied
instead of the custom name.

This adds a new `copy_title` apprt action so each platform resolves
the effective title (user override or terminal-set) before copying
to clipboard.

Fixes #10345
2026-02-13 01:19:15 +05:30
Jon Parise
3cfb9d64d1 shell-integration: respect cursor-style-blink
The `cursor` shell feature always used a blinking bar (beam), often to
the surprise of users who set `cursor-style-blink = false`.

This change extends our GHOSTTY_SHELL_FEATURES format to include either
`cursor:blink` (default) or `cursor:steady` based on cursor-style-blink
when the `cursor` feature is enabled, and all shell integrations have
been updated to use that additional information to choose the DECSCUSR
cursor value (5=blinking bar, 6=steady bar).

I also considered passing a DECSCUSR value in GHOSTTY_SHELL_FEATURES
(e.g. `cursor:5`). This mostly worked well, but zsh also needs the blink
state on its own for its block cursor. We also don't support any other
shell feature cursor configurability (e.g. the shape), so this was an
over generalization.

This does change the behavior for users who like the blinking bar in the
shell but have `cursor-blink-style = false` for other reasons. We could
provide additional `cursor` shell feature configurability, but I think
that's best left to a separate change.
2026-02-10 18:46:36 -05:00
Mitchell Hashimoto
6e2d59f8e5 Don't reset click count on prompt move so we can still double click 2026-02-02 19:53:53 -08:00
Mitchell Hashimoto
e478f3bf76 remove legacy promptPath 2026-02-02 15:18:09 -08:00
Mitchell Hashimoto
7af49f6cc6 Surface respects cl by using single arrow keys within a single line 2026-02-02 13:36:24 -08:00
Mitchell Hashimoto
25b6423e7b Handle Kitty click_events OSC133 extension 2026-02-02 10:44:35 -08:00
Mitchell Hashimoto
e9b6fea11c terminal: move semantic prompt state into its own field in screen 2026-02-02 09:19:18 -08:00
Mitchell Hashimoto
918c2934a3 terminal: add redraw=last for bash for OSC133 2026-01-31 15:26:14 -08:00
Mitchell Hashimoto
400d17aa0d inspector: remove cell picker 2026-01-31 08:47:15 -08:00
Mitchell Hashimoto
32ac82c66f inspector: no longer holds surface pointer 2026-01-31 08:47:15 -08:00
Mitchell Hashimoto
3e825dd608 inspector: clean up Inspector 2026-01-31 08:47:15 -08:00
Mitchell Hashimoto
c8ffc0faa5 termio: report color scheme synchronously (#9705)
The reporting of color scheme was handled asynchronously by queuing a
handler in the surface. This could lead to race conditions where the DSR
is reported after subsequent VT sequences.

Fixes #5922
2026-01-20 09:48:43 -08:00
Mitchell Hashimoto
2e0141fcdf config: clarify selection-word-boundary docs 2026-01-20 09:38:41 -08:00
mauroporras
9b7c20f500 refactor: use u21 for Unicode codepoints and Zig 0.15 ArrayList
- Change all codepoint types from u32 to u21 to align with Zig stdlib
- Update ArrayList to use Zig 0.15 unmanaged pattern (.empty)
- Remove unnecessary @intCast when encoding UTF-8
- Fix formatEntry to use stack-allocated buffer
2026-01-20 09:37:31 -08:00
mauroporras
27602bb4b4 refactor: optimize selection-word-chars with pre-parsed codepoints
Refactor the selection-word-chars implementation to parse UTF-8 boundary
characters once during config initialization instead of on every selection
operation.

Changes:
- Add SelectionWordChars type that stores pre-parsed []const u32 codepoints
- Parse UTF-8 to codepoints in parseCLI() during config load
- Remove UTF-8 parsing logic from selectWord() hot path (27 lines removed)
- Remove arbitrary 64-character buffer limit
- Update selectWord() and selectWordBetween() to accept []const u32
- Update DerivedConfig to store codepoints directly
- Update all tests to use codepoint arrays

Benefits:
- No runtime UTF-8 parsing overhead on every selection
- No arbitrary character limit (uses allocator instead)
- Cleaner separation of concerns (config handles parsing, selection uses data)
- Better performance in selection hot path
2026-01-20 09:37:31 -08:00
mauroporras
811e3594eb feat: add configurable word boundary characters for text selection
Add new `selection-word-chars` config option to customize which characters
mark word boundaries during text selection operations (double-click, word
selection, etc.). Similar to zsh's WORDCHARS environment variable, but
specifies boundary characters rather than word characters.

Default boundaries: ` \t'"│`|:;,()[]{}<>$`

Users can now customize word selection behavior, such as treating
semicolons as part of words or excluding periods from boundaries:

    selection-word-chars = " \t'\"│`|:,()[]{}<>$"

Changes:
- Add selection-word-chars config field with comprehensive documentation
- Modify selectWord() and selectWordBetween() to accept boundary_chars parameter
- Parse UTF-8 boundary string to u32 codepoints at runtime
- Update all call sites in Surface.zig and embedded.zig
- Update all test cases to pass boundary characters
2026-01-20 09:37:31 -08:00
Tobias Kohlbau
836d794b9e termio: report color scheme synchronously
The reporting of color scheme was handled asynchronously by queuing a
handler in the surface. This could lead to race conditions where the
DSR is reported after subsequent VT sequences.

Fixes #5922
2026-01-19 07:49:57 +01:00
Mike Kasberg
2587a2efb4 feat: Select/Copy Links On Right Click If Present
This is a solution for #2107.

When a user right-clicks, and there's no existing selection, the
existing behavior is to try to select the word under the cursor:

3548acfac6/src/Surface.zig (L3740-L3742)

This PR tweaks that behavior _slightly_: If there's a link under our
cursor, as determined by `linkAtPos`, select the link (to copy with the
right-click context menu). Otherwise, select the word as before.

As noted in #2107, this matches the behavior of iTerm and Gnome
Terminal.

It's worth noting that `linkAtPos` already does the right thing in terms
of checking the links from config and their highlight/hover states
(modified by Ctrl or Super depending on platform).

3548acfac6/src/Surface.zig (L3896-L3901)

It also therefore respects `link-url` from config.

3548acfac6/src/config/Config.zig (L3411-L3416)

By using `linkAtPos`, we get all that behavior for free. In practical
terms, that means:
 - If I'm holding Ctrl so a link is underlined and I right click on it,
   it selects the underlined link.
 - If I'm not holding Ctrl and I right click on a link that is not
   underlined, it selects the word as before.
 - This behavior respects per-platform key bindings and user config
   settings.

`linkAtPos` requires that the render state mutex is held. I believe it's
safe to call because we're inside a block holding the mutex:
3548acfac6/src/Surface.zig (L3702-L3704)

**AI Disclosure:** I used Gemini CLI to help me with this PR because
while I have many years of programming experience, this is my first time
writing Zig. I prototyped a couple different approaches with AI before
landing on this one, so AI generated various prototypes and I chose the
final imlementation. I've verified that my code compiles and works as
intended.
2026-01-13 18:57:35 -07:00
rhodes-b
50516ed581 add search selection for GTK 2026-01-10 19:45:05 -06:00
Mitchell Hashimoto
856ef1fc1b input: change the key_is_binding to return some information 2026-01-09 06:51:48 -08:00
Mitchell Hashimoto
5b24aebcab update to use new RemapSet 2026-01-08 10:22:56 -08:00
Jagjeevan Kashid
111b0996d2 feat: key-remap configuration to remap modifiers at the app-level
Signed-off-by: Jagjeevan Kashid <jagjeevandev97@gmail.com>
2026-01-08 10:22:56 -08:00
Mitchell Hashimoto
6659315760 tweaks to link detection 2026-01-07 10:03:15 -08:00
teamchong
5a042570c8 feat: select entire URL on double-click
When double-clicking text, first check if the position is part of a URL
using the default URL regex pattern. If a URL is detected, select the
entire URL instead of just the word.

This follows the feedback from PR #2324 to modify the selection behavior
rather than introducing a separate selectLink function. The implementation
uses the existing URL regex from config/url.zig which already handles
various URL schemes (http, https, ftp, ssh, etc.) and file paths.

The URL detection runs before the normal word selection, falling back to
selectWord if no URL is found at the clicked position.
2026-01-07 10:03:15 -08:00
Mitchell Hashimoto
8e28f58b42 rename the selection search binding, unify into start_search action 2026-01-06 14:10:42 -08:00
Aaron Ruan
9b6a3be993 macOS: Selection for Find feature
Adds the `selection_for_search` action, with Cmd+E keybind by default.
This action inputs the currently selected text into the search
field without changing focus, matching standard macOS behavior.
2026-01-06 22:21:55 +08:00
Mitchell Hashimoto
61df50d70b input: add end_key_sequence binding action
End the currently active key sequence, if any, and flush the
keys up to this point to the terminal, excluding the key that
triggered this action.

For example: `ctrl+w>escape=end_key_sequence` would encode
`ctrl+w` to the terminal and exit the key sequence.

Normally, an invalid sequence will reset the key sequence and
flush all data including the invalid key. This action allows
you to flush only the prior keys, which is useful when you want
to bind something like a control key (`ctrl+w`) but not send
additional inputs.
2025-12-29 12:07:54 -08:00
cyppe
0da650e7dd gtk: support performable keybinds for clipboard paste
Make clipboardRequest return bool to indicate whether the action could
be performed. For paste requests, synchronously check if the clipboard
contains text formats before starting the async read.

This allows 'performable:paste_from_clipboard' keybinds to pass through
when the clipboard contains non-text content (e.g., images), enabling
terminal applications to handle their own clipboard reading.

Changes:
- Surface.startClipboardRequest now returns bool
- paste_from_clipboard/paste_from_selection actions return the result
- GTK apprt checks clipboard formats synchronously before async read
- Embedded apprt always returns true (can't check synchronously)
- All other call sites discard the return value with _
2025-12-29 15:50:06 +01:00
rezky_nightky
bf73f75304 chore: fixed some typo
Author: rezky_nightky <with dot rezky at gmail dot com>
Repository: ghostty
Branch: main
Signing: GPG (4B65AAC2)
HashAlgo: BLAKE3

[ Block Metadata ]
BlockHash: c37f4ee817412728a8058ba6087f5ca6aaff5a845560447d595d8055972d0eac
PrevHash: 3510917a780936278debe21786b7bae3a2162cb3857957314c3b8702e921b3d4
PatchHash: 5e5bb4ab35df304ea13c3d297c6d9a965156052c82bccf852b1f00b7bcaa7dd4

FilesChanged: 18
Lines: +92 / -92

Timestamp: 2025-12-25T17:27:08Z
Signature1: c1970dbb94600d1e24dfe8efcc00f001664db7b777902df9632a689b1d9d1498
Signature2: 30babb1e3ca07264931e067bfe36c676fb7988c2e06f8c54e0c9538fe7c7fc9a
2025-12-26 00:27:08 +07:00
Mitchell Hashimoto
0db0655ea5 Invalid key sequence does not encode if a catch_all has ignore
This adds some new special case handling for key sequences when an
unbound keyboard input is received. If the current keybinding set scope
(i.e. active tables) has a `catch_all` binding that would `ignore`
input, then the entire key sequence is dropped.

Normally, when an unbound key sequence is received, Ghostty encodes it
and sends it to the running program. 

This special behavior is useful for things like Vim mode which have `g>g`
to scroll to top, and a `catch_all=ignore` to drop all other input. If
the user presses `g>h` (unbound), you don't want `gh` to show up in your 
terminal input, because the `catch_all=ignore` indicates that the user
wants that mode to drop all unbound input.
2025-12-23 20:31:05 -08:00
Mitchell Hashimoto
dcbb3fe56f inspector: show chained bindings 2025-12-22 20:37:39 -08:00
Jeffrey C. Ollie
76c0bdf559 input: fix performable bindings 2025-12-22 17:48:04 -06:00
Mitchell Hashimoto
42c21eb16b input: leaf_chained tagged union value 2025-12-22 10:19:54 -08:00
Mitchell Hashimoto
18c8c338e0 Reset key tables on config reload, bound max active key tables
Two unrelated changes to polish key tables:

1. Key tables should be reset (deactivated) when teh config is reloaded.
   This matches the behavior of key sequences as well, which are reset
   on config reload. 

2. A maximum number of active key tables is now enforced (8).
   This prevents a misbehaving config from consuming too much memory
   by activating too many key tables. This is an arbitrary limit we
   can adjust later if needed.
2025-12-21 08:14:37 -08:00
Mitchell Hashimoto
44972198ae apprt: add action for key table activation/deactivation 2025-12-20 19:53:12 -08:00
Mitchell Hashimoto
845bcdb498 config: copy key table name into arena 2025-12-20 15:15:30 -08:00
Mitchell Hashimoto
daa613482e keybind = clear and reset should reset tables, too 2025-12-20 14:57:37 -08:00
Mitchell Hashimoto
14bbc4893f implement one-shot key tables 2025-12-20 14:36:39 -08:00
Mitchell Hashimoto
36f891afd8 implement key table lookup in maybeHandleBinding 2025-12-20 14:30:36 -08:00
Mitchell Hashimoto
18ce219d78 input: activate/deactivate key table binding actions 2025-12-20 14:23:02 -08:00
Mitchell Hashimoto
34ae3848b6 core: key tables 2025-12-20 14:04:11 -08:00
Mitchell Hashimoto
8c59143c1a rename some key sequence state so it is clearer what it is 2025-12-20 14:04:03 -08:00
Elad Kaplan
67f9bb9e8a Fix link opening by resolving existing relative paths 2025-12-17 15:13:47 +02:00
himura467
4c6d3f8ed2 macos: add toggle_background_opacity keybind action 2025-12-16 11:32:10 -08:00