Skip to content

Commit

Permalink
Document CTRL_ constants
Browse files Browse the repository at this point in the history
  • Loading branch information
jessarcher committed Sep 15, 2023
1 parent bdfb130 commit aa36f99
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 2 deletions.
24 changes: 24 additions & 0 deletions src/Key.php
Original file line number Diff line number Diff line change
Expand Up @@ -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";
}
2 changes: 1 addition & 1 deletion src/SearchPrompt.php
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
});
}
Expand Down
2 changes: 1 addition & 1 deletion src/SuggestPrompt.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit aa36f99

Please sign in to comment.