Beispiel #1
0
        internal static void HandleKeyUp()
        {
            _keyUpCount++;
            _enteredCommands.Reverse();

            string line = string.Empty;

            if (_keyUpCount <= _enteredCommands.Count())
            {
                line = _enteredCommands[_keyUpCount - 1];
            }
            else if (_keyUpCount > _enteredCommands.Count)
            {
                _keyUpCount -= _enteredCommands.Count();
                line         = _enteredCommands[_keyUpCount - 1];
            }

            ConsoleInterface.ClearCurrentLine();
            ConsoleInterface.ShowPrefix();
            ConsoleInterface.Builder.Clear();
            ConsoleInterface.Builder.Append(line);
            Console.Write(ConsoleInterface.Builder.ToString());

            _enteredCommands.Reverse();
        }
Beispiel #2
0
        /// <summary>
        /// Renders on console screen the potential match on the line
        /// </summary>
        /// <param name="currentInput">The current prefix value - minus the actual command. This is the thing we'll be searching for.</param>
        /// <param name="commandPrefix">The type of command we are processing</param>
        /// <param name="potentialValues">A list of poential values we want to try to match to</param>
        private static void HandleTabAutoComplete(string currentInput, string commandPrefix, List <string> potentialValues)
        {
            string outputItem = string.Empty;
            var    matches    = potentialValues.Where(item => item != currentInput && item.StartsWith(currentInput, true, CultureInfo.InvariantCulture));

            if (matches.Count() == 0)
            {
                return;
            }

            _tabCount++;

            if (_tabCount <= matches.Count())
            {
                outputItem = matches.ToList()[_tabCount - 1];
            }
            else if (_tabCount > matches.Count())
            {
                _tabCount -= matches.Count();
                outputItem = matches.ToList()[_tabCount - 1];
            }

            ConsoleInterface.ClearCurrentLine();
            ConsoleInterface.ShowPrefix();
            string line = commandPrefix + " " + outputItem;

            ConsoleInterface.Builder.Clear();
            ConsoleInterface.Builder.Append(line);
            Console.Write(ConsoleInterface.Builder.ToString());
        }