New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Switch between single/multi line mode at runtime #934
Comments
I think we should copy scala's
See http://alvinalexander.com/scala/how-to-enter-paste-multiline-commands-statements-into-scala-repl |
The CoffeeScript REPL allows toggling of single-/multi-line mode at any time using Ctrl+v. They are visually distinguished by changing the prompt. Functionally, the only difference between them is that commands are accepted in single-line mode through Return, and multi-line mode through Ctrl+d. This interface works really well, and I enjoy using it much more than psci. Alternatively, node's REPL automatically goes into multi-line mode when the first line entered is a syntax error. This would work for a language where there's no ambiguity between an expression/declaration that has been finished and one that may continue, but even JavaScript does not conform to this, so this ends up being a pretty poor interface. But it's something to consider. |
Definitely agree on the cs repl! |
I didn't know about the CoffeeScript REPL, that does sound better. I just had a play with it and it seems like a command in multi-line mode is terminated with Ctrl-V, not Ctrl-D, though? Ctrl-D seems to exit the REPL. Maybe we could copy CoffeeScript's approach in psci, except use Ctrl-D to terminate a command in multi-line mode instead of Ctrl-V, since psci already uses Ctrl-D to terminate multi line commands. |
Sounds good, but I don't know how to handle While we're at it, adding an interrupt handler for |
To exit the multi-line mode of the coffeescript repl one must press 'C-v' in order to do so, 'C-d' will actualy exit the repl. Here is a comment that mentions this behaviour also purescript/purescript#934 (comment)
This would be really nice to have. In GHCi a semicolon will let you write a multiline statement, but if PureScript isn't going to support that, a keyboard shortcut to switch modes would be a godsend. |
I don't think we want the magic semicolon approach, but I'd be fine with switching modes, if we can make Haskeline do it. |
The way this multi-line input works is very much inspired by the PureScript REPL which also uses `haskeline`: purescript/purescript#934 (comment) The name of the command is configurable, so it could be called `m`, `paste`, `multiline`, or whatever works best for the application using this. The banner can now take into account if it's in the middle of a multi-line input or not.
The way this multi-line input works is very much inspired by the PureScript REPL which also uses `haskeline`: purescript/purescript#934 (comment) The name of the command is configurable, so it could be called `m`, `paste`, `multiline`, or whatever works best for the application using this. The banner can now take into account if it's in the middle of a multi-line input or not.
In psci, it would be nice to switch between the two modes at runtime.
@paf31 prefers something like
:set multiline
to ghci's:{ :}
, and I agree.The text was updated successfully, but these errors were encountered: