Class BehaviorExtensionMethods
- Namespace
- InteractiveReadLine.KeyBehaviors
- Assembly
- InteractiveReadLine.dll
Provides extension methods that register key behaviors on a configuration. Each method returns the supplied configuration for chaining and replaces any existing binding for the same key.
public static class BehaviorExtensionMethods
- Inheritance
-
BehaviorExtensionMethods
- Inherited Members
Methods
AddArrowMovesCursor(ReadLineConfig)
Binds the left and right arrow keys to moving the cursor one character in their direction.
public static ReadLineConfig AddArrowMovesCursor(this ReadLineConfig config)
Parameters
configReadLineConfigThe configuration to add the bindings to
Returns
- ReadLineConfig
The same configuration, for chaining
AddCancelKeys(ReadLineConfig)
Binds Ctrl+C to abandon the current line, matching conventional shell behavior.
public static ReadLineConfig AddCancelKeys(this ReadLineConfig config)
Parameters
configReadLineConfig
Returns
Remarks
The ConsoleReadLine provider puts the console into a mode where Ctrl+C arrives as an ordinary keypress rather than terminating the process, and restores the previous mode when it is disposed. Without this binding, Ctrl+C has no effect while a line is being read.
AddCtrlKeyBehavior(ReadLineConfig, ConsoleKey, Action<IKeyBehaviorTarget>)
Binds a behavior to a key pressed together with the control key.
public static ReadLineConfig AddCtrlKeyBehavior(this ReadLineConfig config, ConsoleKey key, Action<IKeyBehaviorTarget> action)
Parameters
configReadLineConfigThe configuration to add the binding to
keyConsoleKeyThe key which invokes the behavior when control is held
actionAction<IKeyBehaviorTarget>The behavior to run when the key is pressed
Returns
- ReadLineConfig
The same configuration, for chaining
AddCtrlNavKeys(ReadLineConfig)
Binds the control key navigation and editing commands familiar from Bash: cursor movement with Ctrl+A, B, E and F, backspace with Ctrl+H, cutting with Ctrl+K, U and W, pasting with Ctrl+Y, clearing with Ctrl+L, finishing with Ctrl+M, history with Ctrl+N and P, and Ctrl+D to delete forward or signal the end of input on an empty line.
public static ReadLineConfig AddCtrlNavKeys(this ReadLineConfig config)
Parameters
configReadLineConfigThe configuration to add the bindings to
Returns
- ReadLineConfig
The same configuration, for chaining
AddDeleteBackspace(ReadLineConfig)
Binds the delete key to removing the character under the cursor, and the backspace key to removing the character before it.
public static ReadLineConfig AddDeleteBackspace(this ReadLineConfig config)
Parameters
configReadLineConfigThe configuration to add the bindings to
Returns
- ReadLineConfig
The same configuration, for chaining
AddEnterToFinish(ReadLineConfig)
Binds the Enter key to finish the line and return from the read line operation.
public static ReadLineConfig AddEnterToFinish(this ReadLineConfig config)
Parameters
configReadLineConfigThe configuration to add the binding to
Returns
- ReadLineConfig
The same configuration, for chaining
AddHomeAndEndKeys(ReadLineConfig)
Binds the home and end keys to moving the cursor to the start and end of the line.
public static ReadLineConfig AddHomeAndEndKeys(this ReadLineConfig config)
Parameters
configReadLineConfigThe configuration to add the bindings to
Returns
- ReadLineConfig
The same configuration, for chaining
AddKeyBehavior(ReadLineConfig, KeyId, Action<IKeyBehaviorTarget>)
Binds a behavior to a key identified by a KeyId that contains the key and its modifiers.
public static ReadLineConfig AddKeyBehavior(this ReadLineConfig config, KeyId key, Action<IKeyBehaviorTarget> action)
Parameters
configReadLineConfigThe configuration to add the binding to
keyKeyIdThe key which invokes the behavior
actionAction<IKeyBehaviorTarget>The behavior to run when the key is pressed
Returns
- ReadLineConfig
The same configuration, for chaining
AddKeyBehavior(ReadLineConfig, char, Action<IKeyBehaviorTarget>)
Binds a behavior to a character, whichever combination of keys produced it. A character binding is matched before the key and modifier bindings are considered.
public static ReadLineConfig AddKeyBehavior(this ReadLineConfig config, char key, Action<IKeyBehaviorTarget> action)
Parameters
configReadLineConfigThe configuration to add the binding to
keycharThe character which invokes the behavior
actionAction<IKeyBehaviorTarget>The behavior to run when the character is typed
Returns
- ReadLineConfig
The same configuration, for chaining
AddKeyBehavior(ReadLineConfig, ConsoleKey, Action<IKeyBehaviorTarget>)
Binds a behavior to a key pressed with no modifiers.
public static ReadLineConfig AddKeyBehavior(this ReadLineConfig config, ConsoleKey key, Action<IKeyBehaviorTarget> action)
Parameters
configReadLineConfigThe configuration to add the binding to
keyConsoleKeyThe key which invokes the behavior
actionAction<IKeyBehaviorTarget>The behavior to run when the key is pressed
Returns
- ReadLineConfig
The same configuration, for chaining
AddKeyBehavior(ReadLineConfig, ConsoleKey, bool, bool, bool, Action<IKeyBehaviorTarget>)
Binds a behavior to a key pressed together with the given modifiers.
public static ReadLineConfig AddKeyBehavior(this ReadLineConfig config, ConsoleKey key, bool control, bool alt, bool shift, Action<IKeyBehaviorTarget> action)
Parameters
configReadLineConfigThe configuration to add the binding to
keyConsoleKeyThe key which invokes the behavior
controlboolWhether the control key must be held
altboolWhether the alt key must be held
shiftboolWhether the shift key must be held
actionAction<IKeyBehaviorTarget>The behavior to run when the key is pressed
Returns
- ReadLineConfig
The same configuration, for chaining
AddStandardKeys(ReadLineConfig)
Adds a set of standard keys to the configuration, including the default of inserting printable characters, enter to finish the line, delete, backspace, the left and right arrow keys, and Ctrl+C to abandon the line.
public static ReadLineConfig AddStandardKeys(this ReadLineConfig config)
Parameters
configReadLineConfig
Returns
AddTabAutoComplete(ReadLineConfig)
Binds Tab to cycle forward through auto-complete suggestions and Shift+Tab to cycle backward. The bindings do nothing unless the configuration also has a lexer and a suggestion provider.
public static ReadLineConfig AddTabAutoComplete(this ReadLineConfig config)
Parameters
configReadLineConfigThe configuration to add the bindings to
Returns
- ReadLineConfig
The same configuration, for chaining
AddUpDownHistoryNavigation(ReadLineConfig)
Binds the up and down arrow keys to step backward and forward through history. The bindings do nothing unless the configuration also has a history source.
public static ReadLineConfig AddUpDownHistoryNavigation(this ReadLineConfig config)
Parameters
configReadLineConfigThe configuration to add the bindings to
Returns
- ReadLineConfig
The same configuration, for chaining