Deliver the keys that are not characters
An arrow key has never reached this machine. Voyager threw it away for want of anywhere to put it, and a terminal sent ESC [ A, which arrived in the middle of whatever was being read and made it unrecognisable - typing Up at the CosmOS prompt put three bytes in the command line and got "I do not know". So the console names them: one byte each, 0x80 upward, above ASCII so nothing written before them can collide. Up, Down, Left, Right, Home, End and forward Delete, with room above for the paging and function keys. The console normalises, which is what it already does. Behind a window it turns the key somebody pressed into a byte; on a terminal it turns the sequence into the same byte. That is the act it has always performed on Return and Backspace, one layer further along, and it is why a program need not know which of the two it is talking to. What a key MEANS is not the console's business - that belongs to whoever is reading, the same way what is on a disk belongs to the system and what a drive is belongs to the machine. Translated only when standard input really is a terminal. Nothing else sends these sequences, a pipe holds exactly the bytes somebody put in it, and it keeps the Escape-or-Up timing problem out of every test here: a test writes the key values themselves. Line mode drops them, in both front ends, because line mode delivers characters and a line somebody else has finished editing cannot be moved about in. Press.sbx says what it was handed, in hexadecimal and by name, and reads a line before it reads keys so both halves of that rule are checked. Two recordings, one fed as standard input and one as a keyboard, agreeing byte for byte; each break fails exactly one of them. Three checks in terminal.sh type real escape sequences at a pseudo-terminal, which is the only place they are ever read as sequences: that they arrive as keys, that Escape alone is still Escape, and that a character typed straight after an escape is held rather than swallowed. Five recordings re-blessed for Press.sbx appearing on the shared disk, and the whole of that diff is the file's own line and the counts above it. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01E2JrLzFvuFX9fgi1LDRjrW
This commit is contained in:
co-authored by
Claude Opus 5
parent
2a29cebc6b
commit
b3726c950a
@@ -294,6 +294,17 @@ cosmosSnake | CosmOS/Source/cosmos.asm | run | cosmosSna
|
||||
# console's slot at FE00 is zero again, and CosmOS's own disk handler further along is
|
||||
# untouched by a program having installed over the top of it.
|
||||
cosmosKeys | CosmOS/Source/cosmos.asm | run | cosmosKeys.in | - | disks/cosmos.img
|
||||
# The keys that are not characters, both halves of the rule in one run: a line read in line
|
||||
# mode with an arrow key in the middle of it, which arrives with the arrow dropped because
|
||||
# line mode delivers characters, and then the same keys in key mode where they are what the
|
||||
# program asked for. Fed as STANDARD INPUT, so the console is reading bytes that are exactly
|
||||
# what is in the file - no terminal is involved and no escape sequence is translated, which
|
||||
# is what makes an arrow key testable at all.
|
||||
cosmosPress | CosmOS/Source/cosmos.asm | run | cosmosPress.in | - | disks/cosmos.img
|
||||
# The same program and the same keys, fed as a KEYBOARD instead. That is the other front
|
||||
# end - the window's path through the gatherer - and it has its own copy of the line mode
|
||||
# rule, so it needs its own test. The two recordings should agree, which is the point.
|
||||
cosmosPressKeys | CosmOS/Source/cosmos.asm | run | - | - | disks/cosmos.img | cosmosPress.in
|
||||
# The shell taking things off a disk and calling them something else, which is the last of
|
||||
# CosmOS's original four verbs to be built and the first time anything has changed a disk
|
||||
# from the shell. Its own image, because it changes what is on it: a fixture named with a
|
||||
|
||||
Reference in New Issue
Block a user