CLI/readline

* there are still terminals out there sending \r as line terminator...
This commit is contained in:
Sarjuuk
2024-06-07 17:12:44 +02:00
parent fc86825b15
commit 82c04c9ed5

View File

@@ -394,9 +394,9 @@ abstract class CLI
{
$keyId = $ordinals[$idx];
// ignore these ones
if ($keyId == self::CHR_TAB || $keyId == self::CHR_CR)
continue 2;
// skip char if horizontal tab or \r if followed by \n
if ($keyId == self::CHR_TAB || ($keyId == self::CHR_CR && ($ordinals[$i + 1] ?? '') == self::CHR_LF))
continue;
if ($keyId == self::CHR_BACKSPACE)
{
@@ -407,7 +407,8 @@ abstract class CLI
if (!$isHidden && self::$hasReadline)
echo chr(self::CHR_BACK)." ".chr(self::CHR_BACK);
}
else if ($keyId == self::CHR_LF)
// standalone \n or \r
else if ($keyId == self::CHR_LF || $keyId == self::CHR_CR)
{
$fields[$name] = $charBuff;
break 2;