From 824fb4a050996c3cc8768d7bd3a13e931f602fa4 Mon Sep 17 00:00:00 2001 From: thgs Date: Sat, 10 Jun 2023 15:49:19 +0100 Subject: [PATCH] Capture escape key --- src/Xterm/Event/SpecialKeyEvent.php | 1 + src/Xterm/Event/XtermEventFactory.php | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/src/Xterm/Event/SpecialKeyEvent.php b/src/Xterm/Event/SpecialKeyEvent.php index e626a47..f76e73f 100644 --- a/src/Xterm/Event/SpecialKeyEvent.php +++ b/src/Xterm/Event/SpecialKeyEvent.php @@ -6,6 +6,7 @@ class SpecialKeyEvent extends InputEvent { + public const ESC = ''; public const F1 = ''; public const F2 = ''; public const F3 = ''; diff --git a/src/Xterm/Event/XtermEventFactory.php b/src/Xterm/Event/XtermEventFactory.php index 5bf814b..3336238 100644 --- a/src/Xterm/Event/XtermEventFactory.php +++ b/src/Xterm/Event/XtermEventFactory.php @@ -37,11 +37,16 @@ public function createEvent(string $received): ?InputEvent "\x1bOC", "\x8fC", "\eC", "\x1b[C", "\x9bC" => SpecialKeyEvent::create(SpecialKeyEvent::RIGHT, $received), "\x1bOD", "\x8fD", "\eD", "\x1b[D", "\x9bD" => SpecialKeyEvent::create(SpecialKeyEvent::LEFT, $received), + // > escape + // todo: add 8bit if there is one -- not clear yet + "\x1b" => SpecialKeyEvent::create(SpecialKeyEvent::ESC, $received), + // >> MOUSE FOCUS // 7 bit, 8 bit (& repeat) "\x1b[I", "\x9bI", "\x1b[O", "\x9bO" => MouseFocusEvent::create($received), default => match ($received[0]) { + // todo: could $received[2] not be set? "\x1b" => match ($received[2]) { '<' => MouseInputEvent::fromSGR($received), 'M' => MouseInputEvent::fromNormal($received),