private Task HandleInputs()
        {
            while (isRunning)
            {
                string input = System.Console.ReadLine();
                unityThread.Post(state => ConsoleBackend.ExecuteCommand(input), null);
            }

            return(Task.CompletedTask);
        }
        private static void HandleInput(string value)
        {
            Logger.Info($"cmd>: {value}");

            if (string.IsNullOrWhiteSpace(value))
            {
                return;
            }

            ConsoleBackend.ExecuteCommand(value);
        }
Exemple #3
0
        public void UpdateConsole()
        {
            //Return if there is no key available
            if (!System.Console.KeyAvailable)
            {
                return;
            }

            //Read the key
            ConsoleKeyInfo keyInfo = System.Console.ReadKey();

            switch (keyInfo.Key)
            {
            //Enter in input
            case ConsoleKey.Enter:
                string value = System.Console.ReadLine();
                Logger.Info($"cmd>: {value}");
                ConsoleBackend.ExecuteCommand(value);

                break;
            }
        }
Exemple #4
0
        public void UpdateConsole()
        {
            //Return if there is no key available
            if (!System.Console.KeyAvailable)
            {
                return;
            }

            //Read the key
            ConsoleKeyInfo keyInfo = System.Console.ReadKey();

            switch (keyInfo.Key)
            {
            //Enter in input
            case ConsoleKey.Enter:
                ConsoleBackend.ExecuteCommand(currentLine);
                currentLine = "";

                break;

            //Remove last input
            case ConsoleKey.Backspace:
                if (currentLine.Length > 0)
                {
                    currentLine = currentLine.Substring(0, currentLine.Length - 1);
                    System.Console.SetCursorPosition(0, System.Console.BufferHeight - 1);
                    ClearLine();
                    System.Console.Write(currentLine);
                }

                break;

            //Enter in key char
            default:
                currentLine += keyInfo.KeyChar;
                break;
            }
        }
        public void UpdateConsole()
        {
            //Return if there is no key available
            if (!System.Console.KeyAvailable)
            {
                return;
            }

            //Read the key
            ConsoleKeyInfo keyInfo = System.Console.ReadKey();

            switch (keyInfo.Key)
            {
            //Enter in input
            case ConsoleKey.Enter:
                DrawInputLine("\n");
                ConsoleBackend.ExecuteCommand(currentLine);
                currentLine = "";

                break;

            //Remove last input
            case ConsoleKey.Backspace:
                if (currentLine.Length > 0)
                {
                    currentLine = currentLine.Substring(0, currentLine.Length - 1);
                }
                RemoveLastInput();

                break;

            //Attempt to auto complete
            case ConsoleKey.Tab:
                ClearLine();
                currentLine = ConsoleBackend.AutoComplete(currentLine);
                System.Console.Write(currentLine);

                break;

            //Go up in history of commands
            case ConsoleKey.PageUp:
            case ConsoleKey.UpArrow:
                ClearLine();
                currentLine = ConsoleBackend.HistoryUp(currentLine);
                System.Console.Write(currentLine);

                break;

            //Go back in history of commands
            case ConsoleKey.PageDown:
            case ConsoleKey.DownArrow:
                ClearLine();
                currentLine = ConsoleBackend.HistoryDown();
                System.Console.Write(currentLine);

                break;

            //Enter in key char
            default:
                currentLine += keyInfo.KeyChar;
                DrawInputLine(keyInfo.KeyChar.ToString());
                break;
            }
        }