PowerArgs.Cli.RichTextEditor.WriteCharacterForPressedKey C# (CSharp) Method

WriteCharacterForPressedKey() private method

private WriteCharacterForPressedKey ( ConsoleKeyInfo key ) : void
key System.ConsoleKeyInfo
return void
        private void WriteCharacterForPressedKey(ConsoleKeyInfo key)
        {
            var c = new ConsoleCharacter(key.KeyChar);
            if (CursorPosition == Context.Buffer.Count)
            {
                Context.Buffer.Add(c);
            }
            else
            {
                Context.Buffer.Insert(CursorPosition, c);
            }

            CursorPosition++;
        }