diff --git a/PowerSession.Cli/PowerSession.Cli.csproj b/PowerSession.Cli/PowerSession.Cli.csproj index 44d2cb4..2783227 100644 --- a/PowerSession.Cli/PowerSession.Cli.csproj +++ b/PowerSession.Cli/PowerSession.Cli.csproj @@ -9,9 +9,9 @@ PowerSession Yuwei Ba true - 1.2.1 - 1.2.1 - 1.2.1 + 1.4.0 + 1.4.0 + 1.4.0 true PowerSession https://github.com/ibigbug/PowerSession @@ -24,7 +24,7 @@ - + diff --git a/PowerSession.ConPTY/Terminal.cs b/PowerSession.ConPTY/Terminal.cs index 37c0703..4d533f4 100644 --- a/PowerSession.ConPTY/Terminal.cs +++ b/PowerSession.ConPTY/Terminal.cs @@ -14,6 +14,10 @@ namespace PowerSession.Main.ConPTY public sealed class Terminal { private const string CtrlC_Command = "\x3"; + private char[] UpArrow = new []{(char) 0x1b, (char) 0x5b, 'A'}; + private char[] DownArrow = new []{(char) 0x1b, (char) 0x5b, 'B'}; + private char[] RightArrow = new []{(char) 0x1b, (char) 0x5b, 'C'}; + private char[] LeftArrow = new []{(char) 0x1b, (char) 0x5b, 'D'}; private readonly Stream _inputReader; private readonly Stream _outputWriter; @@ -92,7 +96,24 @@ private void AttachStdin() while (!_token.IsCancellationRequested) { var key = Console.ReadKey(true); - _consoleInputWriter.Write(key.KeyChar); + switch (key.Key) + { + case ConsoleKey.UpArrow: + _consoleInputWriter.Write(UpArrow); + break; + case ConsoleKey.DownArrow: + _consoleInputWriter.Write(DownArrow); + break; + case ConsoleKey.RightArrow: + _consoleInputWriter.Write(RightArrow); + break; + case ConsoleKey.LeftArrow: + _consoleInputWriter.Write(LeftArrow); + break; + default: + _consoleInputWriter.Write(key.KeyChar); + break; + } } }, TaskCreationOptions.LongRunning); } diff --git a/PowerSession.sln b/PowerSession.sln index c8aac43..3243b1c 100644 --- a/PowerSession.sln +++ b/PowerSession.sln @@ -1,4 +1,4 @@ - + Microsoft Visual Studio Solution File, Format Version 12.00 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PowerSession.ConPTY", "PowerSession.ConPTY\PowerSession.ConPTY.csproj", "{0E1F00C7-4F6B-4A7D-9A2F-6AD18A3D2F0A}" EndProject