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

Make rtop behavior match common consoles. #92

Open
jordwalke opened this issue Feb 12, 2016 · 14 comments
Open

Make rtop behavior match common consoles. #92

jordwalke opened this issue Feb 12, 2016 · 14 comments

Comments

@jordwalke
Copy link
Member

The <CR> behavior should match that of the Chrome console.

  • When hitting cr, it should submit whatever you have (even if it's invalid syntax), while shift+cr should insert a newline (it's not clear this is possible, but it would be awesome). This would match the Chrome REPL and also Slack/Messenger!
  • Pasting multiple lines doesn't seem to work in rtop (at least with iTerm).
  • It would be great if hitting c-c would cancel whatever command you're in the middle of editing, but it would also tell you "hit c-c again to exit". Right now, you have to type exit 0; which is kind of annoying.
  • It would be good to print the errors using BetterErrors.
  • Currently, I believe the REPL will accept any entry if it is a valid parse, when you hit <CR>. That's bad if your cursor is in in the middle of a currently valid parse, but you want to insert a newline anyways (to add a new field etc). For example, your cursor is after x, and you want to hit enter to insert a newline.
let something = {
  field: x
};
  • Note that it may be impossible to distinguish shift+cr from cr in the terminal. However, the main important feature is that there's a way to distinguish between "submit what I have entered" vs. "I want to force a newline in the input". cr to submit, and shift+cr to force a newline would be ideal, but it may not be possible in the terminal. Instead, perhaps we use cr and ctrl+cr instead?

In general, more people know how to use the Chrome REPL (of Slack for that matter) than any other REPL, so let's just match that (or are there any other popular REPLs that you know of that do a really great job?)

@jordwalke
Copy link
Member Author

Another feature that seemed missing:
When autocompletion options are open, there needs to be an intuitive way to accept the currently highlighted completion.

I think most people would appreciate if hitting tab would cycle through the available/currently-refined completion items.

@chenglou chenglou added the Rtop label May 27, 2016
@jimmyhmiller
Copy link

Do you think these are changes that can be made inside the reason project or will they need to go upstream to utop?

@jordwalke
Copy link
Member Author

I think these changes can even be made apart from utop. If they are helpful, and people like them, we can upstream them

@slonoed
Copy link

slonoed commented May 10, 2017

Hi @jordwalke!

Do you think double c-c is right for an exit? When a user have some ping (think about ssh session), he can press keys twice.
I work with clojure and hitting c-c stops session in REPL. Sometimes it is a real pain.
Maybe better to use c-d instead? Like https://github.com/hanslub42/rlwrap do?

@jordwalke
Copy link
Member Author

Doesn't c-d delete forward in most cases (mac and emacs keybindings)? I would be happy with double c-c. I would love an improvement here :D

Thanks for the interest.

@slonoed
Copy link

slonoed commented May 11, 2017

Hi @jordwalke, thank you for response

c-d means EOF in tty. When you hit c-d in bash it leaves a session. Same in tmux, docker (-ti exec), rlwrap, etc. But c-d works as delete forward when symbols ahead.
c-c in unix stays for SIGINT. It interrupts program.

REPL is an interactive shell and better when it behaves the same way as other shells do:

  • when user hit c-c — clear line, put (maybe for rtop isn't necessary)
  • If there are symbols in input line and user hit c-d — try to delete one symbol forward (none if the end of the line).
  • If there are no symbols in input line and user hit c-d — end input session (close rtop).

But for me, the main reason to use c-d instead of c-c is to avoid accidentally exit. Most sadly think working with REPL is to close a session in the middle of the long pipeline.

I'd like to work on this issue, but triple c-c struggle me. Is there a chance to change your mind, or you have complete vision on this feature?

@jordwalke
Copy link
Member Author

I would like to do what most people prefer. Node does not destroy the session on control-d whether or not there are characters "ahead". I can see why that makes sense. Imagine you are deleting many characters ahead and you accidentally delete one too many. That would destroy the session. Whereas with c-c, you either press it zero or one times. Never repeatedly unless you want to end the session. I will run a poll though and see what people would like. Making sure that other people have a good experience is more important to me than what I would like. I'll report the findings.

@slonoed
Copy link

slonoed commented May 11, 2017

I'm not sure nodejs is a good example. People don't spend much time in node repl.

Imagine you are deleting many characters ahead and you accidentally delete one too many
Session won't be cleared in this case, because of symbols behind. And this behavior typical for all common shells (sh, bash, zsh).

When you use c-c it should be pressed 3 times when symbols in line:

  1. clear current input line
  2. prompt exit
  3. real exit

When working over ssh with large ping it can be an issue.

@jordwalke
Copy link
Member Author

Quick poll is tied!

screen shot 2017-05-11 at 11 43 34 pm

You can be the tie breaker if you want to implement it :D

@jordwalke
Copy link
Member Author

I would rather have two c-d though, but as long as I don't have to type out exit 0; I'm happier.
(I do worry about accidentally killing the session though - I hold down c-d to delete many characters in front of the cursor and I fear I'll go over the line and kill the session. Do you have suggestions to avoid that?)

@slonoed
Copy link

slonoed commented May 12, 2017

@jordwalke looks like same problem with accidenal hitting key more time.

About prompt. It can be good way to add some debounce:

  • press c-c
  • wait for 1 sec, any c-cignored
  • press c-cagain
  • exit
    But the origin issue still there (too much time for exit).

Anyway, I need time to dive into code (I'm newbie in ocaml). Maybe I find better way in other REPLs.

@jordwalke
Copy link
Member Author

So, the difference between c-c and c-d, is that I would hold down c-d to delete many characters. Most people would never hold down c-c for a long time. That means c-d is more proned to accidental quitting of the REPL. Still, people have said that they wouldn't mind c-d to quit the REPL so .. I guess either way would be okay if you're willing to take a shot at implementing.

@slonoed
Copy link

slonoed commented May 12, 2017

@jordwalke BTW it already works in utop and rtop.
Hit c-c c-d to exit in any state (:

@jordwalke
Copy link
Member Author

Perhaps we just need to document it then!

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

4 participants