Skip to content

Commit

Permalink
disable/enable raw mode when suspending/resuming
Browse files Browse the repository at this point in the history
  • Loading branch information
xvxx committed Nov 19, 2022
1 parent 9baac84 commit fb1b3d2
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/ui.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,11 @@ fn resize_handler(_: i32) {
/// received in child processes (like `telnet`).
fn sigint_handler(_: i32) {}

/// Handler for when the application is resumed after ctrl-z.
fn sigcont_handler(_: i32) {
terminal::enable_raw_mode().expect("Fatal Error entering Raw Mode.");
}

/// UI is mainly concerned with drawing to the screen, managing the
/// active views, and responding to user input.
pub struct UI {
Expand Down Expand Up @@ -585,6 +590,7 @@ impl UI {
unsafe {
libc::signal(libc::SIGWINCH, resize_handler as usize);
libc::signal(libc::SIGINT, sigint_handler as usize);
libc::signal(libc::SIGCONT, sigcont_handler as usize);
}

thread::spawn(move || {
Expand All @@ -598,6 +604,7 @@ impl UI {

/// Ctrl-Z: Suspend Unix process w/ SIGTSTP.
fn suspend(&mut self) {
terminal::disable_raw_mode().expect("Fatal Error disabling Raw Mode");
let mut out = stdout();
write!(out, "{}", terminal::ToMainScreen).expect(ERR_SCREEN);
out.flush().expect(ERR_STDOUT);
Expand Down

0 comments on commit fb1b3d2

Please sign in to comment.