I think this is because the terminal thinks of itself as a two-dimensional thing. Once the line wraps, you don’t have easy access to backing up. You’ll probably also run into an issue trying to backspace across a line break - at least I see that issue in tio. A number of free software Common Lisp implementations depend on being wrapped with GNU readline to handle the terminal when not being invoked through emacs because of this and related issues.
Thanks! I tried to implement it with the ANSI cursor-position ESC codes. Perhaps it would work better if I simply deleted back along the line, printed the highlighted bracket, and then redrew the characters from the buffer.
I think what’s needed is to keep track of the cursor position at the prompt and print the whole buffer on each refresh. Terminals are, despite how it looks to us, not line-based at all. That’s most likely why the Arduino serial monitor is as limited as it is.
Has anyone tried the new line editing and parenthesis matching features in the ARM 3.2 beta of uLisp? If the parenthesis matching can’t be fixed to work smoothly with typical terminals I’d be inclined to remove this feature.
I’ve had them enabled for the most part, and it makes a world of difference in a straight-up serial terminal. (tio, as mentioned above.) The issues with going past a line wrap are, perhaps surprisingly, not actually uncommon. I’d prefer mentioning the line handling as a known issue to removing the feature. Most folks using a terminal emulator will have seen these issues before, I think.
I do notice one additional issue, which is that if the parenthesis is immediately closed, the highlighter seems to get confused and creates a phantom paren. This also throws off further calculation, such that e.g.
(let ((x '())) x) becomes rather a mess.
In the function Highlight() change:
if (p>2) esc(p-2, 'C');
New beta version of ARM uLisp with new features for feedback
That was quick!
For Version 3.2 I’ve managed to get parenthesis matching working over multiple lines on VT-100 compatible terminal emulators, such as Mac screen:
I look forward to hearing how well it works on other terminals.