Esempio n. 1
0
        private void HistoryUp()
        {
            if (!IsOpen())
            {
                return;
            }

            inputField.text = ConsoleBackend.HistoryUp(inputField.text);
            SetInputFieldCaretPos(inputField.text.Length);
        }
Esempio n. 2
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:
                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;
            }
        }