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

RegisterKeyPress() public method

public RegisterKeyPress ( ConsoleKeyInfo key ) : void
key System.ConsoleKeyInfo
return void
        public void RegisterKeyPress(ConsoleKeyInfo key)
        {
            Context.Reset();
            Context.KeyPressed = key;
            Context.CharacterToWrite = new ConsoleCharacter(Context.KeyPressed.KeyChar);

            IKeyHandler handler = null;

            if (KeyHandlers.TryGetValue(Context.KeyPressed.Key, out handler) == false && RichTextCommandLineReader.IsWriteable(Context.KeyPressed))
            {
                WriteCharacterForPressedKey(Context.KeyPressed);
                DoSyntaxHighlighting(Context);
            }
            else if (handler != null)
            {
                handler.Handle(Context);

                if (Context.Intercept == false && RichTextCommandLineReader.IsWriteable(Context.KeyPressed))
                {
                    WriteCharacterForPressedKey(Context.KeyPressed);
                }

                DoSyntaxHighlighting(Context);
            }
            FireValueChanged();
        }

Usage Example

Example #1
0
        private void OnKeyInputReceived(ConsoleKeyInfo info)
        {
            ConsoleCharacter?prototype = this.Value.Length == 0 ? (ConsoleCharacter?)null : this.Value[this.Value.Length - 1];

            textState.RegisterKeyPress(info, prototype);
            blinkState = true;
            Application.ChangeInterval(blinkTimerHandle, BlinkInterval);
        }
All Usage Examples Of PowerArgs.Cli.RichTextEditor::RegisterKeyPress