Hmm, after thinking about it for a few minutes it occurs to me that BASIC already has an editing environment based on the line numbers support. Here’s one thing that makes it a lot like the Forth/Lua version above:
@@ -10918,8 +10918,11 @@ int main(int argc, char* argv[]) {
/* do what an Arduino would do, this loops for every interactive input */
setup();
- while (1)
+ while (1) {
loop();
+ if (token == EOL) break;
+ xlist();
+ }
}
Now you don’t need to say LIST
anymore. You implicitly see the program as you type.
Not quite the same as my Lua program above, which does a bit more for pagination. But it feels more idiomatic for BASIC.
(The EOL
line isn’t technically for the editor, but a convenience for the Posix version of tinybasic: it lets me quit using ctrl-c or ctrl-d.)