Exemple #1
0
        public async Task <string> ReadLineOnPositionAsync(Func <int> leftIndentResolver, int top)
        {
            var input = string.Empty;

            while (true)
            {
                _consoleAbstraction.SetCursorPosition(leftIndentResolver.Invoke() + input.Length, top);

                var key = await _consoleAbstraction.ReadKeyAsync();

                _consoleAbstraction.ClearLine(leftIndentResolver.Invoke(), top);

                if (key.Key == ConsoleKey.Enter)
                {
                    return(input);
                }

                if (key.Key == ConsoleKey.Backspace)
                {
                    if (input.Length > 0)
                    {
                        input = input.Remove(input.Length - 1);
                    }
                }
                else
                {
                    input += key.KeyChar;
                }

                _consoleAbstraction.WriteOnPosition(input, leftIndentResolver.Invoke(), top);
            }
        }
Exemple #2
0
 public void SetPrompt(string value)
 {
     _consoleAbstraction.ClearLine(0, _height);
     Prompt = value + " ";
     DisplayPrompt();
 }