pull/9633/merge
Kshitij Saraogi 2025-12-16 11:28:04 -08:00 committed by GitHub
commit 913f09a5e0
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 40 additions and 0 deletions

View File

@ -303,6 +303,7 @@ const DerivedConfig = struct {
mouse_shift_capture: configpkg.MouseShiftCapture,
macos_non_native_fullscreen: configpkg.NonNativeFullscreen,
macos_option_as_alt: ?input.OptionAsAlt,
macos_option_as_alt_original: ?input.OptionAsAlt,
selection_clear_on_copy: bool,
selection_clear_on_typing: bool,
vt_kam_allowed: bool,
@ -378,6 +379,7 @@ const DerivedConfig = struct {
.mouse_shift_capture = config.@"mouse-shift-capture",
.macos_non_native_fullscreen = config.@"macos-non-native-fullscreen",
.macos_option_as_alt = config.@"macos-option-as-alt",
.macos_option_as_alt_original = config.@"macos-option-as-alt",
.selection_clear_on_copy = config.@"selection-clear-on-copy",
.selection_clear_on_typing = config.@"selection-clear-on-typing",
.vt_kam_allowed = config.@"vt-kam-allowed",
@ -5518,6 +5520,22 @@ pub fn performBindingAction(self: *Surface, action: input.Binding.Action) !bool
{},
),
.toggle_macos_option_as_alt => {
const current = self.config.macos_option_as_alt orelse .false;
switch (current) {
.false => {
// Toggle ON the behavior by restoring from the saved state.
self.config.macos_option_as_alt = self.config.macos_option_as_alt_original orelse .true;
},
.true, .left, .right => {
// Toggle OFF and save the current value in the surface state.
self.config.macos_option_as_alt_original = current;
self.config.macos_option_as_alt = .false;
},
}
},
.show_on_screen_keyboard => return try self.rt_app.performAction(
.{ .surface = self },
.show_on_screen_keyboard,

View File

@ -6523,6 +6523,12 @@ pub const Keybinds = struct {
.{ .key = .{ .physical = .arrow_right }, .mods = .{ .alt = true } },
.{ .esc = "f" },
);
// Toggle option-as-alt similar to Terminal.app.
try self.set.put(
alloc,
.{ .key = .{ .unicode = 'o' }, .mods = .{ .super = true, .alt = true } },
.toggle_macos_option_as_alt,
);
}
}

View File

@ -694,6 +694,15 @@ pub const Action = union(enum) {
/// version can be found by running `ghostty +version`.
toggle_command_palette,
/// Toggle the macos-option-as-alt behavior.
///
/// When toggled off, sets the macos-option-as-alt to false.
/// When toggled on, restores to the original configured value (true, left,
/// or right). It defauls to true if none was set.
///
/// Only available on macOS.
toggle_macos_option_as_alt,
/// Toggle the quick terminal.
///
/// The quick terminal, also known as the "Quake-style" or drop-down
@ -1240,6 +1249,7 @@ pub const Action = union(enum) {
.toggle_secure_input,
.toggle_mouse_reporting,
.toggle_command_palette,
.toggle_macos_option_as_alt,
.show_on_screen_keyboard,
.reset_window_size,
.crash,

View File

@ -618,6 +618,12 @@ fn actionCommands(action: Action.Key) []const Command {
.description = "Toggle whether mouse events are reported to terminal applications.",
}},
.toggle_macos_option_as_alt => comptime &.{.{
.action = .toggle_macos_option_as_alt,
.title = "Toggle Option as Alt on macOS",
.description = "Toggle whether the macOS Option keys act as Alt",
}},
.check_for_updates => comptime &.{.{
.action = .check_for_updates,
.title = "Check for Updates",