Skip to content

Latest commit

 

History

History
917 lines (560 loc) · 41 KB

File metadata and controls

917 lines (560 loc) · 41 KB

ConsolePlus

ConsoleKeyInfoExtensions Class

Provides extension methods for System.ConsoleKeyInfo to evaluate specific key combinations, including standard keys and Emacs-style shortcuts.

public static class ConsoleKeyInfoExtensions

Inheritance System.Object → ConsoleKeyInfoExtensions

Methods

ConsoleKeyInfoExtensions.IsBackwardWord(this ConsoleKeyInfo) Method

Determines whether the Alt+B (backward word) Emacs shortcut was pressed.

public static bool IsBackwardWord(this System.ConsoleKeyInfo keyinfo);

Parameters

keyinfo System.ConsoleKeyInfo

The System.ConsoleKeyInfo to evaluate.

Returns

System.Boolean
true if Alt+B was pressed; otherwise, false.

ConsoleKeyInfoExtensions.IsCapitalizeOverCursor(this ConsoleKeyInfo) Method

Determines whether the Alt+C (capitalize over cursor) Emacs shortcut was pressed.

public static bool IsCapitalizeOverCursor(this System.ConsoleKeyInfo keyinfo);

Parameters

keyinfo System.ConsoleKeyInfo

The System.ConsoleKeyInfo to evaluate.

Returns

System.Boolean
true if Alt+C was pressed; otherwise, false.

ConsoleKeyInfoExtensions.IsClearAfterCursor(this ConsoleKeyInfo) Method

Determines whether the Control+K (clear after cursor) Emacs shortcut was pressed.

public static bool IsClearAfterCursor(this System.ConsoleKeyInfo keyinfo);

Parameters

keyinfo System.ConsoleKeyInfo

The System.ConsoleKeyInfo to evaluate.

Returns

System.Boolean
true if Control+K was pressed; otherwise, false.

ConsoleKeyInfoExtensions.IsClearBeforeCursor(this ConsoleKeyInfo) Method

Determines whether the Control+U (clear before cursor) Emacs shortcut was pressed.

public static bool IsClearBeforeCursor(this System.ConsoleKeyInfo keyinfo);

Parameters

keyinfo System.ConsoleKeyInfo

The System.ConsoleKeyInfo to evaluate.

Returns

System.Boolean
true if Control+U was pressed; otherwise, false.

ConsoleKeyInfoExtensions.IsClearContent(this ConsoleKeyInfo) Method

Determines whether the Control+L (clear content) Emacs shortcut was pressed.

public static bool IsClearContent(this System.ConsoleKeyInfo keyinfo);

Parameters

keyinfo System.ConsoleKeyInfo

The System.ConsoleKeyInfo to evaluate.

Returns

System.Boolean
true if Control+L was pressed; otherwise, false.

ConsoleKeyInfoExtensions.IsClearWordAfterCursor(this ConsoleKeyInfo) Method

Determines whether the Control+D (clear word after cursor) Emacs shortcut was pressed.

public static bool IsClearWordAfterCursor(this System.ConsoleKeyInfo keyinfo);

Parameters

keyinfo System.ConsoleKeyInfo

The System.ConsoleKeyInfo to evaluate.

Returns

System.Boolean
true if Control+D was pressed; otherwise, false.

ConsoleKeyInfoExtensions.IsClearWordBeforeCursor(this ConsoleKeyInfo) Method

Determines whether the Control+W (clear word before cursor) Emacs shortcut was pressed.

public static bool IsClearWordBeforeCursor(this System.ConsoleKeyInfo keyinfo);

Parameters

keyinfo System.ConsoleKeyInfo

The System.ConsoleKeyInfo to evaluate.

Returns

System.Boolean
true if Control+W was pressed; otherwise, false.

ConsoleKeyInfoExtensions.IsForwardWord(this ConsoleKeyInfo) Method

Determines whether the Alt+F (forward word) Emacs shortcut was pressed.

public static bool IsForwardWord(this System.ConsoleKeyInfo keyinfo);

Parameters

keyinfo System.ConsoleKeyInfo

The System.ConsoleKeyInfo to evaluate.

Returns

System.Boolean
true if Alt+F was pressed; otherwise, false.

ConsoleKeyInfoExtensions.IsLowersCurrentWord(this ConsoleKeyInfo) Method

Determines whether the Alt+L (lower-case word) Emacs shortcut was pressed.

public static bool IsLowersCurrentWord(this System.ConsoleKeyInfo keyinfo);

Parameters

keyinfo System.ConsoleKeyInfo

The System.ConsoleKeyInfo to evaluate.

Returns

System.Boolean
true if Alt+L was pressed; otherwise, false.

ConsoleKeyInfoExtensions.IsPressAltSpaceKey(this ConsoleKeyInfo) Method

Determines whether Alt+Spacebar was pressed.

public static bool IsPressAltSpaceKey(this System.ConsoleKeyInfo keyinfo);

Parameters

keyinfo System.ConsoleKeyInfo

The System.ConsoleKeyInfo to evaluate.

Returns

System.Boolean
true if Alt+Spacebar was pressed; otherwise, false.

ConsoleKeyInfoExtensions.IsPressAltTabKey(this ConsoleKeyInfo) Method

Determines whether the Alt+Tab key was pressed.

public static bool IsPressAltTabKey(this System.ConsoleKeyInfo keyinfo);

Parameters

keyinfo System.ConsoleKeyInfo

The System.ConsoleKeyInfo to evaluate.

Returns

System.Boolean
true if Alt+Tab was pressed; otherwise, false.

ConsoleKeyInfoExtensions.IsPressBackspaceKey(this ConsoleKeyInfo, bool) Method

Determines whether Backspace or (optionally) Control+H (Emacs delete previous character) was pressed.

public static bool IsPressBackspaceKey(this System.ConsoleKeyInfo keyinfo, bool emacskeys=true);

Parameters

keyinfo System.ConsoleKeyInfo

The System.ConsoleKeyInfo to evaluate.

emacskeys System.Boolean

If true, also accepts Control+H.

Returns

System.Boolean
true if Backspace (or Emacs equivalent) was pressed; otherwise, false.

ConsoleKeyInfoExtensions.IsPressCollapseKey(this ConsoleKeyInfo) Method

Determines whether the key represents a "collapse" action for tree controls.

public static bool IsPressCollapseKey(this System.ConsoleKeyInfo keyinfo);

Parameters

keyinfo System.ConsoleKeyInfo

The System.ConsoleKeyInfo to evaluate.

Returns

System.Boolean
true for Numpad Minus or '-' character; otherwise, false.

ConsoleKeyInfoExtensions.IsPressCtrlAltSpaceKey(this ConsoleKeyInfo) Method

Determines whether Control+Alt+Spacebar was pressed.

public static bool IsPressCtrlAltSpaceKey(this System.ConsoleKeyInfo keyinfo);

Parameters

keyinfo System.ConsoleKeyInfo

The System.ConsoleKeyInfo to evaluate.

Returns

System.Boolean
true if Control+Alt+Spacebar was pressed; otherwise, false.

ConsoleKeyInfoExtensions.IsPressCtrlAltTabKey(this ConsoleKeyInfo) Method

Determines whether the Ctrl+Alt+Tab key was pressed.

public static bool IsPressCtrlAltTabKey(this System.ConsoleKeyInfo keyinfo);

Parameters

keyinfo System.ConsoleKeyInfo

The System.ConsoleKeyInfo to evaluate.

Returns

System.Boolean
true if Ctrl+Alt+Tab was pressed; otherwise, false.

ConsoleKeyInfoExtensions.IsPressCtrlDeleteKey(this ConsoleKeyInfo) Method

Determines whether Control+Delete (clear word after cursor) was pressed.

public static bool IsPressCtrlDeleteKey(this System.ConsoleKeyInfo keyinfo);

Parameters

keyinfo System.ConsoleKeyInfo

The System.ConsoleKeyInfo to evaluate.

Returns

System.Boolean
true if Control+Delete was pressed; otherwise, false.

ConsoleKeyInfoExtensions.IsPressCtrlEndKey(this ConsoleKeyInfo) Method

Determines whether Control+End was pressed.

public static bool IsPressCtrlEndKey(this System.ConsoleKeyInfo keyinfo);

Parameters

keyinfo System.ConsoleKeyInfo

The System.ConsoleKeyInfo to evaluate.

Returns

System.Boolean
true if Control+End was pressed; otherwise, false.

ConsoleKeyInfoExtensions.IsPressCtrlHomeKey(this ConsoleKeyInfo) Method

Determines whether Control+Home was pressed.

public static bool IsPressCtrlHomeKey(this System.ConsoleKeyInfo keyinfo);

Parameters

keyinfo System.ConsoleKeyInfo

The System.ConsoleKeyInfo to evaluate.

Returns

System.Boolean
true if Control+Home was pressed; otherwise, false.

ConsoleKeyInfoExtensions.IsPressCtrlSpaceKey(this ConsoleKeyInfo) Method

Determines whether Control+Spacebar was pressed.

public static bool IsPressCtrlSpaceKey(this System.ConsoleKeyInfo keyinfo);

Parameters

keyinfo System.ConsoleKeyInfo

The System.ConsoleKeyInfo to evaluate.

Returns

System.Boolean
true if Control+Spacebar was pressed; otherwise, false.

ConsoleKeyInfoExtensions.IsPressCtrlTabKey(this ConsoleKeyInfo) Method

Determines whether the Ctrl+Tab key was pressed.

public static bool IsPressCtrlTabKey(this System.ConsoleKeyInfo keyinfo);

Parameters

keyinfo System.ConsoleKeyInfo

The System.ConsoleKeyInfo to evaluate.

Returns

System.Boolean
true if Ctrl+Tab was pressed; otherwise, false.

ConsoleKeyInfoExtensions.IsPressDeleteKey(this ConsoleKeyInfo, bool) Method

Determines whether Delete or (optionally) Control+D (Emacs delete forward) was pressed.

public static bool IsPressDeleteKey(this System.ConsoleKeyInfo keyinfo, bool emacskeys=true);

Parameters

keyinfo System.ConsoleKeyInfo

The System.ConsoleKeyInfo to evaluate.

emacskeys System.Boolean

If true, also accepts Control+D.

Returns

System.Boolean
true if Delete (or Emacs equivalent) was pressed; otherwise, false.

ConsoleKeyInfoExtensions.IsPressDownArrowKey(this ConsoleKeyInfo, bool) Method

Determines whether DownArrow or (optionally) Control+N (Emacs next line/history) was pressed.

public static bool IsPressDownArrowKey(this System.ConsoleKeyInfo keyinfo, bool emacskeys=true);

Parameters

keyinfo System.ConsoleKeyInfo

The System.ConsoleKeyInfo to evaluate.

emacskeys System.Boolean

If true, also accepts Control+N.

Returns

System.Boolean
true if DownArrow (or Emacs equivalent) was pressed; otherwise, false.

ConsoleKeyInfoExtensions.IsPressEndKey(this ConsoleKeyInfo, bool) Method

Determines whether End or (optionally) Control+E (Emacs end-of-line) was pressed.

public static bool IsPressEndKey(this System.ConsoleKeyInfo keyinfo, bool emacskeys=true);

Parameters

keyinfo System.ConsoleKeyInfo

The System.ConsoleKeyInfo to evaluate.

emacskeys System.Boolean

If true, also accepts Control+E.

Returns

System.Boolean
true if End (or Emacs equivalent) was pressed; otherwise, false.

ConsoleKeyInfoExtensions.IsPressEnterKey(this ConsoleKeyInfo, bool) Method

Determines whether the pressed key represents an Enter action.

public static bool IsPressEnterKey(this System.ConsoleKeyInfo keyinfo, bool emacskeys=true);

Parameters

keyinfo System.ConsoleKeyInfo

The System.ConsoleKeyInfo to evaluate.

emacskeys System.Boolean

If true, also accepts Control+J as Enter (Emacs style).

Returns

System.Boolean
true if Enter (or accepted Emacs equivalent) was pressed; otherwise, false.

Remarks

On non-Windows platforms both CR (13) and LF (10) may be emitted. This method normalizes those cases.

ConsoleKeyInfoExtensions.IsPressEscKey(this ConsoleKeyInfo) Method

Determines whether Escape (without modifiers) was pressed.

public static bool IsPressEscKey(this System.ConsoleKeyInfo keyinfo);

Parameters

keyinfo System.ConsoleKeyInfo

The System.ConsoleKeyInfo to evaluate.

Returns

System.Boolean
true if Escape was pressed; otherwise, false.

ConsoleKeyInfoExtensions.IsPressExpandKey(this ConsoleKeyInfo) Method

Determines whether the key represents an "expand" action for tree controls.

public static bool IsPressExpandKey(this System.ConsoleKeyInfo keyinfo);

Parameters

keyinfo System.ConsoleKeyInfo

The System.ConsoleKeyInfo to evaluate.

Returns

System.Boolean
true for Numpad Plus or '+' character; otherwise, false.

ConsoleKeyInfoExtensions.IsPressFilterActivationKey(this ConsoleKeyInfo) Method

Determines whether the cross-terminal filter activation key was pressed.

public static bool IsPressFilterActivationKey(this System.ConsoleKeyInfo keyinfo);

Parameters

keyinfo System.ConsoleKeyInfo

The System.ConsoleKeyInfo to evaluate.

Returns

System.Boolean
true for Ctrl+Alt+Spacebar (primary) or Ctrl+Spacebar (fallback for terminals that do not report Ctrl+Alt+Spacebar consistently); otherwise, false.

ConsoleKeyInfoExtensions.IsPressHomeKey(this ConsoleKeyInfo, bool) Method

Determines whether Home or (optionally) Control+A (Emacs beginning-of-line) was pressed.

public static bool IsPressHomeKey(this System.ConsoleKeyInfo keyinfo, bool emacskeys=true);

Parameters

keyinfo System.ConsoleKeyInfo

The System.ConsoleKeyInfo to evaluate.

emacskeys System.Boolean

If true, also accepts Control+A.

Returns

System.Boolean
true if Home (or Emacs equivalent) was pressed; otherwise, false.

ConsoleKeyInfoExtensions.IsPressLeftArrowKey(this ConsoleKeyInfo, bool) Method

Determines whether LeftArrow or (optionally) Control+B (Emacs move backward) was pressed.

public static bool IsPressLeftArrowKey(this System.ConsoleKeyInfo keyinfo, bool emacskeys=true);

Parameters

keyinfo System.ConsoleKeyInfo

The System.ConsoleKeyInfo to evaluate.

emacskeys System.Boolean

If true, also accepts Control+B.

Returns

System.Boolean
true if LeftArrow (or Emacs equivalent) was pressed; otherwise, false.

ConsoleKeyInfoExtensions.IsPressPageDownKey(this ConsoleKeyInfo, bool) Method

Determines whether PageDown or (optionally) Alt+N (Emacs next extended navigation) was pressed.

public static bool IsPressPageDownKey(this System.ConsoleKeyInfo keyinfo, bool emacskeys=true);

Parameters

keyinfo System.ConsoleKeyInfo

The System.ConsoleKeyInfo to evaluate.

emacskeys System.Boolean

If true, also accepts Alt+N.

Returns

System.Boolean
true if PageDown (or Emacs equivalent) was pressed; otherwise, false.

ConsoleKeyInfoExtensions.IsPressPageUpKey(this ConsoleKeyInfo, bool) Method

Determines whether PageUp or (optionally) Alt+P (Emacs previous extended navigation) was pressed.

public static bool IsPressPageUpKey(this System.ConsoleKeyInfo keyinfo, bool emacskeys=true);

Parameters

keyinfo System.ConsoleKeyInfo

The System.ConsoleKeyInfo to evaluate.

emacskeys System.Boolean

If true, also accepts Alt+P.

Returns

System.Boolean
true if PageUp (or Emacs equivalent) was pressed; otherwise, false.

ConsoleKeyInfoExtensions.IsPressRightArrowKey(this ConsoleKeyInfo, bool) Method

Determines whether RightArrow or (optionally) Control+F (Emacs move forward) was pressed.

public static bool IsPressRightArrowKey(this System.ConsoleKeyInfo keyinfo, bool emacskeys=true);

Parameters

keyinfo System.ConsoleKeyInfo

The System.ConsoleKeyInfo to evaluate.

emacskeys System.Boolean

If true, also accepts Control+F.

Returns

System.Boolean
true if RightArrow (or Emacs equivalent) was pressed; otherwise, false.

ConsoleKeyInfoExtensions.IsPressShiftTabKey(this ConsoleKeyInfo) Method

Determines whether Shift+Tab was pressed.

public static bool IsPressShiftTabKey(this System.ConsoleKeyInfo keyinfo);

Parameters

keyinfo System.ConsoleKeyInfo

The System.ConsoleKeyInfo to evaluate.

Returns

System.Boolean
true if Shift+Tab was pressed; otherwise, false.

ConsoleKeyInfoExtensions.IsPressSpaceKey(this ConsoleKeyInfo) Method

Determines whether Spacebar (without modifiers) was pressed.

public static bool IsPressSpaceKey(this System.ConsoleKeyInfo keyinfo);

Parameters

keyinfo System.ConsoleKeyInfo

The System.ConsoleKeyInfo to evaluate.

Returns

System.Boolean
true if Spacebar was pressed; otherwise, false.

ConsoleKeyInfoExtensions.IsPressSpecialKey(this ConsoleKeyInfo, ConsoleKey, ConsoleModifiers) Method

Determines whether the pressed key matches the specified key and modifier.

public static bool IsPressSpecialKey(this System.ConsoleKeyInfo keyinfo, System.ConsoleKey key, System.ConsoleModifiers modifier);

Parameters

keyinfo System.ConsoleKeyInfo

The System.ConsoleKeyInfo to evaluate.

key System.ConsoleKey

The expected System.ConsoleKey.

modifier System.ConsoleModifiers

The expected System.ConsoleModifiers.

Returns

System.Boolean
true if both key and modifier match; otherwise, false.

ConsoleKeyInfoExtensions.IsPressTabKey(this ConsoleKeyInfo) Method

Determines whether the Tab key (without modifiers) was pressed.

public static bool IsPressTabKey(this System.ConsoleKeyInfo keyinfo);

Parameters

keyinfo System.ConsoleKeyInfo

The System.ConsoleKeyInfo to evaluate.

Returns

System.Boolean
true if Tab was pressed; otherwise, false.

ConsoleKeyInfoExtensions.IsPressUpArrowKey(this ConsoleKeyInfo, bool) Method

Determines whether UpArrow or (optionally) Control+P (Emacs previous line/history) was pressed.

public static bool IsPressUpArrowKey(this System.ConsoleKeyInfo keyinfo, bool emacskeys=true);

Parameters

keyinfo System.ConsoleKeyInfo

The System.ConsoleKeyInfo to evaluate.

emacskeys System.Boolean

If true, also accepts Control+P.

Returns

System.Boolean
true if UpArrow (or Emacs equivalent) was pressed; otherwise, false.

ConsoleKeyInfoExtensions.IsTransposePrevious(this ConsoleKeyInfo) Method

Determines whether the Control+T (transpose previous characters) Emacs shortcut was pressed.

public static bool IsTransposePrevious(this System.ConsoleKeyInfo keyinfo);

Parameters

keyinfo System.ConsoleKeyInfo

The System.ConsoleKeyInfo to evaluate.

Returns

System.Boolean
true if Control+T was pressed; otherwise, false.

ConsoleKeyInfoExtensions.IsUppersCurrentWord(this ConsoleKeyInfo) Method

Determines whether the Alt+U (upper-case word) Emacs shortcut was pressed.

public static bool IsUppersCurrentWord(this System.ConsoleKeyInfo keyinfo);

Parameters

keyinfo System.ConsoleKeyInfo

The System.ConsoleKeyInfo to evaluate.

Returns

System.Boolean
true if Alt+U was pressed; otherwise, false.