Fixes#5448
We previously removed the ctrl modifier for text commit (IME-style) to
workaround a libghostty quirk (as noted in the comment in the diff). But
this broke other keyboard layouts.
This commit attempts to clean this up slightly -- but not completely --
by removing that hack, and only modifying the ctrl behavior for the
UCKeyTranslate call.
Long term, I plan to remove UCKeyTranslate completely, as noted in the
todo comment already written just below this diff.
This fixes the aforementioned issue and hopefully doesn't regress any
other behavior. I tested the following:
1. Dvorak Ctrl characters
2. Ergo-L Ctrl characters
3. US standard Ctrl characters
4. Japanese IME input Ctrl input to modify IME state
Fixes#5448
We previously removed the ctrl modifier for text commit (IME-style)
to workaround a libghostty quirk (as noted in the comment in the diff).
But this broke other keyboard layouts.
This commit attempts to clean this up slightly -- but not completely --
by removing that hack, and only modifying the ctrl behavior for the
UCKeyTranslate call.
Long term, I plan to remove UCKeyTranslate completely, as noted in the
todo comment already written just below this diff.
This fixes the aforementioned issue and hopefully doesn't regress any
other behavior. I tested the following:
1. Dvorak Ctrl characters
2. Ergo-L Ctrl characters
3. US standard Ctrl characters
4. Japanese IME input Ctrl input to modify IME state
* implement `yQuads()` and `draw_octant()`, pretty obvious extensions of
existing code. to allocate up to 3 potential remainder lines, consider
that octants will often appear in a rectangular subset of the terminal.
we want the distributed excess uniformly distributed across such a
region. so:
* one excess row: break symmetry in any direction (pick an arbitrary
tetrad and use it everywhere)
* two excess rows: go to alternating tetrads
* three excess rows: break symmetry, do not use three contiguous tetrads
* our `Octant`s are octary arrays of `bool`, provided as a somewhat
opaque constant table
* the 8-line copy-and-paste draw based on the `Octant` is not the
prettiest thing in the known universe
* we could generalize `draw_sextant()` and `draw_octant()` like
notcurses did, almost certainly
* oh bird thou never wert
with that said, i don't think `draw_octant()` is actually being called
lol, so let's not merge this yet. happy to hear early feedback, though.
Adds buildtime and comptime checks to make sure that Blueprints/UI files
are availble and correctly formed. Will also compile Blueprints to UI
files so that they are available to GTK code.
Fixes#5718
When a terminal is resized with text reflow (i.e. soft-wrapped text),
the cursor is generally reflowed with it.
For example, imagine a terminal window 5-columns wide and you type the
following without pressing enter. The cursor is on the X.
```
OOOOO
OOX
```
If you resize the window now to 8 or more columns, this happens, as
expected:
```
OOOOOOOX
```
As expected, the cursor remains on the "X". This behaves like any other
text input...
Terminals also provide an escape sequence to
[save the cursor (ESC 7 aka
DECSC)](https://ghostty.org/docs/vt/esc/decsc). This includes, amongst
other things, the cursor position. The cursor can be restored with
[DECRC](https://ghostty.org/docs/vt/esc/decrc).
The behavior of the position of the _saved cursor_ in the context of
text reflow is unspecified and varies wildly between terminals Ghostty
does this right now (as do many other terminals):
```
OOOOOOOO
X
```
This commit changes the behavior so that we reflow the saved cursor.
Adds buildtime and comptime checks to make sure that Blueprints/UI files
are availble and correctly formed. Will also compile Blueprints to UI
files so that they are available to GTK code.
Fixes#5718
When a terminal is resized with text reflow (i.e. soft-wrapped text), the cursor
is generally reflowed with it.
For example, imagine a terminal window 5-columns wide and you type the
following without pressing enter. The cursor is on the X.
```
OOOOO
OOX
```
If you resize the window now to 8 or more columns, this happens, as expected:
```
OOOOOOOX
```
As expected, the cursor remains on the "X". This behaves like any other text
input...
Terminals also provide an escape sequence to
[save the cursor (ESC 7 aka DECSC)](https://ghostty.org/docs/vt/esc/decsc).
This includes, amongst other things, the cursor position. The cursor can be
restored with [DECRC](https://ghostty.org/docs/vt/esc/decrc).
The behavior of the position of the _saved cursor_ in the context of text
reflow is unspecified and varies wildly between terminals Ghostty does this
right now (as do many other terminals):
```
OOOOOOOO
X
```
This commit changes the behavior so that we reflow the saved cursor.
As pointed out by @tristan957 the standard path for including the
Adwaita header file is simply "adwaita.h". While it may have been
necessary in the past to use a non-standard include path, that no longer
appears to be the case.
As pointed out by @tristan957 the standard path for including the
Adwaita header file is simply "adwaita.h". While it may have been
necessary in the past to use a non-standard include path, that no longer
appears to be the case.
Caused by #5650
I actually don't understand how this didn't happen before or why we
didn't notice it but it seems like the envmap was never freed. In the
latest debug builds prior to this build GPA reports the leak.
We should free the envmap when the subprocess is deinitialized. But also
we can free the env map as soon as we start the subprocess which saves
some small amount of memory at runtime.
Additionally, we should only be freeing the envmap on error if we
created it.
Caused by #5650
I actually don't understand how this didn't happen before or why we
didn't notice it but it seems like the envmap was never freed. In the
latest debug builds prior to this build GPA reports the leak.
We should free the envmap when the subprocess is deinitialized. But also
we can free the env map as soon as we start the subprocess which saves
some small amount of memory at runtime.
Additionally, we should only be freeing the envmap on error if we
created it.
This should help with API rate limits being hit by macOS builders since
they can't use the Namespace cache that Linux builders can use to cache
Zig dependencies. It will need to be run by Mitchell once so that the
Cachix action can push everything up to the cache and then the full
benefits should be seen. Not sure how using `--system` on all the macOS
builds will affect things overall but it doesn't seem to have affected
the CI.
Partial fixes#5552 (for GTK).
This PR adds the core infrastructure for keybind actions that are
implemented as runtime app actions to be performable. This is done by
having `rt_app.performAction` return a boolean. By default all runtime
app actions return `true` (the action was performed) unless they are
modified to return `true`/`false` as appropriate.
The GTK apprt is modified so that `goto_split`, `previous_tab`,
`next_tab`, `last_tab`, and `goto_tab` are performable. macOS support
will need to be added in a subsequent commit.
This doesn't completely solve the issue for the OP because if the
`goto_split` isn't performable there is no fallback to`previous_tab` or
`next_tab`.
I don't think that the approach taken in #5579 is the right one as it
conflates split and tab navigation unconditionally which I don't think
is what everyone would want. Either a separate action that explicitly
combines the actions or a solution to #3175 will be the ultimate
solution I believe.
This is just a fun change to add a bunch of alternate icons. We don't
want to add too many since this increases the final bundle size but we
also want to have some fun. :)
`WINDOWID` is the conventional environment variable for scripts that
want to know the X11 window ID of the terminal, so that it may call
tools like `xprop` or `xdotool`. We already know the window ID for
window protocol handling, so we might as well throw this in for
convenience.
Originally suggested by #4299
`WINDOWID` is the conventional environment variable for scripts that
want to know the X11 window ID of the terminal, so that it may call
tools like `xprop` or `xdotool`. We already know the window ID for
window protocol handling, so we might as well throw this in for
convenience.
Fixes https://github.com/ghostty-org/ghostty/issues/4958
## Changes
1. Fixed documentation generation in `actions.mdx`:
- Fixed an issue where the last action's documentation was [not properly
generated](fe6c69263c/docs/config/keybind/reference.mdx (crash))
- Ensured all actions' documentation is correctly included in the output
2. Improved `ghostty +list-actions --docs` command output formatting:
- Grouped related actions together with shared documentation
- Added proper spacing between action groups
<details>
<summary>ghostty-dev +list-actions --docs</summary>
```
ignore:
Ignore this key combination, don't send it to the child process, just
black hole it.
unbind:
This action is used to flag that the binding should be removed from
the set. This should never exist in an active set and `set.put` has an
assertion to verify this.
csi:
Send a CSI sequence. The value should be the CSI sequence without the
CSI header (`ESC [` or `\x1b[`).
esc:
Send an `ESC` sequence.
text:
Send the given text. Uses Zig string literal syntax. This is currently
not validated. If the text is invalid (i.e. contains an invalid escape
sequence), the error will currently only show up in logs.
cursor_key:
Send data to the pty depending on whether cursor key mode is enabled
(`application`) or disabled (`normal`).
reset:
Reset the terminal. This can fix a lot of issues when a running
program puts the terminal into a broken state. This is equivalent to
when you type "reset" and press enter.
If you do this while in a TUI program such as vim, this may break
the program. If you do this while in a shell, you may have to press
enter after to get a new prompt.
copy_to_clipboard:
paste_from_clipboard:
paste_from_selection:
Copy and paste.
copy_url_to_clipboard:
Copy the URL under the cursor to the clipboard. If there is no
URL under the cursor, this does nothing.
increase_font_size:
decrease_font_size:
Increase/decrease the font size by a certain amount.
reset_font_size:
Reset the font size to the original configured size.
clear_screen:
Clear the screen. This also clears all scrollback.
select_all:
Select all text on the screen.
scroll_to_top:
scroll_to_bottom:
scroll_page_up:
scroll_page_down:
scroll_page_fractional:
scroll_page_lines:
Scroll the screen varying amounts.
adjust_selection:
Adjust an existing selection in a given direction. This action
does nothing if there is no active selection.
jump_to_prompt:
Jump the viewport forward or back by prompt. Positive number is the
number of prompts to jump forward, negative is backwards.
write_scrollback_file:
Write the entire scrollback into a temporary file. The action
determines what to do with the filepath. Valid values are:
- "paste": Paste the file path into the terminal.
- "open": Open the file in the default OS editor for text files.
The default OS editor is determined by using `open` on macOS
and `xdg-open` on Linux.
write_screen_file:
Same as write_scrollback_file but writes the full screen contents.
See write_scrollback_file for available values.
write_selection_file:
Same as write_scrollback_file but writes the selected text.
If there is no selected text this does nothing (it doesn't
even create an empty file). See write_scrollback_file for
available values.
new_window:
Open a new window. If the application isn't currently focused,
this will bring it to the front.
new_tab:
Open a new tab.
previous_tab:
Go to the previous tab.
next_tab:
Go to the next tab.
last_tab:
Go to the last tab (the one with the highest index)
goto_tab:
Go to the tab with the specific number, 1-indexed. If the tab number
is higher than the number of tabs, this will go to the last tab.
move_tab:
Moves a tab by a relative offset.
Adjusts the tab position based on `offset`. For example `move_tab:-1` for left, `move_tab:1` for right.
If the new position is out of bounds, it wraps around cyclically within the tab range.
toggle_tab_overview:
Toggle the tab overview.
This only works with libadwaita enabled currently.
new_split:
Create a new split in the given direction. The new split will appear in
the direction given. For example `new_split:up`. Valid values are left, right, up, down and auto.
goto_split:
Focus on a split in a given direction. For example `goto_split:up`.
Valid values are left, right, up, down, previous and next.
toggle_split_zoom:
zoom/unzoom the current split.
resize_split:
Resize the current split by moving the split divider in the given
direction. For example `resize_split:left,10`. The valid directions are up, down, left and right.
equalize_splits:
Equalize all splits in the current window
inspector:
Show, hide, or toggle the terminal inspector for the currently focused
terminal.
open_config:
Open the configuration file in the default OS editor. If your default OS
editor isn't configured then this will fail. Currently, any failures to
open the configuration will show up only in the logs.
reload_config:
Reload the configuration. The exact meaning depends on the app runtime
in use but this usually involves re-reading the configuration file
and applying any changes. Note that not all changes can be applied at
runtime.
close_surface:
Close the current "surface", whether that is a window, tab, split, etc.
This only closes ONE surface. This will trigger close confirmation as
configured.
close_tab:
Close the current tab, regardless of how many splits there may be.
This will trigger close confirmation as configured.
close_window:
Close the window, regardless of how many tabs or splits there may be.
This will trigger close confirmation as configured.
close_all_windows:
Close all windows. This will trigger close confirmation as configured.
This only works for macOS currently.
toggle_fullscreen:
Toggle fullscreen mode of window.
toggle_window_decorations:
Toggle window decorations on and off. This only works on Linux.
toggle_secure_input:
Toggle secure input mode on or off. This is used to prevent apps
that monitor input from seeing what you type. This is useful for
entering passwords or other sensitive information.
This applies to the entire application, not just the focused
terminal. You must toggle it off to disable it, or quit Ghostty.
This only works on macOS, since this is a system API on macOS.
toggle_quick_terminal:
Toggle the "quick" terminal. The quick terminal is a terminal that
appears on demand from a keybinding, often sliding in from a screen
edge such as the top. This is useful for quick access to a terminal
without having to open a new window or tab.
When the quick terminal loses focus, it disappears. The terminal state
is preserved between appearances, so you can always press the keybinding
to bring it back up.
To enable the quick terminally globally so that Ghostty doesn't
have to be focused, prefix your keybind with `global`. Example:
\```ini
keybind = global:cmd+grave_accent=toggle_quick_terminal
\```
The quick terminal has some limitations:
- It is a singleton; only one instance can exist at a time.
- It does not support tabs, but it does support splits.
- It will not be restored when the application is restarted
(for systems that support window restoration).
- It supports fullscreen, but fullscreen will always be a non-native
fullscreen (macos-non-native-fullscreen = true). This only applies
to the quick terminal window. This is a requirement due to how
the quick terminal is rendered.
See the various configurations for the quick terminal in the
configuration file to customize its behavior.
This currently only works on macOS.
toggle_visibility:
Show/hide all windows. If all windows become shown, we also ensure
Ghostty becomes focused. When hiding all windows, focus is yielded
to the next application as determined by the OS.
This currently only works on macOS.
quit:
Quit ghostty.
crash:
Crash ghostty in the desired thread for the focused surface.
WARNING: This is a hard crash (panic) and data can be lost.
The purpose of this action is to test crash handling. For some
users, it may be useful to test crash reporting functionality in
order to determine if it all works as expected.
The value determines the crash location:
- "main" - crash on the main (GUI) thread.
- "io" - crash on the IO thread for the focused surface.
- "render" - crash on the render thread for the focused surface.
```
</details>
## Testing
- Run `ghostty-dev +list-actions --docs` to verify the new output format
- Check generated _zig-out/share/ghostty/webdata/actions.mdx_ to ensure
all actions are properly documented
Implements window position persistence on macOS, similar to Terminal.app
and iTerm2. The window position is saved when it becomes main or moves,
and restored on next startup. Window position is kept within visible
screen bounds.
cc @jsumners - Would you mind giving it a try? Any feedback would be
appreciated!
Resolves#4233
Fixes#5690
When we hide the app and then show it again, the previously key window
is lost. This is because we are not using unhide and are manually doing
it (and we're not using unhide for good reasons commented in the source
already).
Modify our hidden state to include what the key window was (as a weak
ref) and restore it when we show the app again.