Skip to content
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

Closed
hdgarrood opened this issue Mar 3, 2015 · 7 comments
Closed

Switch between single/multi line mode at runtime #934

hdgarrood opened this issue Mar 3, 2015 · 7 comments
Assignees
Milestone

Comments

@hdgarrood
Copy link
Contributor

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.

@paf31 paf31 added this to the 0.8.0 milestone Mar 3, 2015
@hdgarrood
Copy link
Contributor Author

I think we should copy scala's :paste, which enables multiline mode for the next command only.
So an example interaction could be:

> :paste
-- Entering paste mode. Press Ctrl-D to finish

if true
  then 1
  else 0
^D
-- Exiting paste mode
1
> 1 + 2
3

See http://alvinalexander.com/scala/how-to-enter-paste-multiline-commands-statements-into-scala-repl

@michaelficarra
Copy link
Contributor

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.

@joneshf
Copy link
Member

joneshf commented Mar 16, 2015

Definitely agree on the cs repl!

@hdgarrood
Copy link
Contributor Author

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.

@paf31
Copy link
Contributor

paf31 commented Mar 16, 2015

Sounds good, but I don't know how to handle ^V in haskeline.

While we're at it, adding an interrupt handler for ^C would be nice. I often mistakenly use it to try to kill long running node processes, but it just ends up killing psci instead. Something like node where you have to press ^C twice to quite might be nice, and if evaluation in process, ^C once to cancel it would be nice too.

kimat added a commit to kimat/slimux that referenced this issue May 20, 2015
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)
@nmsmith
Copy link

nmsmith commented Jul 2, 2015

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.

@paf31
Copy link
Contributor

paf31 commented Jul 2, 2015

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.

@paf31 paf31 modified the milestones: 0.9.0, 0.10.0 Apr 10, 2016
@paf31 paf31 modified the milestones: 0.10.0, 1.0.0 Sep 17, 2016
@paf31 paf31 modified the milestones: 1.0, Approved Oct 2, 2016
@paf31 paf31 self-assigned this Oct 2, 2016
@paf31 paf31 closed this as completed in 0072f25 Oct 23, 2016
basile-henry added a commit to basile-henry/repline that referenced this issue Jun 14, 2020
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.
basile-henry added a commit to basile-henry/repline that referenced this issue Jun 16, 2020
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants