-
Notifications
You must be signed in to change notification settings - Fork 181
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
Keybinding to ASCII characters #421
Comments
Because of this: '\x08' => KeyPress::Backspace, // '\b' Control characters received from stdin are "normalized" before looking for associated command. |
Right. I've seen that. So there is no way to use char literals for keybindings? |
And I guess we cannot retrieved a Ctrl-backspace from a Unix terminal. |
You may already know but you can patch this example. RUST_LOG=rustyline=debug cargo run --example example 2> debug.log
# tail -f debug.log in another terminal... to trace all keys pressed. |
oh, I didn't know that. Thanks for the tip! |
We should (have) "normalize" the first parameter of |
We want to be able to bind |
For me, you cannot retrieve a |
Something like: diff --git a/src/lib.rs b/src/lib.rs
index faa8da0..968fb87 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -887,7 +887,21 @@ impl<H: Helper> Editor<H> {
/// Bind a sequence to a command.
pub fn bind_sequence(&mut self, key_seq: KeyPress, cmd: Cmd) -> Option<Cmd> {
if let Ok(mut bindings) = self.custom_bindings.write() {
- bindings.insert(key_seq, cmd)
+ let key = if let KeyPress::Char(ref c) = key_seq {
+ if c.is_control() {
+ keys::char_to_key_press(*c)
+ } else {
+ key_seq
+ }
+ } else if let KeyPress::Ctrl(ref c) = key_seq {
+ if c.is_control() {
+ warn!(target: "rustyline", "KeyPress::Ctrl({:?}) may not work on unix", c)
+ }
+ key_seq
+ } else {
+ key_seq
+ };
+ bindings.insert(key, cmd)
} else {
None
} |
what would be even better, is to allow the windows customization, and warn like you do here. Also, vice-versa, i assume there are keys that unix can bind that windows cannot. |
If you want to support } else if key == KeyPress::Backspace && ctrl {
... (not tested) |
Here's a PR to look at for this stuff. |
Version 7.0.0 released |
I'm trying to understand rustyline's keybindings better because I'm not sure what we have implemented in nushell is working.
This backspaces a character at a time. It seems like it should backspace a word at a time.
This backspaces a word at a time. I think that is correct.
This backspaces a character at a time. It seems like this should backspace a word at a time with
ctrl+backspace
.Any ideas why only the middle one seems to work?
The text was updated successfully, but these errors were encountered: