From b54221ed38db292968bb5e2d1fb87c3ad755358c Mon Sep 17 00:00:00 2001 From: Timothy J Warren Date: Thu, 5 Dec 2019 11:05:07 -0500 Subject: [PATCH] Simplify more escape sequences --- src/Editor.php | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/src/Editor.php b/src/Editor.php index 9836d79..576bc3f 100644 --- a/src/Editor.php +++ b/src/Editor.php @@ -99,29 +99,29 @@ class Editor { case "\r": return Key::ENTER; - case "\x1b[A": return Key::ARROW_UP; - case "\x1b[B": return Key::ARROW_DOWN; - case "\x1b[C": return Key::ARROW_RIGHT; - case "\x1b[D": return Key::ARROW_LEFT; + case "\e[A": return Key::ARROW_UP; + case "\e[B": return Key::ARROW_DOWN; + case "\e[C": return Key::ARROW_RIGHT; + case "\e[D": return Key::ARROW_LEFT; - case "\x1b[3~": return Key::DEL_KEY; + case "\e[3~": return Key::DEL_KEY; - case "\x1b[5~": return Key::PAGE_UP; - case "\x1b[6~": return Key::PAGE_DOWN; + case "\e[5~": return Key::PAGE_UP; + case "\e[6~": return Key::PAGE_DOWN; - case "\x1bOH": - case "\x1b[1~": - case "\x1b[7~": + case "\eOH": + case "\e[1~": + case "\e[7~": case ANSI::RESET_CURSOR: return Key::HOME_KEY; - case "\x1bOF": - case "\x1b[4~": - case "\x1b[8~": - case "\x1b[F": + case "\eOF": + case "\e[4~": + case "\e[8~": + case "\e[F": return Key::END_KEY; - case "\x1b": + case "\e": return Key::ESCAPE; default: return $c; @@ -428,7 +428,7 @@ class Editor { $savedHl = []; } - if ($key === "\r" || $key === "\x1b") + if ($key === "\r" || $key === "\e") { $lastMatch = -1; $direction = 1;