Skip to content

Commit 124fb9b

Browse files
committed
Fix default binding for cancel selection with escape
1 parent f833ebb commit 124fb9b

File tree

2 files changed

+26
-13
lines changed

2 files changed

+26
-13
lines changed

metainfo.xml

+1
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@
107107
<release version="0.6.2" urgency="medium" type="development">
108108
<description>
109109
<ul>
110+
<li>Fixes `CancelSelection` default binding with escape (#1710)</li>
110111
<li>Fixes `CreateTab` to sometimes spawn more than one tab (#1695)</li>
111112
<li>Ensure inserting new tabs happens right next to the currently active tab (#1695)</li>
112113
<li>Adds `MoveTabToLeft` and `MoveTabToRight` actions to move tabs around (#1695)</li>

src/contour/Config.h

+25-13
Original file line numberDiff line numberDiff line change
@@ -409,11 +409,11 @@ struct TerminalProfile
409409
ConfigEntry<std::map<vtbackend::DECMode, bool>, documentation::FrozenDecMode> frozenModes {};
410410
ConfigEntry<std::chrono::milliseconds, documentation::SmoothLineScrolling> smoothLineScrolling { 100 };
411411
ConfigEntry<vtbackend::PageSize, documentation::TerminalSize> terminalSize { {
412-
vtbackend::LineCount(25),
413-
vtbackend::ColumnCount(80),
412+
.lines = vtbackend::LineCount(25),
413+
.columns = vtbackend::ColumnCount(80),
414414
} };
415-
ConfigEntry<WindowMargins, documentation::Margins> margins { { HorizontalMargin { 0u },
416-
VerticalMargin { 0u } } };
415+
ConfigEntry<WindowMargins, documentation::Margins> margins { { .horizontal = HorizontalMargin { 0u },
416+
.vertical = VerticalMargin { 0u } } };
417417
ConfigEntry<HistoryConfig, documentation::History> history {};
418418
ConfigEntry<ScrollBarConfig, documentation::Scrollbar> scrollbar {};
419419
ConfigEntry<MouseConfig, documentation::Mouse> mouse { true };
@@ -422,16 +422,18 @@ struct TerminalProfile
422422
ConfigEntry<vtrasterizer::FontDescriptions, documentation::Fonts> fonts { defaultFont };
423423
ConfigEntry<bool, documentation::DrawBoldTextWithBrightColors> drawBoldTextWithBrightColors { false };
424424
ConfigEntry<InputModeConfig, documentation::ModeInsert> modeInsert { CursorConfig {
425-
vtbackend::CursorShape::Bar, vtbackend::CursorDisplay::Steady, std::chrono::milliseconds { 500 } } };
425+
.cursorShape = vtbackend::CursorShape::Bar,
426+
.cursorDisplay = vtbackend::CursorDisplay::Steady,
427+
.cursorBlinkInterval = std::chrono::milliseconds { 500 } } };
426428
ConfigEntry<InputModeConfig, documentation::ModeNormal> modeNormal {
427-
CursorConfig { vtbackend::CursorShape::Block,
428-
vtbackend::CursorDisplay::Steady,
429-
std::chrono::milliseconds { 500 } },
429+
CursorConfig { .cursorShape = vtbackend::CursorShape::Block,
430+
.cursorDisplay = vtbackend::CursorDisplay::Steady,
431+
.cursorBlinkInterval = std::chrono::milliseconds { 500 } },
430432
};
431433
ConfigEntry<InputModeConfig, documentation::ModeVisual> modeVisual {
432-
CursorConfig { vtbackend::CursorShape::Block,
433-
vtbackend::CursorDisplay::Steady,
434-
std::chrono::milliseconds { 500 } },
434+
CursorConfig { .cursorShape = vtbackend::CursorShape::Block,
435+
.cursorDisplay = vtbackend::CursorDisplay::Steady,
436+
.cursorBlinkInterval = std::chrono::milliseconds { 500 } },
435437
};
436438
ConfigEntry<std::chrono::milliseconds, documentation::HighlightTimeout> highlightTimeout { 100 };
437439
ConfigEntry<vtbackend::LineCount, documentation::ModalCursorScrollOff> modalCursorScrollOff {
@@ -452,7 +454,12 @@ const InputMappings defaultInputMappings {
452454
.modifiers { vtbackend::Modifiers { vtbackend::Modifier::Alt } },
453455
.input = vtbackend::Key::Enter,
454456
.binding = { { actions::ToggleFullscreen {} } } },
455-
KeyInputMapping { .modes {},
457+
KeyInputMapping { .modes = []() -> vtbackend::MatchModes {
458+
auto mods = vtbackend::MatchModes();
459+
mods.enable(vtbackend::MatchModes::Select);
460+
mods.enable(vtbackend::MatchModes::Insert);
461+
return mods;
462+
}(),
456463
.modifiers { vtbackend::Modifiers {} },
457464
.input = vtbackend::Key::Escape,
458465
.binding = { { actions::CancelSelection {} } } },
@@ -1049,10 +1056,15 @@ struct Writer
10491056

10501057
[[nodiscard]] std::string format(KeyInputMapping v)
10511058
{
1059+
auto actionAndModes = format(" action: {} }}", v.binding[0]);
1060+
if (v.modes.any())
1061+
{
1062+
actionAndModes = format(" action: {}, mode: '{}' }}", v.binding[0], v.modes);
1063+
}
10521064
return format("{:<30},{:<30},{:<30}\n",
10531065
format("- {{ mods: [{}]", format(v.modifiers)),
10541066
format(" key: '{}'", v.input),
1055-
format(" action: {} }}", v.binding[0]));
1067+
actionAndModes);
10561068
}
10571069

10581070
[[nodiscard]] std::string format(CharInputMapping v)

0 commit comments

Comments
 (0)