The shell remembers what was typed before it

Up walks back through the last eight lines and Down forward again. It exists
only because the keys reach the system now: until A1 and A2 there was nothing to
press Up at, and the line was assembled somewhere the shell could not see.

A RING RATHER THAN A LIST. A ninth line pushes the oldest out by moving where
the ring starts, not by moving any of the lines - so keeping a line costs a copy
of that line and nothing else, however full the history is. Eight is a power of
two, so which slot an entry lives in is an AND. The ISA had the awkward part
already: A and B are a sixteen bit shift register, so one SHR with B empty turns
a slot number into the offset of a 128 byte slot, high byte and low, ready for
DPUW.

A NINTH SLOT HOLDS WHAT WAS BEING TYPED when Up left it, and Down brings it
back. Losing a half written line to a keypress is the sort of small rudeness
that makes a thing unpleasant to use, and it costs one slot to avoid.

An empty line is not kept, and neither is one the same as the line already at the
top. The test proves the second by looking one further back: if a repeated
command were kept twice, the line behind the newest would be the same line
again.

The redraw had to learn to rub out. One space was enough while the only thing
that shortened a line was taking one character out of it; a recalled line
replaces the whole of it, and a short line over a long one left the tail of the
long one on screen looking like part of what you were typing. It now covers
exactly what was lost - which turned out to be one space fewer than before in
the cases that GREW, so two lines of cosmosEditKeys lost a trailing space that
was never doing anything.

Costs 1157 bytes of Data Memory, taking CosmOS to 6220 of the 8192 it has before
a loaded program's data begins. Worth writing down: that is the budget, and this
is the largest single thing in it.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01E2JrLzFvuFX9fgi1LDRjrW
This commit is contained in:
Anachronaut
2026-09-01 12:24:23 -04:00
co-authored by Claude Opus 5
parent 81e544eb3d
commit 71f6e215f9
7 changed files with 409 additions and 9 deletions
+20
View File
@@ -294,6 +294,7 @@ line can be moved about in at all.
| Home, End | Go to the start of the line or the end of it. |
| Backspace | Take out the character before the cursor. |
| Delete | Take out the one under it. |
| Up, Down | Walk back through the last eight lines, and forward again. |
| Return | Finish the line, wherever the cursor happens to be sitting. |
Anything typed goes in where the cursor is, so a word left out of the middle of a line is
@@ -307,6 +308,25 @@ line, and nowhere for a history to live. Now the console delivers keys and says
about what they mean, the same way it reports what a drive is and says nothing about what
should be on it, and the shell decides.
### The History:
The last eight lines are kept, and Up walks back through them. It is a ring: a ninth line
pushes the oldest out by moving where the ring starts rather than by moving any of the
lines.
An empty line is not kept - that is somebody pressing Return - and neither is a line the
same as the one already at the top, so running a command twice does not put it in twice.
**What you were typing is kept too.** Pressing Up when you were half way through a line puts
that line somewhere and Down brings it back, so looking at what you did before does not cost
you what you were doing.
The history belongs to the shell rather than to the console, and that is the whole reason it
can exist: until the keys reached the system there was nothing to press Up at. It is shared
with the monitor, which reads its lines the same way - and since the monitor reads into a
buffer of forty characters where the shell reads into one of 127, a longer line recalled
there is cut short rather than written past the end of it.
The line holds 127 characters. It held 63 until the shell could edit one, which is when the
limit started to be felt: a copy between two disks with a directory on each is most of the
way there before anything has been said.