-
Notifications
You must be signed in to change notification settings - Fork 176
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
rustyline ignores user's terminal settings for VINTR and VSUSP on Unix #530
Comments
|
You are correct in that one would use the termios(3) and specifically |
Ok, so we should be able to retrieve current config here and overwrite default key bindings accordingly. |
Could you please give a try to #535 ? rustyline % RUST_LOG=rustyline=debug cargo run --example example 2> debug.log
|
This doesn't seem to work; setting
This may be because of:
|
@godmar Could you give it another try ? |
This now works, except for EOF. diff --git a/examples/example.rs b/examples/example.rs
index 7b3ccc8..f937b8f 100644
--- a/examples/example.rs
+++ b/examples/example.rs
@@ -113,11 +113,11 @@ fn main() -> rustyline::Result<()> {
println!("Line: {}", line);
}
Err(ReadlineError::Interrupted) => {
- println!("CTRL-C");
+ println!("Interrupted");
break;
}
Err(ReadlineError::Eof) => {
- println!("CTRL-D");
+ println!("Encountered Eof");
break;
}
Err(err) => {
diff --git a/src/keymap.rs b/src/keymap.rs
index 67c9775..d459062 100644
--- a/src/keymap.rs
+++ b/src/keymap.rs
@@ -1045,6 +1045,7 @@ impl InputState {
}),
#[cfg(any(windows, test))]
E(K::Char('C'), M::CTRL) => Cmd::Interrupt,
+ #[cfg(any(windows, test))]
E(K::Char('D'), M::CTRL) => {
if self.is_emacs_mode() && !wrt.line().is_empty() {
Cmd::Kill(if positive {
diff --git a/src/tty/unix.rs b/src/tty/unix.rs
index 584076d..e1c31ae 100644
--- a/src/tty/unix.rs
+++ b/src/tty/unix.rs
@@ -1151,6 +1151,7 @@ impl Term for PosixTerminal {
raw.control_chars[SCI::VTIME as usize] = 0; // with blocking read
let mut key_map: HashMap<KeyEvent, Cmd> = HashMap::with_capacity(3);
+ map_key(&mut key_map, &raw, SCI::VEOF, "VEOF", Cmd::EndOfFile);
map_key(&mut key_map, &raw, SCI::VINTR, "VINTR", Cmd::Interrupt);
map_key(&mut key_map, &raw, SCI::VQUIT, "VQUIT", Cmd::Interrupt);
map_key(&mut key_map, &raw, SCI::VSUSP, "VSUSP", Cmd::Suspend); |
See also how editline handle VEOF. |
Independent of any other logic to which you may be referring, editline seems to respect the termios settings by doing: |
|
Version 9.1.0 released. |
On Unix, users expect to configure the character they type to cause
SIGINT
to be sent to the foreground process group by typing, e.g.stty intr ^X
where^X
is the key combination they wish to use.rustyline doesn't use signal handling, turns off
ISIG
, and hardwires Ctrl-C as the interrupt character.Likewise, the functionality of the
VSUSP
character (by default Ctrl-Z) appears hardwired as well.It may be better for it to query the terminal as to which character the user prefers to use and then implement the corresponding actions when it encounters these characters.
PS: this behavior appears to be inherited from the original "guerrilla" linenoise library.
The text was updated successfully, but these errors were encountered: