Allow multi-line editing in REPL
Some languages have multi-line editing using some special symbols to indicate another line is going to follow. Others detect if what is entered is a parseble expression or statement, this could be a pain to implement.
My personal preference goes to Shift+Enter, which is commonly used to go to the next line without submitting when using text-areas.
I'll ask in the chat before implementing.
Is it linked with #2666?
Yes indeed. Having this implemented would be a significant improvement in repl UX.
We use rustyline for generic repl features. This rustyline example adapted for Shift+Enter might be all that's needed. Are you interested in giving that a try @ghigt?
Yes, I tried it before, but while this works
rl.bind_sequence(
KeyEvent(KeyCode::Char('s'), Modifiers::CTRL),
EventHandler::Simple(Cmd::Newline),
);
This is handled by the default Enter behavior:
rl.bind_sequence(
KeyEvent(KeyCode::Enter, Modifiers::SHIFT),
EventHandler::Simple(Cmd::Newline),
);
Oh I see, can you file an issue for that on the rustyline repo?
https://github.com/kkawakam/rustyline/issues/653
Thanks @ghigt!
His response makes sens, do you think about an alternative?
Interesting, Ctrl+s is probably good.
I don't want to enter into a battle π, but I associate Ctrl+s with "save", is there a particular reason that I don't know for the s key?
I would associate a newline with Ctrl+n or Ctrl+o (like in vim mode).
The main thing I like about Ctrl+s is that it is easy to reach single-handedly.
@Anton-4 recommend this be closed as completed. Just using enter on an expression that isn't complete seems to work fine.
% roc repl
The rockinβ roc repl
ββββββββββββββββββββββββ
Enter an expression, or :help, or :q to quit.
Β» greeting : Str
β¦ greeting = "Hi"
"Hi" : Str # greeting
Β»
Thanks for notifying me @lukewilliamboswell :)