Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Instead of option_as_alt introduce command_as_alt and fix behaviour #1718

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/contour/Config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

option_as_alt was not removed?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah, looks like it was not there since config refactor. oops :)

loadFromEntry(child, "margins", where.margins);
loadFromEntry(child, "terminal_id", where.terminalId);
loadFromEntry(child, "frozen_dec_modes", where.frozenModes);
Expand Down
2 changes: 1 addition & 1 deletion src/contour/Config.h
Original file line number Diff line number Diff line change
Expand Up @@ -445,7 +445,7 @@ struct TerminalProfile
ConfigEntry<HyperlinkDecorationConfig, documentation::HyperlinkDecoration> hyperlinkDecoration {};

ConfigEntry<std::string, documentation::WMClass> wmClass { CONTOUR_APP_ID };
ConfigEntry<bool, documentation::OptionKeyAsAlt> optionKeyAsAlt { false };
ConfigEntry<bool, documentation::CommandKeyAsAlt> commandKeyAsAlt { true };
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we really want to default to true here?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that this is better for the default since user do not need to tweak config to use Alt+something key mappings on mac

};

const InputMappings defaultInputMappings {
Expand Down
16 changes: 8 additions & 8 deletions src/contour/ConfigDocumentation.h
Original file line number Diff line number Diff line change
Expand Up @@ -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"
};
Expand Down Expand Up @@ -1753,7 +1753,7 @@ using TerminalId = DocumentationEntry<TerminalIdConfig, TerminalIdWeb>;
using History = DocumentationEntry<HistoryConfig, HistoryWeb>;
using Scrollbar = DocumentationEntry<ScrollbarConfig, ScrollbarWeb>;
using StatusLine = DocumentationEntry<StatusLineConfig, StatusLineWeb>;
using OptionKeyAsAlt = DocumentationEntry<OptionKeyAsAltConfig, OptionKeyAsAltWeb>;
using CommandKeyAsAlt = DocumentationEntry<CommandKeyAsAltConfig, CommandKeyAsAltWeb>;
using Fonts = DocumentationEntry<FontsConfig, FontsWeb>;
using Permissions = DocumentationEntry<PermissionsConfig, PermissionsWeb>;
using DrawBoldTextWithBrightColors =
Expand Down
2 changes: 1 addition & 1 deletion src/contour/contour.yml
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ profiles:
# This value is ignored on other platforms.
#
# Default: false
option_as_alt: false
command_as_alt: false
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

above it says default is true, here false 🤔


# Environment variables to be passed to the shell.
# environment:
Expand Down
8 changes: 4 additions & 4 deletions src/contour/helper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<char32_t>(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;
}
Expand Down
Loading