382 Commits

Author SHA1 Message Date
Mitchell Hashimoto
7e9be00924 working on macos 2025-03-12 10:15:14 -07:00
Mitchell Hashimoto
0f4d2bb237 Lots of 0.14 changes 2025-03-12 09:55:52 -07:00
Leah Amelia Chen
e07b6fdf6b gtk: implement quick terminal slide & autohide (#6090) 2025-03-05 23:20:03 +01:00
Leah Amelia Chen
58b0434092 docs: update information about quick terminal support on Linux 2025-03-05 21:37:49 +01:00
Mitchell Hashimoto
f93eb0b27f input: legacy encoding never encodes text for command mods on macOS
Fixes #5929
Replaces #5984

On macOS, native applications typically never encode any text for
key events that use the command key. This is because the command key
is used for key equivalents and "commands" and should not be used
for text input.

This can be verified with apps like TextEdit but also terminals like
Terminal.app officially but also iTerm2 unofficially. Anything such as
`Cmd+b` or `Cmd+Shift+b` will not produce any text input.

Cross-platform terminals generally don't follow this, for example Kitty
performs CSI-u encoding and Alacritty and WezTerm encode the text as-is
(i.e. `Cmd+b` will produce `b`).

On Linux, the super key (command-equivalent) does produce text input.
For example, `Super+b` will produce `b` in Gnome Console, Foot, and
all the cross-platform terminals mentioned above.

In the interest of matching the behavior of native macOS applications,
we should not encode text for command key events on macOS. We continue
to encode text for the super key on non-macOS platforms.
2025-03-02 13:53:20 -08:00
Mitchell Hashimoto
17cae57f51 Introduce reset_window_size keybinding and apprt action
Related to #6035

This implements the keybind/action portion of #5974 so that this can
have a binding and so that other apprts can respond to this and
implement it this way.
2025-02-28 15:31:17 -08:00
Maciej Bartczak
95fc5ad1e9 remove outdated comment 2025-02-22 16:30:57 -06:00
Aswin M Prabhu
a581955b9b Add tab title rename feature to macos 2025-02-14 13:29:36 -08:00
Mitchell Hashimoto
b44b1086d3 apprt/embedded: proper consumed modifier state for ctrl keys 2025-02-13 14:58:41 -08:00
Bryan Lee
1674224c1a Refactor keybinding actions reference generation 2025-02-12 06:29:40 +08:00
Mitchell Hashimoto
f8b547f92e Revert "Fixed documentation generation in list-actions --docs command (#4974)"
This reverts commit f3d0c7c2ad01968de5191ccfae09a25e5c760760, reversing
changes made to 4b77a1c71e7994f6c040c4bee8a9e0b3d77b6286.
2025-02-11 12:55:40 -08:00
Mitchell Hashimoto
f3d0c7c2ad Fixed documentation generation in list-actions --docs command (#4974)
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
2025-02-11 12:47:47 -08:00
Shaps Benkau
8d31f6ce2e Toggling visibility is now ignored when in fullscreen mode. 2025-02-03 13:44:23 -08:00
Mitchell Hashimoto
ce2a3773d2 input: performable bindings aren't part of the reverse mapping
Fixes #4522

This is a bit of a hammer-meets-nail solution, but it's a simple
solution to the problem. The reverse mapping is used to find the
binding that an action is bound to, and it's used by apprt's to populate
the accelerator label in the UI.

The problem is that accelerators in GTK are handled early in the event
handling process and its difficult to get that event mapping to a
specific surface. Therefore, the "performable" prefix was not working.
On macOS, this issue didn't exist because there exists an OS mechanism
to install an event handler earlier than the menu system.

This commit changes the reverse mapping to only include bindings that
are not performable. This way, the keybind always reaches the surface
and can be handled by `Surface.keyCallback` which processes
`performable`.

The caveat is that performable bindings will not show up in the UI
for menu items. This is documented in this commit now. They still work,
its just a UI issue.
2025-01-29 14:12:21 -08:00
Mitchell Hashimoto
3b108945f3 Merge branch 'main' into cleanup-action-binding-docs 2025-01-24 15:33:39 -08:00
Erlend Lind Madsen
0c5ef5578c Docs: remove type from action arguments 2025-01-24 23:13:42 +07:00
Erlend Lind Madsen
076bcccde4 Docs: improve doc structure for action bindings with args and examples
minor doc changes
2025-01-24 15:06:45 +07:00
Bruno Bachmann
bb58710fa8 Fix typo in binding comments 2025-01-19 14:49:59 -08:00
Bryan Lee
0016199ec3 Extract keybind actions help generation into a dedicated module 2025-01-18 05:14:50 +08:00
Bryan Lee
05fe3e7ec3 Ensure last action's documentation is properly generated
The issue was caused by the documentation generation logic not writing the final buffered content.
2025-01-18 05:14:49 +08:00
Adam Wolf
8102fddceb apprt/gtk: add toggle_maximize keybind and window-maximize config option 2025-01-10 22:42:41 -06:00
Mitchell Hashimoto
200aee9acf macos: rework toggle_visibility to better match iTerm2
Two major changes:

1. Hiding uses `NSApp.hide` which hides all windows, preserves tabs, and
   yields focus to the next app.

2. Unhiding manually tracks and brings forward only the windows we hid.
   Proper focus should be retained.
2025-01-10 14:40:02 -08:00
Bryan Lee
5213edfa6c Add keybind action copy_url_to_clipboard 2025-01-08 13:22:33 -08:00
Bryan Lee
140ac93884 Add close_tab keybinding action for macOS
Implement `close_tab` keybinding action to close the current tab and all splits within that tab.
2025-01-08 12:04:40 -08:00
Sabarigirish Manikandan
306c7ea2be close_tab keybind (gtk apprt only) (#4033)
Title. Adds a close_tab keybind that essentially behaves the exact same
as clicking the tab close button on the tab bar.
2025-01-08 19:07:00 +00:00
Mitchell Hashimoto
359c390218 config: unbind keybind triggers unbinds both translated and physical
Fixes #4703

This changes `unbind` so it always removes all keybinds with the given
trigger pattern regardless of if it is translated or physical.

The previous behavior was technically correct, but this implements the pattern
of least surprise. I can't think of a scenario where you really want to
be exact about what key you're unbinding. And if that scenario does
exist, you can always fix it by rebinding after unbind.
2025-01-06 09:47:21 -08:00
Mitchell Hashimoto
305e5b3533 fix typo: CSI header (#4565)
Fixes a typo in the keybindings documentation comments.
Originally opened on the website repo at
https://github.com/ghostty-org/website/pull/259
2025-01-04 14:27:23 -08:00
Kiril Angov
2dc518d8b0 Improve the documentation for move_tab keybind action 2025-01-04 12:57:38 -05:00
dkmar
69e4428d80 fix typo: CSI header 2025-01-03 23:34:39 -08:00
Caleb Norton
2610f5b4e2 Docs: update goto_split documentation
In #4388, documentation was added for goto_split but in #3427 this
documentation was made outdated but not updated. This makes the
documentation up to date and brings the ordering in line with new_split
2025-01-03 14:32:39 -06:00
Mitchell Hashimoto
ab9b14215c input: legacy encoding falls back to mapping of logical key for ctrlseq (#4528)
Fixes #4518

If our UTF8 encoding is not recognized, we fall back to the ASCII
mapping of the logical key for the control sequence. This allows
cyrillic control characters to work.

I also verified that non-cyrllic (US) and alternate layouts (Dvorak)
work as expected still.
2025-01-03 11:09:09 -08:00
Peter Cock
6459e5c8ca Fixing a few typos in the source code comments (#4529) 2025-01-03 11:00:45 -08:00
Mitchell Hashimoto
45d005ce65 input: legacy encoding falls back to mapping of logical key for ctrlseq
Fixes #4518

If our UTF8 encoding is not recognized, we fall back to the ASCII
mapping of the logical key for the control sequence. This allows
cyrillic control characters to work.

I also verified that non-cyrllic (US) and alternate layouts (Dvorak)
work as expected still.
2025-01-03 10:53:54 -08:00
Mitchell Hashimoto
e2f9eb6a6f keybindings: improve sort to include key value 1,2,3,4... (#4399)
Current sort used by `+list-keybinds` doesn't include the value of the
key:
```
ctrl  + shift + v                      paste_from_clipboard
ctrl  + shift + a                      select_all
...
ctrl  + shift + q                      quit
ctrl  + shift + n                      new_window
...
alt   + five                           goto_tab:5
alt   + eight                          goto_tab:8
...
alt   + six                            goto_tab:6
alt   + seven                          goto_tab:7
```
adding the key value improves the sort order

```
ctrl  + shift + a                      select_all
ctrl  + shift + c                      copy_to_clipboard
...
ctrl  + shift + n                      new_window
ctrl  + shift + o                      new_split:right
ctrl  + shift + q                      quit
...
alt   + one                            goto_tab:1
alt   + two                            goto_tab:2
alt   + three                          goto_tab:3
...
alt   + eight                          goto_tab:8
alt   + nine                           last_tab
alt   + f4                             close_window
2025-01-02 19:43:19 -08:00
Mitchell Hashimoto
7e1b7bb8b3 performable: prefix (#4345)
closes #4328
closes #3970

makes this possible now
```
keybind = performable:ctrl+c=copy_to_clipboard # copy if theres a selection else send sigint
keybind = ctrl+v=paste_from_clipboard
```
2025-01-02 16:11:24 -08:00
Mitchell Hashimoto
95b73f197f Add docs for performable 2025-01-02 15:41:01 -08:00
Mitchell Hashimoto
9503c9fe50 Rename goto_split top/bottom directions to up/down. (#3427)
Renames the top/bottom directions of `goto_split` to up/down. I have
tested this on linux (nixos) but given that `goto_split` is broken on
linux anyway (#2866) there's not a whole lot to test.

I have no way to build on macOS so I can't verify that I've changed
everything correctly for that.

Closes #3237
2025-01-02 07:08:16 -08:00
Mitchell Hashimoto
75571fb804 Improve resize_split documentation (#4393) 2025-01-02 07:02:33 -08:00
Mitchell Hashimoto
4047c89c24 Improve new_split documentation (#4389) 2025-01-02 07:02:23 -08:00
Anund
913a1404be keybindings: improve sort to include key value 1,2,3,4... 2025-01-03 01:53:07 +11:00
Jade
355ac91c0a Improve resize_split documentation 2025-01-02 21:33:47 +08:00
Jade
cd809106c4 Improve new_split documentation 2025-01-02 21:05:56 +08:00
Jade
80fe32be32 Update Binding.zig 2025-01-02 20:58:50 +08:00
Jade
15ceb18fcb Improve goto_split documentation 2025-01-02 20:54:42 +08:00
Ethan Conneely
98aa046a4d Add performable flag 2025-01-02 00:18:39 +00:00
Mitchell Hashimoto
aa81c16ba1 input: parse triggers with codepoints that map to keys as translated
Fixes #4146

This makes it so that keys such as `cmd+1` and `cmd+one` are identical.
2024-12-30 21:06:43 -08:00
Daniel Patterson
3e11476d32 Add "top" and "bottom" aliases 2024-12-29 22:05:28 +00:00
Ronit Gandhi
38643ec4fe docs: add guide for setting quick terminal toggle keybind 2024-12-28 12:57:17 -08:00
xaviduds
96753aa7e0 Update doc inform toggle_quick_terminal macOS only 2024-12-27 11:52:20 -08:00
Daniel Patterson
a4daabb28a Rename goto_split top/bottom directions to up/down. 2024-12-27 14:56:48 +00:00