@Ginkgo suggested:
I’d like to suggest a feature: the possibility to call up at least just the last line typed into the local REPL with a single keystroke.
Here’s an initial attempt to implement this:
-
Change the line:
volatile int WritePtr = 0, ReadPtr = 0;
to:
volatile int WritePtr = 0, ReadPtr = 0, LastWritePtr = 0;
-
Change:
// Edit buffer
if (c == '\n' || c == '\r') {
pserial('\n');
KybdAvailable = 1;
ReadPtr = 0;
return;
}
if (c == 8 || c == 0x7f) { // Backspace key
if (WritePtr > 0) {
WritePtr--;
Serial.write(8); Serial.write(' '); Serial.write(8);
if (WritePtr) c = KybdBuf[WritePtr-1];
}
} else if (WritePtr < KybdBufSize) {
KybdBuf[WritePtr++] = c;
Serial.write(c);
}
to:
// Edit buffer
if (c == '\n' || c == '\r') {
pserial('\n');
KybdAvailable = 1;
ReadPtr = 0; LastWritePtr = WritePtr;
return;
}
if (c == 8 || c == 0x7f) { // Backspace key
if (WritePtr > 0) {
WritePtr--;
Serial.write(8); Serial.write(' '); Serial.write(8);
if (WritePtr) c = KybdBuf[WritePtr-1];
}
} else if (c == 9) { // tab or ctrl-I
for (int i = 0; i < LastWritePtr; i++) Serial.write(KybdBuf[i]);
WritePtr = LastWritePtr;
} else if (WritePtr < KybdBufSize) {
KybdBuf[WritePtr++] = c;
Serial.write(c);
}
Note: It assumes you have this enabled:
#define lineeditor
Now, pressing the Tab key will echo the previous line typed after the uLisp prompt, and allow you to edit it.
If you think this would be a useful feature I’ll incorporate it into the standard releases.