mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-15 16:26:08 +03:00
config: macos-option-as-alt now accepts "left", "right"
This commit is contained in:
@ -142,7 +142,7 @@ const DerivedConfig = struct {
|
||||
confirm_close_surface: bool,
|
||||
mouse_interval: u64,
|
||||
macos_non_native_fullscreen: bool,
|
||||
macos_option_as_alt: bool,
|
||||
macos_option_as_alt: configpkg.OptionAsAlt,
|
||||
|
||||
pub fn init(alloc_gpa: Allocator, config: *const configpkg.Config) !DerivedConfig {
|
||||
var arena = ArenaAllocator.init(alloc_gpa);
|
||||
@ -1042,9 +1042,11 @@ pub fn charCallback(
|
||||
// On macOS, we have to opt-in to using alt because option
|
||||
// by default is a unicode character sequence.
|
||||
if (comptime builtin.target.isDarwin()) {
|
||||
if (!self.config.macos_option_as_alt) {
|
||||
log.debug("macos_option_as_alt disabled, not sending esc prefix", .{});
|
||||
break :alt;
|
||||
switch (self.config.macos_option_as_alt) {
|
||||
.false => break :alt,
|
||||
.true => {},
|
||||
.left => if (mods.sides.alt != .left) break :alt,
|
||||
.right => if (mods.sides.alt != .right) break :alt,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -394,8 +394,16 @@ pub const Surface = struct {
|
||||
// then we strip the alt modifier from the mods for translation.
|
||||
const translate_mods = translate_mods: {
|
||||
var translate_mods = mods;
|
||||
if (self.app.config.@"macos-option-as-alt")
|
||||
translate_mods.alt = false;
|
||||
switch (self.app.config.@"macos-option-as-alt") {
|
||||
.false => {},
|
||||
.true => translate_mods.alt = false,
|
||||
.left => if (mods.sides.alt == .left) {
|
||||
translate_mods.alt = false;
|
||||
},
|
||||
.right => if (mods.sides.alt == .right) {
|
||||
translate_mods.alt = false;
|
||||
},
|
||||
}
|
||||
|
||||
break :translate_mods translate_mods;
|
||||
};
|
||||
|
@ -249,7 +249,7 @@ pub const Config = struct {
|
||||
/// (i.e. alt+ctrl+a).
|
||||
///
|
||||
/// This does not work with GLFW builds.
|
||||
@"macos-option-as-alt": bool = false,
|
||||
@"macos-option-as-alt": OptionAsAlt = .false,
|
||||
|
||||
/// This is set by the CLI parser for deinit.
|
||||
_arena: ?ArenaAllocator = null,
|
||||
@ -1036,6 +1036,14 @@ fn equal(comptime T: type, old: T, new: T) bool {
|
||||
}
|
||||
}
|
||||
|
||||
/// Valid values for macos-option-as-alt.
|
||||
pub const OptionAsAlt = enum {
|
||||
false,
|
||||
true,
|
||||
left,
|
||||
right,
|
||||
};
|
||||
|
||||
/// Color represents a color using RGB.
|
||||
pub const Color = struct {
|
||||
r: u8,
|
||||
|
Reference in New Issue
Block a user