diff --git a/composer.json b/composer.json index 8c15c0a7..3cddb176 100644 --- a/composer.json +++ b/composer.json @@ -21,7 +21,7 @@ "require": { "php" : ">=7.1", "beberlei/assert": "^2.4 | ^3", - "php-school/terminal": "dev-master", + "php-school/terminal": "^0.2", "ext-posix": "*" }, "autoload" : { diff --git a/src/CliMenu.php b/src/CliMenu.php index 01cc9f7f..49ec3ee2 100644 --- a/src/CliMenu.php +++ b/src/CliMenu.php @@ -214,7 +214,7 @@ public function disableDefaultControlMappings() : void public function setDefaultControlMappings(array $defaultControlMappings) : void { $this->defaultControlMappings = $defaultControlMappings; - } + } /** * Adds a custom control mapping diff --git a/src/Input/InputIO.php b/src/Input/InputIO.php index 2efb3a18..163f00ca 100644 --- a/src/Input/InputIO.php +++ b/src/Input/InputIO.php @@ -40,6 +40,8 @@ public function collect(Input $input) : InputResult $inputValue = $input->getPlaceholderText(); $havePlaceHolderValue = !empty($inputValue); + + $originalValue = $inputValue; $reader = new NonCanonicalReader($this->terminal); @@ -59,6 +61,9 @@ public function collect(Input $input) : InputResult if ($char->isHandledControl()) { switch ($char->getControl()) { + case InputCharacter::ESC: + $this->parentMenu->redraw(); + return new InputResult($originalValue); case InputCharacter::ENTER: if ($input->validate($inputValue)) { $this->parentMenu->redraw();