Simplify more escape sequences
All checks were successful
Gitea - Tutorials/php-kilo/master This commit looks good

This commit is contained in:
Timothy Warren 2019-12-05 11:05:07 -05:00
parent d095b82a3c
commit b54221ed38

View File

@ -99,29 +99,29 @@ class Editor {
case "\r": return Key::ENTER; case "\r": return Key::ENTER;
case "\x1b[A": return Key::ARROW_UP; case "\e[A": return Key::ARROW_UP;
case "\x1b[B": return Key::ARROW_DOWN; case "\e[B": return Key::ARROW_DOWN;
case "\x1b[C": return Key::ARROW_RIGHT; case "\e[C": return Key::ARROW_RIGHT;
case "\x1b[D": return Key::ARROW_LEFT; 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 "\e[5~": return Key::PAGE_UP;
case "\x1b[6~": return Key::PAGE_DOWN; case "\e[6~": return Key::PAGE_DOWN;
case "\x1bOH": case "\eOH":
case "\x1b[1~": case "\e[1~":
case "\x1b[7~": case "\e[7~":
case ANSI::RESET_CURSOR: case ANSI::RESET_CURSOR:
return Key::HOME_KEY; return Key::HOME_KEY;
case "\x1bOF": case "\eOF":
case "\x1b[4~": case "\e[4~":
case "\x1b[8~": case "\e[8~":
case "\x1b[F": case "\e[F":
return Key::END_KEY; return Key::END_KEY;
case "\x1b": case "\e":
return Key::ESCAPE; return Key::ESCAPE;
default: return $c; default: return $c;
@ -428,7 +428,7 @@ class Editor {
$savedHl = []; $savedHl = [];
} }
if ($key === "\r" || $key === "\x1b") if ($key === "\r" || $key === "\e")
{ {
$lastMatch = -1; $lastMatch = -1;
$direction = 1; $direction = 1;