195 Commits

Author SHA1 Message Date
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
Mitchell Hashimoto
471098df30 macOS: Run scripts using stdin rather than executing directly
Fixes #7647

See #7647 for context. This commit works by extending the `input` work
introduced in #7652 to libghostty so that the macOS can take advantage
of it. At that point, its just the macOS utilizing `input` in order to
set the command and `exit` up similar to Terminal and iTerm2.
2025-06-22 21:06:32 -04:00
Mitchell Hashimoto
f8bc9b547c macos: support env vars for surface config, clean up surface config 2025-06-21 06:39:20 -07:00
Mitchell Hashimoto
e1ee180172 apprt/embedded: API to read text can get top left/bottom right coords 2025-06-15 13:06:38 -07:00
Mitchell Hashimoto
c5f921bb06 apprt/embedded: improve text reading APIs (selection, random points) 2025-06-15 07:59:19 -07:00
Mitchell Hashimoto
6e77a5a6ca macos: address quick terminal basic functionality with new API 2025-06-07 13:07:31 -07:00
Mitchell Hashimoto
b044f4864a add undo/redo keybindings, default them on macOS 2025-06-07 12:46:14 -07:00
Jeffrey C. Ollie
d3cb6d0d41 GTK: add action to show the GTK inspector
The default keybinds for showing the GTK inspector (`ctrl+shift+i` and
`ctrl+shift+d`) don't work reliably in Ghostty due to the way Ghostty
handles input. You can show the GTK inspector by setting the environment
variable `GTK_DEBUG` to `interactive` before starting Ghostty but that's
not always convenient.

This adds a keybind action that will show the GTK inspector. Due to
API limitations toggling the GTK inspector using the keybind action is
impractical because GTK does not provide a convenient API to determine
if the GTK inspector is already showing. Thus we limit ourselves to
strictly showing the GTK inspector. To close the GTK inspector the user
must click the close button on the GTK inspector window. If the GTK
inspector window is already visible but is hidden, calling the keybind
action will not bring the GTK inspector window to the front.
2025-05-29 16:07:57 -05:00
Jörg Thalheim
a8651882a7 add cut/copy/paste keys
The origin of these keys are old sun keyboards.
They are getting picked up by the custom (progammable) keyboard scene
(see https://github.com/manna-harbour/miryoku for a popular layout).
Support in ghosty is quite handy because it allows to bind copy/paste in
a way that doesn't overlap with ctrl-c/ctrl-v, which can have special
bindings in some terminal applications.
2025-05-24 00:29:53 +02:00
Aaron Ruan
7ccc181332 macos: add "Check for Updates" action, menu item & key-binding support 2025-05-15 13:34:44 +08:00
Mitchell Hashimoto
ed1194cd75 fix tests 2025-05-10 08:51:08 -07:00
Mitchell Hashimoto
ffdf86374a apprt/gtk: build 2025-05-09 10:01:06 -07:00
Mitchell Hashimoto
b991d36343 macOS: build 2025-05-09 10:01:06 -07:00
Jeffrey C. Ollie
9c70f8aee1 core: add context menu key 2025-05-07 13:08:38 -07:00
Mitchell Hashimoto
6e11d947e7 Binding for toggling window float on top (macOS only)
This adds a keybinding and apprt action for #7237.
2025-05-01 09:47:17 -07:00
Friedrich Stoltzfus
77f5fc34f1 Add config color palette C bindings
C bindings to expose the color palette to Swift for macOS.
2025-04-25 14:10:35 -04:00
Mitchell Hashimoto
3e5fe5de9a move command filtering into apprt 2025-04-22 08:33:32 -07:00
Mitchell Hashimoto
6d2685b5a2 add toggle command palette binding 2025-04-21 10:05:30 -07:00
Mitchell Hashimoto
8615dfb73d libghostty: add API for getting commands 2025-04-21 08:32:05 -07:00
Mitchell Hashimoto
a34134e643 input: defind Command struct and default commands 2025-04-21 08:32:05 -07:00
Mitchell Hashimoto
b3cb38c3fa macOS/libghostty: rework keyboard input handling
This is a large refactor of the keyboard input handling code in
libghostty and macOS. Previously, libghostty did a lot of things that
felt out of scope or was repeated work due to lacking context. For
example, libghostty would do full key translation from key event to
character (including unshifted translation) as well as managing dead key
states and setting the proper preedit text.

This is all information the apprt can and should have on its own.
NSEvent on macOS already provides us with all of this information,
there's no need to redo the work. The reason we did in the first place
is mostly historical: libghostty powered our initial macOS port years
ago when we didn't have an AppKit runtime yet.

This cruft has already practically been the source of numerous issues, e.g.
#5558, but many other hacks along the way, too.

This commit pushes all preedit (e.g. dead key) handling and key translation
including unshifted keys up into the caller of libghostty.

Besides code cleanup, a practical benefit of this is that key event
handling on macOS is now about 10x faster on average. That's because
we're avoiding repeated key translations as well as other unnecessary
work. This should have a meaningful impact on input latency but I didn't
measure the full end-to-end latency.

A scarier part of this commit is that key handling is not well tested
since its a GUI component. I suspect we'll have some fallout for certain
keyboard layouts or input methods, but I did my best to run through
everything I could think of.
2025-04-17 14:24:12 -07:00
Leah Amelia Chen
a0760cabd6 gtk: implement bell
Co-authored-by: Jeffrey C. Ollie <jeff@ocjtech.us>
2025-04-14 23:44:13 +08:00
Mitchell Hashimoto
edf619205c add ghostty_translate C API 2025-03-07 13:42:00 -08:00
Leah Amelia Chen
9ed76729ab gtk: add separate close_window apprt action
For *some* reason we have a binding for close_window but it merely closes
the surface and not the entire window. That is not only misleading but
also just wrong. Now we make a separate apprt action for close_window
that would make it show a close confirmation prompt identical to as if
the user had clicked the (X) button on the window titlebar.
2025-03-06 20:32:38 +01: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
Aswin M Prabhu
a581955b9b Add tab title rename feature to macos 2025-02-14 13:29:36 -08:00
Mitchell Hashimoto
ac7aa757bd macos: add padded-notch option for macos-non-native-fullscreen
Finishes #378
Supercedes #4159

This adds a new enum value for `macos-non-native-fullscreen`:
`padded-notch`. This value will add padding to the top of the window to
account for the notch on applicable devices while still hiding the
menu.

This value is preferred over "visible-menu" by some people because for
screens without a notch, the window will take up the full height.

The plan in the future is that we may color the padded area when a notch
is present. In this commit it appears as transparent.
2025-02-13 20:27:42 -08:00
Mitchell Hashimoto
cbf562ecb3 apprt/embedded: make performAction return the performable state 2025-02-11 16:43:50 -08:00
Mitchell Hashimoto
844f20d01f Handle setting _NET_WM_STATE (#4936)
As recommended in
https://github.com/ghostty-org/ghostty/pull/4927#issuecomment-2585003934,
adds a config option `maximize` for starting a window in a maximized
state in terms of window properties. Also adds a `toggle_maximize`
keybind to allow users to manually toggle this feature on and off.

It might make more sense to make this an optional config value so that
we don't toggle the state off if the WM already handles that for us, but
I'll let a reviewer decide.

Closes https://github.com/ghostty-org/ghostty/issues/4646
2025-01-13 13:14:31 -08:00
Andreas Skielboe
e288096c26 Fix backslash comment in ghostty.h 2025-01-13 11:49:21 +01:00
Adam Wolf
8102fddceb apprt/gtk: add toggle_maximize keybind and window-maximize config option 2025-01-10 22:42:41 -06: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
40bdea7335 macos: handle overridden system bindings with no focused window 2025-01-04 14:07:47 -08:00
Mitchell Hashimoto
3e89c4c2f4 Key events return boolean if handled 2025-01-04 13:36:40 -08:00
Mitchell Hashimoto
4d103ca16d core: add keyEventIsBinding
This API can be used to determine if the next key event, if given as-is,
would result in a key binding being triggered.
2025-01-04 12:45:15 -08:00
Mitchell Hashimoto
e8811ac6fb Move app quit to apprt action
This changes quit signaling from a boolean return from core app `tick()`
to an apprt action. This simplifies the API and conceptually makes more
sense to me now.

This wasn't done just for that; this change was also needed so that
macOS can quit cleanly while fixing #4540 since we may no longer trigger
menu items. I wanted to split this out into a separate commit/PR because
it adds complexity making the diff harder to read.
2025-01-04 07:18:53 -08:00
Daniel Patterson
a4daabb28a Rename goto_split top/bottom directions to up/down. 2024-12-27 14:56:48 +00:00
Mitchell Hashimoto
29929a473d config: macos-icon configurations 2024-12-21 19:31:30 -08:00
Mitchell Hashimoto
298d6194f4 config: change color to a defined C struct for libghostty 2024-12-21 19:31:30 -08:00
Mitchell Hashimoto
cd49015243 App applies conditional state, supports theme setting
The prior light/dark mode awareness work works on surface-level APIs. As
a result, configurations used at the app-level (such as split divider
colors, inactive split opacity, etc.) are not aware of the current theme
configurations and default to the "light" theme.

This commit adds APIs to specify app-level color scheme changes. This
changes the configuration for the app and sets the default conditional
state to use that new theme. This latter point makes it so that future
surfaces use the correct theme on load rather than requiring some apprt
event loop ticks. Some users have already reported a short "flicker" to
load the correct theme, so this should help alleviate that.
2024-11-22 14:08:35 -08:00
Mitchell Hashimoto
00c62708d3 apprt: remove change conditional state action 2024-11-22 11:52:34 -08:00
Mitchell Hashimoto
a191f3c396 apprt: switch to reload_config action that calls update_config API 2024-11-22 11:52:34 -08:00
Mitchell Hashimoto
037d4364e5 config: C API ghostty_config_clone 2024-11-21 10:41:48 -08:00
Mitchell Hashimoto
fadfb08efe apprt: add config_change action 2024-11-21 10:30:27 -08:00
Mitchell Hashimoto
b7f1eaa145 apprt: action to change conditional state, implement for embedded 2024-11-19 15:36:31 -08:00
Mitchell Hashimoto
e0a733584e libghostty: remove the pwd function 2024-11-13 13:11:24 -08:00
Mitchell Hashimoto
3ca246ceb9 apprt: support a pwd change action 2024-11-13 12:29:30 -08:00
Mitchell Hashimoto
1065359b9a apprt: rename set_bg/fg to "color_change" to report all color changes 2024-10-30 16:33:18 -04:00
CJ van den Berg
a2a1d93d5c apprt: propagate OSC10/11 (set term fore/background color) through to apprt
This is to allow the running apprt to set the UI theme to match the
terminal application coloring.
2024-10-30 17:35:34 +01:00
Mitchell Hashimoto
de5ec5d83e macos: make move_tab work 2024-10-25 11:54:07 -07:00