فهرست منبع

Tidy up layout and fix old inaccurate comment

tznind 2 سال پیش
والد
کامیت
35e79a9f64
2فایلهای تغییر یافته به همراه13 افزوده شده و 13 حذف شده
  1. 7 7
      Terminal.Gui/ConsoleDrivers/WindowsDriver.cs
  2. 6 6
      UnitTests/ConsoleDriverTests.cs

+ 7 - 7
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 {
 
 		/// <summary>
 		/// Handles case when the 'key' providied is <see cref="ConsoleKey.Packet"/>
-		/// returning a new <see cref="ConsoleKeyInfo"/> where key is remapped
-		/// by parsing the Unicode char data of the <see cref="ConsoleKeyInfo"/>
+		/// returning a <see cref="Key"/> that reflects the unicode char that came with
+		/// the OS event.
 		/// </summary>
 		/// <exception cref="ArgumentException">Thrown if passed key was not a <see cref="ConsoleKey.Packet"/></exception>
 		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;

+ 6 - 6
UnitTests/ConsoleDriverTests.cs

@@ -617,20 +617,20 @@ namespace Terminal.Gui.ConsoleDrivers {
 		/// see: https://github.com/gui-cs/Terminal.Gui/issues/2008
 		/// </summary>
 		[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);
 		}
 	}
 }