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

Implement common non-raw-mode keyboard shortcuts #1

Closed
pzmarzly opened this issue May 10, 2019 · 4 comments
Closed

Implement common non-raw-mode keyboard shortcuts #1

pzmarzly opened this issue May 10, 2019 · 4 comments

Comments

@pzmarzly
Copy link
Contributor

In other REPLs Ctrl+D closes REPL if buffer is empty. Also, Ctrl+Z can be used to send it to background (via SIGTSTP). I noticed you are putting the terminal in raw mode, I'm not sure if it is necessary (do other REPLs do that, too?). Isn't there any other way to get Up and Down keypresses? Just asking, I genuinely don't know.

@sigmaSd
Copy link
Owner

sigmaSd commented May 10, 2019

1- So is it as simple as chaning ctrl+C to ctrl+D or I'm missing something
2- for Ctrl+Z I'll check it out but my main concern is how hard is it to mimic the same behavior on windows
3- for raw mode is there a disadvantage on using it?, the problem without using it the terminal will immediately print the keys for example arrow keys will be printed immediately like ^[[D

@pzmarzly
Copy link
Contributor Author

I have no idea how other REPLs do it, but when I e.g. open python3 in terminal, it doesn't print weird characters, yet Ctrl+Z works. But unless you manage to find some "proper" way (my google-fu is not enough to quickly find anything), I'm fine with leaving raw mode and adding:

  • Ctrl+D as if self.buffer.empty() { self.exit()?; }
  • Unix-only Ctrl+Z as nix::sys::signal::kill(nix::unistd::Pid::this(), Some(nix::sys::signal::Signal::SIGTSTP))?

@sigmaSd
Copy link
Owner

sigmaSd commented May 10, 2019

Thanks a lot for the suggestions!
Feel free to open PRs btw
fixed in 20cda4c

@sigmaSd sigmaSd closed this as completed May 10, 2019
@pzmarzly
Copy link
Contributor Author

I will in a second, especially since what you've done is not exactly what I had in mind (though I don't mean any offence, it's still awesome that you replied that fast)

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

2 participants