コード例 #1
0
        private void InputLoop()
        {
            application.Input.OnSendCommand += Input_OnSendCommand;
            // TODO: probably better to handle that in another file.
            // TODO: handle multiple lines edit and nav
            //var line = ""; // change for a string builder? or probably just send 1 character at the time to the renderer...
            while (!quit)
            {
                if (Console.KeyAvailable)
                {
                    var key = Console.ReadKey(true);
                    application.OnKeyPress(key);

                    /*
                     * if (key.Key == ConsoleKey.Enter)
                     * {
                     *  var command = CommandFactory.Create(line);
                     *
                     *  if (command.IsValid())
                     *      context.ExecuteCommand(command);
                     *  else
                     *      application.Server.Write(LogType.Error, "Command doesn't exists. Type /help for available commands.");
                     *
                     *  quit = command is QuitCommand;
                     * }
                     * else
                     * {
                     *  if (key.Modifiers.HasFlag(ConsoleModifiers.Control) || key.Modifiers.HasFlag(ConsoleModifiers.Alt))
                     *  {
                     *      // TODO
                     *  }
                     *  else
                     *  {
                     *
                     *  }
                     *  // TODO: render the key press async!
                     *  // TODO: hadle the different modifiers and keys. hack for now.
                     *  line += key.KeyChar;
                     * }*/
                }

                Thread.Sleep(1);
            }
        }