diff --git a/src/Key.php b/src/Key.php index af8aad53..7869fa5e 100644 --- a/src/Key.php +++ b/src/Key.php @@ -36,19 +36,43 @@ class Key const END = "\e[4~"; + /** + * Cancel/SIGINT + */ const CTRL_C = "\x03"; + /** + * Previous/Up + */ const CTRL_P = "\x10"; + /** + * Next/Down + */ const CTRL_N = "\x0E"; + /** + * Forward/Right + */ const CTRL_F = "\x06"; + /** + * Back/Left + */ const CTRL_B = "\x02"; + /** + * Backspace + */ const CTRL_H = "\x08"; + /** + * Home + */ const CTRL_A = "\x01"; + /** + * End + */ const CTRL_E = "\x05"; } diff --git a/src/SearchPrompt.php b/src/SearchPrompt.php index 9ecef48a..d5cdf2bd 100644 --- a/src/SearchPrompt.php +++ b/src/SearchPrompt.php @@ -48,7 +48,7 @@ public function __construct( Key::UP, Key::UP_ARROW, Key::SHIFT_TAB, Key::CTRL_P => $this->highlightPrevious(), Key::DOWN, Key::DOWN_ARROW, Key::TAB, Key::CTRL_N => $this->highlightNext(), Key::ENTER => $this->highlighted !== null ? $this->submit() : $this->search(), - Key::LEFT, Key::LEFT_ARROW, Key::RIGHT, Key::RIGHT_ARROW, Key::CTRL_B, Key::CTRL_F, Key::HOME, KEY::END, Key::CTRL_A, Key::CTRL_E => $this->highlighted = null, + Key::LEFT, Key::LEFT_ARROW, Key::RIGHT, Key::RIGHT_ARROW, Key::CTRL_B, Key::CTRL_F, Key::HOME, Key::END, Key::CTRL_A, Key::CTRL_E => $this->highlighted = null, default => $this->search(), }); } diff --git a/src/SuggestPrompt.php b/src/SuggestPrompt.php index 9ae71094..6ffbc0e9 100644 --- a/src/SuggestPrompt.php +++ b/src/SuggestPrompt.php @@ -58,7 +58,7 @@ public function __construct( Key::UP, Key::UP_ARROW, Key::SHIFT_TAB, Key::CTRL_P => $this->highlightPrevious(), Key::DOWN, Key::DOWN_ARROW, Key::TAB, Key::CTRL_N => $this->highlightNext(), Key::ENTER => $this->selectHighlighted(), - Key::LEFT, Key::LEFT_ARROW, Key::RIGHT, Key::RIGHT_ARROW, Key::CTRL_B, Key::CTRL_F, Key::HOME, KEY::END, Key::CTRL_A, Key::CTRL_E => $this->highlighted = null, + Key::LEFT, Key::LEFT_ARROW, Key::RIGHT, Key::RIGHT_ARROW, Key::CTRL_B, Key::CTRL_F, Key::HOME, Key::END, Key::CTRL_A, Key::CTRL_E => $this->highlighted = null, default => (function () { $this->highlighted = null; $this->matches = null;