Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 83b867d

Browse files
authored
Allow ESC key to "cancel" editing an input
It will simply return the initial value (empty string or the placeholder text) when the user presses the ESC key, even if the text was modified.
1 parent 33ac5c0 commit 83b867d

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

‎src/Input/InputIO.php‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ public function collect(Input $input) : InputResult
4040

4141
$inputValue = $input->getPlaceholderText();
4242
$havePlaceHolderValue = !empty($inputValue);
43+
44+
$originalValue = $inputValue;
4345

4446
$reader = new NonCanonicalReader($this->terminal);
4547

@@ -59,6 +61,9 @@ public function collect(Input $input) : InputResult
5961

6062
if ($char->isHandledControl()) {
6163
switch ($char->getControl()) {
64+
case InputCharacter::ESC:
65+
$this->parentMenu->redraw();
66+
return new InputResult($originalValue);
6267
case InputCharacter::ENTER:
6368
if ($input->validate($inputValue)) {
6469
$this->parentMenu->redraw();

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /