Skip to content

Commit

Permalink
Merge pull request #1714 from contour-terminal/fix/key_binding_default
Browse files Browse the repository at this point in the history
Fix default binding for cancel selection with escape
  • Loading branch information
christianparpart authored Jan 26, 2025
2 parents f833ebb + 124fb9b commit cd912d1
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 13 deletions.
1 change: 1 addition & 0 deletions metainfo.xml
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@
<release version="0.6.2" urgency="medium" type="development">
<description>
<ul>
<li>Fixes `CancelSelection` default binding with escape (#1710)</li>
<li>Fixes `CreateTab` to sometimes spawn more than one tab (#1695)</li>
<li>Ensure inserting new tabs happens right next to the currently active tab (#1695)</li>
<li>Adds `MoveTabToLeft` and `MoveTabToRight` actions to move tabs around (#1695)</li>
Expand Down
38 changes: 25 additions & 13 deletions src/contour/Config.h
Original file line number Diff line number Diff line change
Expand Up @@ -409,11 +409,11 @@ struct TerminalProfile
ConfigEntry<std::map<vtbackend::DECMode, bool>, documentation::FrozenDecMode> frozenModes {};
ConfigEntry<std::chrono::milliseconds, documentation::SmoothLineScrolling> smoothLineScrolling { 100 };
ConfigEntry<vtbackend::PageSize, documentation::TerminalSize> terminalSize { {
vtbackend::LineCount(25),
vtbackend::ColumnCount(80),
.lines = vtbackend::LineCount(25),
.columns = vtbackend::ColumnCount(80),
} };
ConfigEntry<WindowMargins, documentation::Margins> margins { { HorizontalMargin { 0u },
VerticalMargin { 0u } } };
ConfigEntry<WindowMargins, documentation::Margins> margins { { .horizontal = HorizontalMargin { 0u },
.vertical = VerticalMargin { 0u } } };
ConfigEntry<HistoryConfig, documentation::History> history {};
ConfigEntry<ScrollBarConfig, documentation::Scrollbar> scrollbar {};
ConfigEntry<MouseConfig, documentation::Mouse> mouse { true };
Expand All @@ -422,16 +422,18 @@ struct TerminalProfile
ConfigEntry<vtrasterizer::FontDescriptions, documentation::Fonts> fonts { defaultFont };
ConfigEntry<bool, documentation::DrawBoldTextWithBrightColors> drawBoldTextWithBrightColors { false };
ConfigEntry<InputModeConfig, documentation::ModeInsert> modeInsert { CursorConfig {
vtbackend::CursorShape::Bar, vtbackend::CursorDisplay::Steady, std::chrono::milliseconds { 500 } } };
.cursorShape = vtbackend::CursorShape::Bar,
.cursorDisplay = vtbackend::CursorDisplay::Steady,
.cursorBlinkInterval = std::chrono::milliseconds { 500 } } };
ConfigEntry<InputModeConfig, documentation::ModeNormal> modeNormal {
CursorConfig { vtbackend::CursorShape::Block,
vtbackend::CursorDisplay::Steady,
std::chrono::milliseconds { 500 } },
CursorConfig { .cursorShape = vtbackend::CursorShape::Block,
.cursorDisplay = vtbackend::CursorDisplay::Steady,
.cursorBlinkInterval = std::chrono::milliseconds { 500 } },
};
ConfigEntry<InputModeConfig, documentation::ModeVisual> modeVisual {
CursorConfig { vtbackend::CursorShape::Block,
vtbackend::CursorDisplay::Steady,
std::chrono::milliseconds { 500 } },
CursorConfig { .cursorShape = vtbackend::CursorShape::Block,
.cursorDisplay = vtbackend::CursorDisplay::Steady,
.cursorBlinkInterval = std::chrono::milliseconds { 500 } },
};
ConfigEntry<std::chrono::milliseconds, documentation::HighlightTimeout> highlightTimeout { 100 };
ConfigEntry<vtbackend::LineCount, documentation::ModalCursorScrollOff> modalCursorScrollOff {
Expand All @@ -452,7 +454,12 @@ const InputMappings defaultInputMappings {
.modifiers { vtbackend::Modifiers { vtbackend::Modifier::Alt } },
.input = vtbackend::Key::Enter,
.binding = { { actions::ToggleFullscreen {} } } },
KeyInputMapping { .modes {},
KeyInputMapping { .modes = []() -> vtbackend::MatchModes {
auto mods = vtbackend::MatchModes();
mods.enable(vtbackend::MatchModes::Select);
mods.enable(vtbackend::MatchModes::Insert);
return mods;
}(),
.modifiers { vtbackend::Modifiers {} },
.input = vtbackend::Key::Escape,
.binding = { { actions::CancelSelection {} } } },
Expand Down Expand Up @@ -1049,10 +1056,15 @@ struct Writer

[[nodiscard]] std::string format(KeyInputMapping v)
{
auto actionAndModes = format(" action: {} }}", v.binding[0]);
if (v.modes.any())
{
actionAndModes = format(" action: {}, mode: '{}' }}", v.binding[0], v.modes);
}
return format("{:<30},{:<30},{:<30}\n",
format("- {{ mods: [{}]", format(v.modifiers)),
format(" key: '{}'", v.input),
format(" action: {} }}", v.binding[0]));
actionAndModes);
}

[[nodiscard]] std::string format(CharInputMapping v)
Expand Down

0 comments on commit cd912d1

Please sign in to comment.