Hi
On 2026-11-20 13:26, Pratik Bhujel wrote:
I’ve updated the Io\Terminal RFC to v0.7:
https://wiki.php.net/rfc/io_terminal
I was quite surprised to see the RFC text completely rewritten in 0.7
(https://wiki.php.net/rfc/io_terminal?do=diff&rev2%5B0%5D=1794200215&rev2%5B1%5D=1795177398&difftype=sidebyside).
I have given it another full read:
(1)
Is there always a “unique byte sequence” for every possible key in the
`Key` enum? If so it might be a rare case where making the enum a backed
enum might be warranted to enable cleaner compatibility with the enum
changing, because users could retrieve the original byte sequence from
each enum case to compare it. So something like:
$key = $t->readKey();
again:
if ($key === "\x1b[1;5D") {
// Ctrl+Left
} else if ($key instanceof Key) {
$key = $key->value;
goto again;
}
(2)
Writing out the example also made me realize that there is no explicit
example for `readKey()` returning sequences, or rather no dedicated
example for `readKey()` at all. There only is one for `readLine()` and
multiple terminals being attached to the same “physical terminal”. In
particular it is not clear to me whether the sequence timeout of
`readKey()` is only relevant for the keys in the `Key` enum or if it can
also return strings with length greater than one.
(3)
It is not clear to me why `readLine()` returns `null` on EOF instead of
throwing. This is inconsistent with `readSecret()` as the closest
relative (since it also reads entire lines), and breaks the pattern in
the try-catch example in the “Error Model” section.
(4)
I'm noting that the voting widget does not render properly. That likely
indicates some Wiki syntax error elsewhere in the text.
Best regards
Tim Düsterhus