16 private readonly Queue<string>
_inputQueue =
new Queue<string>();
22 _terminal.AttachCustomKeyEventHandler((args) =>
24 if (args.Type !=
"keydown")
26 if (args.Key ==
"Enter")
33 else if (args.Key ==
"Backspace")
47 else if(args.Key ==
"ArrowLeft")
55 else if(args.Key ==
"ArrowRight")
63 else if(args.Key.Length == 1)
80 else if(args.Key ==
"Tab")
88 Console.WriteLine(
"Unknown Key: " + args.Key);
102 private static Dictionary<ConsoleColor, string>
_colorMap =
new Dictionary<ConsoleColor, string>
104 {ConsoleColor.Black,
"#000000"},
105 {ConsoleColor.DarkBlue,
"#000080"},
106 {ConsoleColor.DarkGreen,
"#008000"},
107 {ConsoleColor.DarkCyan,
"#008080"},
108 {ConsoleColor.DarkRed,
"#800000"},
109 {ConsoleColor.DarkMagenta,
"#800080"},
110 {ConsoleColor.DarkYellow,
"#808000"},
111 {ConsoleColor.Gray,
"#c0c0c0"},
112 {ConsoleColor.DarkGray,
"#808080"},
113 {ConsoleColor.Blue,
"#0000ff"},
114 {ConsoleColor.Green,
"#00ff00"},
115 {ConsoleColor.Cyan,
"#00ffff"},
116 {ConsoleColor.Red,
"#ff0000"},
117 {ConsoleColor.Magenta,
"#ff00ff"},
118 {ConsoleColor.Yellow,
"#ffff00"},
119 {ConsoleColor.White,
"#ffffff"}
125 _options.Theme.Background =
_colorMap[color];
132 _options.Theme.Foreground =
_colorMap[color];
138 if (str.Contains(
'\n'))
140 string[] lines = str.Split(
'\n');
141 foreach (
string line
in lines.SkipLast(1))
152 if (str.Contains(
'\n'))
154 string[] lines = str.Split(
'\n');
155 foreach (
string line
in lines)
169 throw new NotSupportedException(
"Can not read line synchronously from XTermConsole");
180 await Task.Delay(100);
readonly TerminalOptions _options
string ReadLine()
Reads a line from the console.
void SetForegroundColor(ConsoleColor color)
void WriteLine(string str)
Writes a string to the console and appends a newline.
XTermConsole(TerminalOptions options, Xterm terminal)
void Clear()
Clears the console.
ConsoleColor _backgroundColor
ConsoleColor ForegroundColor
The Foreground Color.
ConsoleColor BackgroundColor
The Background Color.
void Write(string str)
Writes a string to the console.
async Task< string > ReadLineAsync()
Reads a line from the console asynchronously.
void SetBackgroundColor(ConsoleColor color)
readonly Queue< string > _inputQueue
readonly StringBuilder _inputBuffer
ConsoleColor _foregroundColor
static Dictionary< ConsoleColor, string > _colorMap
Interface that abstracts the console.
Contains a Console Abstraction Layer to be able to Simulate Console Input/Output over the Network.