BASIC editor: Right copies one character, End the rest, Up recalls
After a bare line number, Right copies that program line one character at a time and End copies the rest; Delete skips a character of it. Up brings back the last line entered, cursor at the end. The last line is kept in a 256-byte buffer taken from the end of the program arena, so programs still start at 8482h and have about 20.3 KB. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
eb72d85834
commit
b629cbec00
7 files changed
+2033
-1978
No files matched your search
+22
-8
@@ -14,7 +14,8 @@ HERE = os.path.dirname(os.path.abspath(__file__))
|
||||
sys.path.insert(0, os.path.join(HERE, "..", "tools"))
|
||||
from boardemu import Board # noqa: E402
|
||||
|
||||
RIGHT, LEFT, HOME, END, DEL = b"\x1b[C", b"\x1b[D", b"\x1b[1~", b"\x1b[4~", b"\x1b[3~"
|
||||
RIGHT, LEFT, UP = b"\x1b[C", b"\x1b[D", b"\x1b[A"
|
||||
HOME, END, DEL = b"\x1b[1~", b"\x1b[4~", b"\x1b[3~"
|
||||
BS, CTRL_U, CR = b"\x7f", b"\x15", b"\r"
|
||||
|
||||
|
||||
@@ -69,9 +70,15 @@ def main():
|
||||
|
||||
b.type(b"")
|
||||
b.type(b'10 PRINT "HELLO"' + CR + b"20 GOTO 10" + CR)
|
||||
b.type(b"PRINT PEEK(33923)" + CR) # line 10's number, low byte
|
||||
check("the program still starts at 8482h", lines().rstrip().endswith(" 10\n\nREADY"))
|
||||
y = cur()[0]
|
||||
b.type(b"10" + RIGHT)
|
||||
check("right after 10 brings line 10 in", row(y) == '10 PRINT "HELLO"' and cur() == (y, 16))
|
||||
check("right after 10 copies one character of line 10", row(y) == "10" and cur() == (y, 3))
|
||||
b.type(RIGHT * 2)
|
||||
check("each right copies one more", row(y) == "10 PR" and cur() == (y, 5))
|
||||
b.type(END)
|
||||
check("End copies the rest", row(y) == '10 PRINT "HELLO"' and cur() == (y, 16))
|
||||
b.type(LEFT * 6) # cursor onto the H
|
||||
check("left moves the cursor back", cur() == (y, 10))
|
||||
b.type(b"BIG ")
|
||||
@@ -84,20 +91,24 @@ def main():
|
||||
lst = lines()
|
||||
check("the edited line is stored", '10 PRINT "BIG HELLO!"\n20 GOTO 10' in lst)
|
||||
|
||||
b.type(b"99" + RIGHT)
|
||||
b.type(UP)
|
||||
y = cur()[0]
|
||||
check("right after a missing line number does nothing", row(y) == "99" and cur() == (y, 2))
|
||||
check("up brings back the last line, cursor at the end", row(y) == "LIST" and cur() == (y, 4))
|
||||
b.type(CTRL_U)
|
||||
check("Ctrl-U clears the line", row(y) == "" and cur() == (y, 0))
|
||||
b.type(b"20" + RIGHT + HOME + DEL * 2 + b"30" + CR)
|
||||
b.type(b"99" + RIGHT)
|
||||
check("right after a missing line number does nothing", row(y) == "99" and cur() == (y, 2))
|
||||
b.type(CTRL_U + b"20" + RIGHT * 6 + DEL * 2 + b"30" + CR)
|
||||
b.type(b"LIST" + CR)
|
||||
lst = lines()
|
||||
check("a recalled line can be stored as a copy", "20 GOTO 10\n30 GOTO 10" in lst)
|
||||
lst = lines().split("LIST")[-1]
|
||||
check("Delete skips old characters while copying", "20 GOTO 30" in lst and "20 GOTO 10" not in lst)
|
||||
b.type(b"20" + END + HOME + DEL * 2 + b"40" + CR + b"LIST" + CR)
|
||||
check("a copied line can be stored under a new number", "20 GOTO 30\n40 GOTO 30" in lines())
|
||||
|
||||
# a line that wraps onto three screen rows
|
||||
text = "REM " + "".join(chr(65 + i % 26) for i in range(170))
|
||||
b.type(b"40 " + text.encode() + CR)
|
||||
b.type(b"40" + RIGHT)
|
||||
b.type(b"40" + END)
|
||||
y, x = cur()
|
||||
full = "40 " + text
|
||||
y0 = y - (len(full) // 80)
|
||||
@@ -113,6 +124,9 @@ def main():
|
||||
check("inserting and deleting across rows redraws them", shown.rstrip() == full and cur() == (y0, 79))
|
||||
b.type(CR + b"LIST 40" + CR)
|
||||
check("the long line is stored", full in "".join(screen().display))
|
||||
b.type(UP + UP)
|
||||
check("up again gives the same last line", lines().rstrip().endswith("LIST 40"))
|
||||
b.type(CTRL_U)
|
||||
|
||||
b.type(b"NEW" + CR + b'INPUT A$: PRINT "GOT ";A$' + CR)
|
||||
b.type(b"ABD" + LEFT + b"C" + CR)
|
||||
|
||||
Reference in new issue
Block a user