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

Allow multi-line editing in REPL #718

Closed
Anton-4 opened this issue Nov 21, 2020 · 13 comments
Closed

Allow multi-line editing in REPL #718

Anton-4 opened this issue Nov 21, 2020 · 13 comments
Assignees

Comments

@Anton-4
Copy link
Collaborator

Anton-4 commented Nov 21, 2020

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.

@Anton-4 Anton-4 self-assigned this Nov 21, 2020
@ghigt
Copy link
Contributor

ghigt commented Oct 3, 2022

Is it linked with #2666?

@Anton-4
Copy link
Collaborator Author

Anton-4 commented Oct 3, 2022

Yes indeed. Having this implemented would be a significant improvement in repl UX.

@Anton-4
Copy link
Collaborator Author

Anton-4 commented Oct 3, 2022

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?

@ghigt
Copy link
Contributor

ghigt commented Oct 3, 2022

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),
);

@Anton-4
Copy link
Collaborator Author

Anton-4 commented Oct 3, 2022

Oh I see, can you file an issue for that on the rustyline repo?

@ghigt
Copy link
Contributor

ghigt commented Oct 3, 2022

kkawakam/rustyline#653

@Anton-4
Copy link
Collaborator Author

Anton-4 commented Oct 3, 2022

Thanks @ghigt!

@ghigt
Copy link
Contributor

ghigt commented Oct 3, 2022

His response makes sens, do you think about an alternative?

@Anton-4
Copy link
Collaborator Author

Anton-4 commented Oct 3, 2022

Interesting, Ctrl+s is probably good.

@ghigt
Copy link
Contributor

ghigt commented Oct 3, 2022

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).

@Anton-4
Copy link
Collaborator Author

Anton-4 commented Oct 4, 2022

The main thing I like about Ctrl+s is that it is easy to reach single-handedly.

@lukewilliamboswell
Copy link
Collaborator

@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

» 

@Anton-4
Copy link
Collaborator Author

Anton-4 commented Dec 16, 2022

Thanks for notifying me @lukewilliamboswell :)

@Anton-4 Anton-4 closed this as completed Dec 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants