void ExecuteBuffer() { if (Buffer.Output.Length == 0) { return; } var output = commandProcesser.Process(Buffer.Output).Split('\n').Where(l => l != ""); Out.Add(new OutputLine(Buffer.Output, OutputLineType.Command)); foreach (var line in output) { Out.Add(new OutputLine(line, OutputLineType.Output)); } CommandHistory.Add(Buffer.Output); Buffer.Output = ""; }
void OnKeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == GameConsoleOptions.Options.ToggleKey) { ToggleConsole(); isHandled = true; } switch (e.KeyCode) { case Keys.Enter: ExecuteBuffer(); break; case Keys.Back: if (Buffer.Output.Length > 0) { Buffer.Output = Buffer.Output.Substring(0, Buffer.Output.Length - 1); } break; case Keys.Tab: AutoComplete(); break; case Keys.Up: Buffer.Output = CommandHistory.Previous(); break; case Keys.Down: Buffer.Output = CommandHistory.Next(); break; default: var @char = TranslateChar(e.KeyCode); if (IsPrintable(@char)) { Buffer.Output += @char; } break; } }