Skip to content

Commit

Permalink
Capture escape key
Browse files Browse the repository at this point in the history
  • Loading branch information
thgs committed Jun 10, 2023
1 parent ab4eacb commit 824fb4a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/Xterm/Event/SpecialKeyEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

class SpecialKeyEvent extends InputEvent
{
public const ESC = '<ESC>';
public const F1 = '<F1>';
public const F2 = '<F2>';
public const F3 = '<F3>';
Expand Down
5 changes: 5 additions & 0 deletions src/Xterm/Event/XtermEventFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down

0 comments on commit 824fb4a

Please sign in to comment.