diff --git a/src/contour/Config.cpp b/src/contour/Config.cpp index bd117276df..b2d82e3a06 100644 --- a/src/contour/Config.cpp +++ b/src/contour/Config.cpp @@ -398,6 +398,7 @@ void YAMLConfigReader::loadFromEntry(YAML::Node const& node, std::string const& loadFromEntry(child, "insert_after_yank", where.insertAfterYank); loadFromEntry(child, "bell", where.bell); loadFromEntry(child, "wm_class", where.wmClass); + loadFromEntry(child, "command_as_alt", where.commandKeyAsAlt); loadFromEntry(child, "margins", where.margins); loadFromEntry(child, "terminal_id", where.terminalId); loadFromEntry(child, "frozen_dec_modes", where.frozenModes); diff --git a/src/contour/Config.h b/src/contour/Config.h index cd07fe48f5..58759ef72c 100644 --- a/src/contour/Config.h +++ b/src/contour/Config.h @@ -445,7 +445,7 @@ struct TerminalProfile ConfigEntry hyperlinkDecoration {}; ConfigEntry wmClass { CONTOUR_APP_ID }; - ConfigEntry optionKeyAsAlt { false }; + ConfigEntry commandKeyAsAlt { true }; }; const InputMappings defaultInputMappings { diff --git a/src/contour/ConfigDocumentation.h b/src/contour/ConfigDocumentation.h index c6e2a2a535..97c1f9b91d 100644 --- a/src/contour/ConfigDocumentation.h +++ b/src/contour/ConfigDocumentation.h @@ -1631,22 +1631,22 @@ constexpr StringLiteral HyperlinkDecorationWeb { }; -constexpr StringLiteral OptionKeyAsAltConfig { - "{comment} Tells Contour how to handle Option-Key events on MacOS.\n" +constexpr StringLiteral CommandKeyAsAltConfig { + "{comment} Tells Contour how to handle Command-Key events on MacOS.\n" "{comment} This value is ignored on other platforms.\n" "{comment}\n" - "{comment} Default: false\n" - "option_as_alt: {}\n" + "{comment} Default: true\n" + "command_as_alt: {}\n" "\n" }; -constexpr StringLiteral OptionKeyAsAltWeb { - "section tells Contour how to handle Option-Key events on MacOS.\n" +constexpr StringLiteral CommandKeyAsAltWeb { + "section tells Contour how to handle Command-Key events on MacOS.\n" "This value is ignored on other platforms.\n" "``` yaml\n" "profiles:\n" " profile_name:\n" - " option_as_alt: false\n" + " command_as_alt: false\n" "```\n" "\n" }; @@ -1753,7 +1753,7 @@ using TerminalId = DocumentationEntry; using History = DocumentationEntry; using Scrollbar = DocumentationEntry; using StatusLine = DocumentationEntry; -using OptionKeyAsAlt = DocumentationEntry; +using CommandKeyAsAlt = DocumentationEntry; using Fonts = DocumentationEntry; using Permissions = DocumentationEntry; using DrawBoldTextWithBrightColors = diff --git a/src/contour/contour.yml b/src/contour/contour.yml index 2fc2e6e422..23c9ac2e59 100644 --- a/src/contour/contour.yml +++ b/src/contour/contour.yml @@ -246,7 +246,7 @@ profiles: # This value is ignored on other platforms. # # Default: false - option_as_alt: false + command_as_alt: false # Environment variables to be passed to the shell. # environment: diff --git a/src/contour/helper.cpp b/src/contour/helper.cpp index b46a180cf3..a5dca8557a 100644 --- a/src/contour/helper.cpp +++ b/src/contour/helper.cpp @@ -387,11 +387,11 @@ bool sendKeyEvent(QKeyEvent* event, vtbackend::KeyboardEventType eventType, Term return true; } -#if defined(__apple__) - if (0x20 <= key && key < 0x80 && (modifiers.alt() && session.profile().optionKeyAsAlt.value())) +#if defined(__APPLE__) + if (0x20 <= key && key < 0x80 + && ((modifiers & Modifier::Super) && session.profile().commandKeyAsAlt.value())) { - auto const ch = static_cast(modifiers.shift() ? std::toupper(key) : std::tolower(key)); - session.sendCharEvent(ch, physicalKey, modifiers, eventType, now); + session.sendCharEvent(key, physicalKey, Modifier::Alt, vtbackend::KeyboardEventType::Press, now); event->accept(); return true; }