mirror of
https://github.com/gui-cs/Terminal.Gui.git
synced 2025-12-30 17:57:57 +01:00
Cleans up key handling in drivers (was "fixes VkeyPacketSimulator is broken") (#3078)
* Fixes #3054. VkeyPacketSimulator scenario is broken. * Fix some key handle and unit tests. * Remove unnecessary conditional. * Improves key handling. * Also allow map capslock to shift with accented characters. * Change to MemberData. * Remove unnecessary using. * Fix merge errors. * Fixes #3095. WindowsDriver should return the mask keys to IsShift, IsAlt and IsCtrl return the right value. * Modifiers keys are valid to be handled on key down and key up. * Map KeyCode.Enter to ConsoleKey.Enter and vice versa. * Updated ScanCodeMapping table with readable constants * Documented bugs * Implemented mapping using MapVirtualKeyEx * Implemented mapping using MapVirtualKeyEx * Changed KeyCode special keys to match ConsoleKey values + max unicode codepoint * Fixed bogus CollectionNavigator impl and tests * Nuked DeleteChar. renamed InsertChar to Insert * KeyCode.Enter = ConsoleKey.Enter, not \n * Code cleanup * Added diag for keyboard layout name * Fixed AltGr support (hopefully) * Simplified code * Simplified KeyCode by removing ShiftKeys * Fixed TextView * Code cleanup * Fixes cursesdriver (somewhat) * Code cleanup * netdriver wip * Fixed netdriver under WSL * Turned off debug spew * Removed old code --------- Co-authored-by: Tig Kindel <tig@users.noreply.github.com> Co-authored-by: Tig Kindel <tig@kindel.com>
This commit is contained in:
@@ -249,7 +249,7 @@ namespace Terminal.Gui.TextTests {
|
||||
[InlineData ("After K_", false, -1, KeyCode.Null, true)]
|
||||
[InlineData ("Multiple _K and _R", true, 9, (KeyCode)'K', true)]
|
||||
[InlineData ("Non-english: _Кдать", true, 13, (KeyCode)'К', true)] // Cryllic K (К)
|
||||
public void FindHotKey_AlphaUpperCase_Succeeds (string text, bool expectedResult, int expectedHotPos, Key expectedKey, bool supportFirstUpperCase = false)
|
||||
public void FindHotKey_AlphaUpperCase_Succeeds (string text, bool expectedResult, int expectedHotPos, KeyCode expectedKey, bool supportFirstUpperCase = false)
|
||||
{
|
||||
Rune hotKeySpecifier = (Rune)'_';
|
||||
|
||||
@@ -261,7 +261,7 @@ namespace Terminal.Gui.TextTests {
|
||||
}
|
||||
Assert.Equal (expectedResult, result);
|
||||
Assert.Equal (expectedHotPos, hotPos);
|
||||
Assert.Equal (expectedKey, hotKey);
|
||||
Assert.Equal ((Key)expectedKey, hotKey);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
@@ -277,7 +277,7 @@ namespace Terminal.Gui.TextTests {
|
||||
[InlineData ("After k_", false, -1, KeyCode.Null, true)]
|
||||
[InlineData ("Multiple _k and _r", true, 9, (KeyCode)'K', true)]
|
||||
[InlineData ("Non-english: _кдать", true, 13, (KeyCode)'к', true)] // Cryllic K (К)
|
||||
public void FindHotKey_AlphaLowerCase_Succeeds (string text, bool expectedResult, int expectedHotPos, Key expectedKey, bool supportFirstUpperCase = false)
|
||||
public void FindHotKey_AlphaLowerCase_Succeeds (string text, bool expectedResult, int expectedHotPos, KeyCode expectedKey, bool supportFirstUpperCase = false)
|
||||
{
|
||||
Rune hotKeySpecifier = (Rune)'_';
|
||||
|
||||
@@ -289,7 +289,7 @@ namespace Terminal.Gui.TextTests {
|
||||
}
|
||||
Assert.Equal (expectedResult, result);
|
||||
Assert.Equal (expectedHotPos, hotPos);
|
||||
Assert.Equal (expectedKey, hotKey);
|
||||
Assert.Equal ((Key)expectedKey, hotKey);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
@@ -303,7 +303,7 @@ namespace Terminal.Gui.TextTests {
|
||||
[InlineData ("Last _1", true, 5, (KeyCode)'1', true)]
|
||||
[InlineData ("After 1_", false, -1, KeyCode.Null, true)]
|
||||
[InlineData ("Multiple _1 and _2", true, 9, (KeyCode)'1', true)]
|
||||
public void FindHotKey_Numeric_Succeeds (string text, bool expectedResult, int expectedHotPos, Key expectedKey, bool supportFirstUpperCase = false)
|
||||
public void FindHotKey_Numeric_Succeeds (string text, bool expectedResult, int expectedHotPos, KeyCode expectedKey, bool supportFirstUpperCase = false)
|
||||
{
|
||||
Rune hotKeySpecifier = (Rune)'_';
|
||||
|
||||
@@ -315,7 +315,7 @@ namespace Terminal.Gui.TextTests {
|
||||
}
|
||||
Assert.Equal (expectedResult, result);
|
||||
Assert.Equal (expectedHotPos, hotPos);
|
||||
Assert.Equal (expectedKey, hotKey);
|
||||
Assert.Equal ((Key)expectedKey, hotKey);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
@@ -324,7 +324,7 @@ namespace Terminal.Gui.TextTests {
|
||||
[InlineData ("last K", true, 5, (KeyCode)'K')]
|
||||
[InlineData ("multiple K and R", true, 9, (KeyCode)'K')]
|
||||
[InlineData ("non-english: Кдать", true, 13, (KeyCode)'К')] // Cryllic K (К)
|
||||
public void FindHotKey_Legacy_FirstUpperCase_Succeeds (string text, bool expectedResult, int expectedHotPos, Key expectedKey)
|
||||
public void FindHotKey_Legacy_FirstUpperCase_Succeeds (string text, bool expectedResult, int expectedHotPos, KeyCode expectedKey)
|
||||
{
|
||||
var supportFirstUpperCase = true;
|
||||
|
||||
@@ -338,25 +338,25 @@ namespace Terminal.Gui.TextTests {
|
||||
}
|
||||
Assert.Equal (expectedResult, result);
|
||||
Assert.Equal (expectedHotPos, hotPos);
|
||||
Assert.Equal (expectedKey, hotKey);
|
||||
Assert.Equal ((Key)expectedKey, hotKey);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
//[InlineData ("_\"k before", false, Key.Null)] // BUGBUG: Not sure why this fails
|
||||
[InlineData ("_\"k before", true, (KeyCode)'"')] // BUGBUG: Not sure why this fails. " is a normal char
|
||||
[InlineData ("\"_k before", true, KeyCode.K)]
|
||||
[InlineData ("_`~!@#$%^&*()-_=+[{]}\\|;:'\",<.>/?", true, (KeyCode)'`')]
|
||||
[InlineData ("`_~!@#$%^&*()-_=+[{]}\\|;:'\",<.>/?", true, (KeyCode)'~')]
|
||||
//[InlineData ("`~!@#$%^&*()-__=+[{]}\\|;:'\",<.>/?", true, (Key)'_')] // BUGBUG: Not sure why this fails
|
||||
[InlineData ("`~!@#$%^&*()-__=+[{]}\\|;:'\",<.>/?", true, (KeyCode)'=')] // BUGBUG: Not sure why this fails. Ignore the first and consider the second
|
||||
[InlineData ("_ ~ s gui.cs master ↑10", true, (KeyCode)'')] // ~IsLetterOrDigit + Unicode
|
||||
[InlineData (" ~ s gui.cs _ master ↑10", true, (KeyCode)'')] // ~IsLetterOrDigit + Unicode
|
||||
[InlineData ("non-english: _кдать", true, (KeyCode)'к')] // Lower case Cryllic K (к)
|
||||
public void FindHotKey_Symbols_Returns_Symbol (string text, bool found, Key expected)
|
||||
public void FindHotKey_Symbols_Returns_Symbol (string text, bool found, KeyCode expected)
|
||||
{
|
||||
var hotKeySpecifier = (Rune)'_';
|
||||
|
||||
var result = TextFormatter.FindHotKey (text, hotKeySpecifier, false, out int _, out var hotKey);
|
||||
Assert.Equal (found, result);
|
||||
Assert.Equal (expected, hotKey);
|
||||
Assert.Equal ((Key)expected, hotKey);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
|
||||
Reference in New Issue
Block a user