Skip to content

Commit

Permalink
Merge pull request #1581 from contour-terminal/fix/numpad_keymapping
Browse files Browse the repository at this point in the history
Add missing keymapping for numpad during config load
  • Loading branch information
Yaraslaut authored Aug 1, 2024
2 parents 34289b2 + 56611c5 commit c895cde
Show file tree
Hide file tree
Showing 2 changed files with 83 additions and 63 deletions.
1 change: 1 addition & 0 deletions metainfo.xml
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@
<li>Fixes bell sound in spawned window in same process (#1515)</li>
<li>Fixes status line crush (#1511)</li>
<li>Fixes application window icon on (KDE) Wayland</li>
<li>Fixes missing keymapping for numpad (#1325)</li>
<li>Improves handling of constant bell sound spawning</li>
<li>Fixes yW (yank WORD) not working properly in normal mode (#1448)</li>
</ul>
Expand Down
145 changes: 82 additions & 63 deletions src/contour/Config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1392,7 +1392,10 @@ bool YAMLConfigReader::tryAddKey(InputMappings& inputMappings,

auto const input = parseKeyOrChar(node.as<std::string>());
if (!input.has_value())
{
logger()("Could not parse key:{}", node.as<std::string>());
return false;
}

if (holds_alternative<vtbackend::Key>(*input))
{
Expand Down Expand Up @@ -1448,69 +1451,85 @@ std::optional<vtbackend::Key> YAMLConfigReader::parseKey(std::string const& name
{
using vtbackend::Key;
using namespace std::literals::string_view_literals;
auto static constexpr Mappings = std::array {
std::pair { "F1"sv, Key::F1 },
std::pair { "F2"sv, Key::F2 },
std::pair { "F3"sv, Key::F3 },
std::pair { "F4"sv, Key::F4 },
std::pair { "F5"sv, Key::F5 },
std::pair { "F6"sv, Key::F6 },
std::pair { "F7"sv, Key::F7 },
std::pair { "F8"sv, Key::F8 },
std::pair { "F9"sv, Key::F9 },
std::pair { "F10"sv, Key::F10 },
std::pair { "F11"sv, Key::F11 },
std::pair { "F12"sv, Key::F12 },
std::pair { "F13"sv, Key::F13 },
std::pair { "F14"sv, Key::F14 },
std::pair { "F15"sv, Key::F15 },
std::pair { "F16"sv, Key::F16 },
std::pair { "F17"sv, Key::F17 },
std::pair { "F18"sv, Key::F18 },
std::pair { "F19"sv, Key::F19 },
std::pair { "F20"sv, Key::F20 },
std::pair { "F21"sv, Key::F21 },
std::pair { "F22"sv, Key::F22 },
std::pair { "F23"sv, Key::F23 },
std::pair { "F24"sv, Key::F24 },
std::pair { "F25"sv, Key::F25 },
std::pair { "F26"sv, Key::F26 },
std::pair { "F27"sv, Key::F27 },
std::pair { "F28"sv, Key::F28 },
std::pair { "F29"sv, Key::F29 },
std::pair { "F30"sv, Key::F30 },
std::pair { "F31"sv, Key::F31 },
std::pair { "F32"sv, Key::F32 },
std::pair { "F33"sv, Key::F33 },
std::pair { "F34"sv, Key::F34 },
std::pair { "F35"sv, Key::F35 },
std::pair { "Escape"sv, Key::Escape },
std::pair { "Enter"sv, Key::Enter },
std::pair { "Tab"sv, Key::Tab },
std::pair { "Backspace"sv, Key::Backspace },
std::pair { "DownArrow"sv, Key::DownArrow },
std::pair { "LeftArrow"sv, Key::LeftArrow },
std::pair { "RightArrow"sv, Key::RightArrow },
std::pair { "UpArrow"sv, Key::UpArrow },
std::pair { "Insert"sv, Key::Insert },
std::pair { "Delete"sv, Key::Delete },
std::pair { "Home"sv, Key::Home },
std::pair { "End"sv, Key::End },
std::pair { "PageUp"sv, Key::PageUp },
std::pair { "PageDown"sv, Key::PageDown },
std::pair { "MediaPlay"sv, Key::MediaPlay },
std::pair { "MediaStop"sv, Key::MediaStop },
std::pair { "MediaPrevious"sv, Key::MediaPrevious },
std::pair { "MediaNext"sv, Key::MediaNext },
std::pair { "MediaPause"sv, Key::MediaPause },
std::pair { "MediaTogglePlayPause"sv, Key::MediaTogglePlayPause },
std::pair { "VolumeUp"sv, Key::VolumeUp },
std::pair { "VolumeDown"sv, Key::VolumeDown },
std::pair { "VolumeMute"sv, Key::VolumeMute },
std::pair { "PrintScreen"sv, Key::PrintScreen },
std::pair { "Pause"sv, Key::Pause },
std::pair { "Menu"sv, Key::Menu },
};
auto static constexpr Mappings =
std::array { std::pair { "F1"sv, Key::F1 },
std::pair { "F2"sv, Key::F2 },
std::pair { "F3"sv, Key::F3 },
std::pair { "F4"sv, Key::F4 },
std::pair { "F5"sv, Key::F5 },
std::pair { "F6"sv, Key::F6 },
std::pair { "F7"sv, Key::F7 },
std::pair { "F8"sv, Key::F8 },
std::pair { "F9"sv, Key::F9 },
std::pair { "F10"sv, Key::F10 },
std::pair { "F11"sv, Key::F11 },
std::pair { "F12"sv, Key::F12 },
std::pair { "F13"sv, Key::F13 },
std::pair { "F14"sv, Key::F14 },
std::pair { "F15"sv, Key::F15 },
std::pair { "F16"sv, Key::F16 },
std::pair { "F17"sv, Key::F17 },
std::pair { "F18"sv, Key::F18 },
std::pair { "F19"sv, Key::F19 },
std::pair { "F20"sv, Key::F20 },
std::pair { "F21"sv, Key::F21 },
std::pair { "F22"sv, Key::F22 },
std::pair { "F23"sv, Key::F23 },
std::pair { "F24"sv, Key::F24 },
std::pair { "F25"sv, Key::F25 },
std::pair { "F26"sv, Key::F26 },
std::pair { "F27"sv, Key::F27 },
std::pair { "F28"sv, Key::F28 },
std::pair { "F29"sv, Key::F29 },
std::pair { "F30"sv, Key::F30 },
std::pair { "F31"sv, Key::F31 },
std::pair { "F32"sv, Key::F32 },
std::pair { "F33"sv, Key::F33 },
std::pair { "F34"sv, Key::F34 },
std::pair { "F35"sv, Key::F35 },
std::pair { "Escape"sv, Key::Escape },
std::pair { "Enter"sv, Key::Enter },
std::pair { "Tab"sv, Key::Tab },
std::pair { "Backspace"sv, Key::Backspace },
std::pair { "DownArrow"sv, Key::DownArrow },
std::pair { "LeftArrow"sv, Key::LeftArrow },
std::pair { "RightArrow"sv, Key::RightArrow },
std::pair { "UpArrow"sv, Key::UpArrow },
std::pair { "Insert"sv, Key::Insert },
std::pair { "Delete"sv, Key::Delete },
std::pair { "Home"sv, Key::Home },
std::pair { "End"sv, Key::End },
std::pair { "PageUp"sv, Key::PageUp },
std::pair { "PageDown"sv, Key::PageDown },
std::pair { "MediaPlay"sv, Key::MediaPlay },
std::pair { "MediaStop"sv, Key::MediaStop },
std::pair { "MediaPrevious"sv, Key::MediaPrevious },
std::pair { "MediaNext"sv, Key::MediaNext },
std::pair { "MediaPause"sv, Key::MediaPause },
std::pair { "MediaTogglePlayPause"sv, Key::MediaTogglePlayPause },
std::pair { "VolumeUp"sv, Key::VolumeUp },
std::pair { "VolumeDown"sv, Key::VolumeDown },
std::pair { "VolumeMute"sv, Key::VolumeMute },
std::pair { "PrintScreen"sv, Key::PrintScreen },
std::pair { "Pause"sv, Key::Pause },
std::pair { "Menu"sv, Key::Menu },
std::pair { "Numpad_Add"sv, Key::Numpad_Add },
std::pair { "Numpad_Divide"sv, Key::Numpad_Divide },
std::pair { "Numpad_Multiply"sv, Key::Numpad_Multiply },
std::pair { "Numpad_Subtract"sv, Key::Numpad_Subtract },
std::pair { "Numpad_Decimal"sv, Key::Numpad_Decimal },
std::pair { "Numpad_Enter"sv, Key::Numpad_Enter },
std::pair { "Numpad_Equal"sv, Key::Numpad_Equal },
std::pair { "Numpad_0"sv, Key::Numpad_0 },
std::pair { "Numpad_1"sv, Key::Numpad_1 },
std::pair { "Numpad_2"sv, Key::Numpad_2 },
std::pair { "Numpad_3"sv, Key::Numpad_3 },
std::pair { "Numpad_4"sv, Key::Numpad_4 },
std::pair { "Numpad_5"sv, Key::Numpad_5 },
std::pair { "Numpad_6"sv, Key::Numpad_6 },
std::pair { "Numpad_7"sv, Key::Numpad_7 },
std::pair { "Numpad_8"sv, Key::Numpad_8 },
std::pair { "Numpad_9"sv, Key::Numpad_9 } };

auto const lowerName = crispy::toLower(name);

Expand Down

0 comments on commit c895cde

Please sign in to comment.