Skip to content
Snippets Groups Projects
Commit a6f36b6d authored by gwenn's avatar gwenn
Browse files

Fix Ctrl-Z (#20)

parent 4dd0cb77
No related branches found
No related tags found
No related merge requests found
...@@ -43,8 +43,6 @@ use std::io::{self, Write}; ...@@ -43,8 +43,6 @@ use std::io::{self, Write};
use std::mem; use std::mem;
use std::path::Path; use std::path::Path;
use std::result; use std::result;
#[cfg(unix)]
use nix::sys::signal;
use tty::{RawMode, RawReader, Terminal, Term}; use tty::{RawMode, RawReader, Terminal, Term};
use completion::{Completer, longest_common_prefix}; use completion::{Completer, longest_common_prefix};
...@@ -937,7 +935,7 @@ fn readline_edit<C: Completer>(prompt: &str, ...@@ -937,7 +935,7 @@ fn readline_edit<C: Completer>(prompt: &str,
#[cfg(unix)] #[cfg(unix)]
KeyPress::Ctrl('Z') => { KeyPress::Ctrl('Z') => {
try!(original_mode.disable_raw_mode()); try!(original_mode.disable_raw_mode());
try!(signal::raise(signal::SIGSTOP)); try!(tty::suspend());
try!(s.term.enable_raw_mode()); // TODO original_mode may have changed try!(s.term.enable_raw_mode()); // TODO original_mode may have changed
try!(s.refresh_line()) try!(s.refresh_line())
} }
......
...@@ -140,3 +140,8 @@ impl Term for DummyTerminal { ...@@ -140,3 +140,8 @@ impl Term for DummyTerminal {
Ok(()) Ok(())
} }
} }
#[cfg(unix)]
pub fn suspend() -> Result<()> {
Ok(())
}
...@@ -325,6 +325,14 @@ impl Term for PosixTerminal { ...@@ -325,6 +325,14 @@ impl Term for PosixTerminal {
} }
} }
#[cfg(unix)]
pub fn suspend() -> Result<()> {
// For macos:
try!(signal::kill(nix::unistd::getppid(), signal::SIGTSTP));
try!(signal::kill(nix::unistd::getpid(), signal::SIGTSTP));
Ok(())
}
#[cfg(all(unix,test))] #[cfg(all(unix,test))]
mod test { mod test {
#[test] #[test]
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment