From b140064b06c5860dfa54b538de8fd4be7cc00545 Mon Sep 17 00:00:00 2001 From: Leonard Hecker Date: Mon, 23 Sep 2024 20:55:34 +0200 Subject: [PATCH] Check EnableHexNumpad before enabling it --- src/cascadia/TerminalControl/TermControl.cpp | 29 ++++++++++++++++---- 1 file changed, 23 insertions(+), 6 deletions(-) diff --git a/src/cascadia/TerminalControl/TermControl.cpp b/src/cascadia/TerminalControl/TermControl.cpp index 565ea02ccf6..e2d8256ce1f 100644 --- a/src/cascadia/TerminalControl/TermControl.cpp +++ b/src/cascadia/TerminalControl/TermControl.cpp @@ -1631,12 +1631,29 @@ namespace winrt::Microsoft::Terminal::Control::implementation { if (vkey == VK_ADD) { - // Alt '+' is used to input Unicode code points. - // Every time you press + it resets the entire state - // in the original OS implementation as well. - s.encoding = AltNumpadEncoding::Unicode; - s.accumulator = 0; - s.active = true; + static const auto enabled = []() { + wchar_t buffer[4]{}; + DWORD size = sizeof(buffer); + RegGetValueW( + HKEY_CURRENT_USER, + L"Control Panel\\Input Method", + L"EnableHexNumpad", + RRF_RT_REG_SZ, + nullptr, + &buffer[0], + &size); + return size == 4 && memcmp(&buffer[0], L"1", 4) == 0; + }(); + + if (enabled) + { + // Alt '+' is used to input Unicode code points. + // Every time you press + it resets the entire state + // in the original OS implementation as well. + s.encoding = AltNumpadEncoding::Unicode; + s.accumulator = 0; + s.active = true; + } } else if (vkey == VK_NUMPAD0 && s.encoding == AltNumpadEncoding::OEM && s.accumulator == 0) {