mirror of
https://github.com/gui-cs/Terminal.Gui.git
synced 2025-12-26 15:57:56 +01:00
Add net ansi sequences
This commit is contained in:
53
TerminalGuiFluentTesting/NetSequences.cs
Normal file
53
TerminalGuiFluentTesting/NetSequences.cs
Normal file
@@ -0,0 +1,53 @@
|
||||
namespace TerminalGuiFluentTesting;
|
||||
class NetSequences
|
||||
{
|
||||
public static ConsoleKeyInfo [] Down = new []
|
||||
{
|
||||
new ConsoleKeyInfo('\x1B', ConsoleKey.Enter, false, false, false),
|
||||
new ConsoleKeyInfo('[', ConsoleKey.None, false, false, false),
|
||||
new ConsoleKeyInfo('B', ConsoleKey.None, false, false, false),
|
||||
};
|
||||
|
||||
public static ConsoleKeyInfo [] Up = new []
|
||||
{
|
||||
new ConsoleKeyInfo('\x1B', ConsoleKey.Enter, false, false, false),
|
||||
new ConsoleKeyInfo('[', ConsoleKey.None, false, false, false),
|
||||
new ConsoleKeyInfo('A', ConsoleKey.None, false, false, false),
|
||||
};
|
||||
|
||||
public static ConsoleKeyInfo [] Left = new []
|
||||
{
|
||||
new ConsoleKeyInfo('\x1B', ConsoleKey.Enter, false, false, false),
|
||||
new ConsoleKeyInfo('[', ConsoleKey.None, false, false, false),
|
||||
new ConsoleKeyInfo('D', ConsoleKey.None, false, false, false),
|
||||
};
|
||||
|
||||
public static ConsoleKeyInfo [] Right = new []
|
||||
{
|
||||
new ConsoleKeyInfo('\x1B', ConsoleKey.Enter, false, false, false),
|
||||
new ConsoleKeyInfo('[', ConsoleKey.None, false, false, false),
|
||||
new ConsoleKeyInfo('C', ConsoleKey.None, false, false, false),
|
||||
};
|
||||
|
||||
public static IEnumerable<ConsoleKeyInfo> Click (int button, int screenX, int screenY)
|
||||
{
|
||||
// Adjust for 1-based coordinates
|
||||
int adjustedX = screenX + 1;
|
||||
int adjustedY = screenY + 1;
|
||||
|
||||
// Mouse press sequence
|
||||
var sequence = $"\x1B[<{button};{adjustedX};{adjustedY}M";
|
||||
foreach (char c in sequence)
|
||||
{
|
||||
yield return new ConsoleKeyInfo (c, ConsoleKey.None, false, false, false);
|
||||
}
|
||||
|
||||
// Mouse release sequence
|
||||
sequence = $"\x1B[<{button};{adjustedX};{adjustedY}m";
|
||||
foreach (char c in sequence)
|
||||
{
|
||||
yield return new ConsoleKeyInfo (c, ConsoleKey.None, false, false, false);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user