diff --git a/Terminal.Gui/ConsoleDrivers/WindowsDriver.cs b/Terminal.Gui/ConsoleDrivers/WindowsDriver.cs index 4261d3a0e..73f1915a8 100644 --- a/Terminal.Gui/ConsoleDrivers/WindowsDriver.cs +++ b/Terminal.Gui/ConsoleDrivers/WindowsDriver.cs @@ -1244,17 +1244,17 @@ namespace Terminal.Gui { keyModifiers.Scrolllock = scrolllock; var ConsoleKeyInfo = new ConsoleKeyInfo (keyEvent.UnicodeChar, (ConsoleKey)keyEvent.wVirtualKeyCode, shift, alt, control); - + return new WindowsConsole.ConsoleKeyInfoEx (ConsoleKeyInfo, capslock, numlock); } public Key MapKey (WindowsConsole.ConsoleKeyInfoEx keyInfoEx) { // If keystroke is a virtual key - if(keyInfoEx.consoleKeyInfo.Key == ConsoleKey.Packet) { - + if (keyInfoEx.consoleKeyInfo.Key == ConsoleKey.Packet) { + // try to map the 'char' that came with it into a Key - if(TryRemapPacketKey(keyInfoEx.consoleKeyInfo,out var result)) { + if (TryRemapPacketKey (keyInfoEx.consoleKeyInfo, out var result)) { return result; } } @@ -1771,8 +1771,8 @@ namespace Terminal.Gui { /// /// Handles case when the 'key' providied is - /// returning a new where key is remapped - /// by parsing the Unicode char data of the + /// returning a that reflects the unicode char that came with + /// the OS event. /// /// Thrown if passed key was not a internal static bool TryRemapPacketKey (ConsoleKeyInfo original, out Key result) @@ -1781,7 +1781,7 @@ namespace Terminal.Gui { var c = original.KeyChar; if (original.Key != ConsoleKey.Packet) - throw new ArgumentException ("Expected a ConsoleKeyInfo with a Key of Packet",nameof(original)); + throw new ArgumentException ("Expected a ConsoleKeyInfo with a Key of Packet", nameof (original)); if (c == '\0') { return false; diff --git a/UnitTests/ConsoleDriverTests.cs b/UnitTests/ConsoleDriverTests.cs index a55f76e09..1d414a00b 100644 --- a/UnitTests/ConsoleDriverTests.cs +++ b/UnitTests/ConsoleDriverTests.cs @@ -617,20 +617,20 @@ namespace Terminal.Gui.ConsoleDrivers { /// see: https://github.com/gui-cs/Terminal.Gui/issues/2008 /// [Theory] - [InlineData('A',true,false,false,Key.A)] - [InlineData('z',false,false,false, Key.z)] + [InlineData ('A', true, false, false, Key.A)] + [InlineData ('z', false, false, false, Key.z)] [InlineData (' ', false, false, false, Key.Space)] [InlineData ('\b', false, false, false, Key.Backspace)] [InlineData ('=', false, false, false, (Key)'=')] [InlineData ('+', true, false, false, (Key)'+')] - public void TestVKPacket(char unicodeCharacter,bool shift, bool alt, bool control, Key expectedRemapping) + public void TestVKPacket (char unicodeCharacter, bool shift, bool alt, bool control, Key expectedRemapping) { - var before = new ConsoleKeyInfo(unicodeCharacter,ConsoleKey.Packet,shift,alt,control); - Assert.True (WindowsDriver.TryRemapPacketKey (before,out var after)); + var before = new ConsoleKeyInfo (unicodeCharacter, ConsoleKey.Packet, shift, alt, control); + Assert.True (WindowsDriver.TryRemapPacketKey (before, out var after)); // The thing we are really interested in, did we correctly convert // the input ConsoleKey.Packet to the correct physical key - Assert.Equal(expectedRemapping,after); + Assert.Equal (expectedRemapping, after); } } }