예제 #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);
            }
        }
예제 #2
0
 public void SetCursorAfterPrompt()
 {
     lock (_consoleAbstraction)
     {
         _consoleAbstraction.SetCursorPosition(Prompt.Length, _height);
     }
 }
예제 #3
0
 public void Stop()
 {
     _isStarted = false;
     _debugTextBox.Clear();
     _remoteTextBox.Clear();
     _consoleAbstraction.Clear();
     _consoleAbstraction.SetCursorPosition(0, 0);
 }