Skip to content

Commit

Permalink
Ctrl-z now suspends jless.
Browse files Browse the repository at this point in the history
  • Loading branch information
PaulJuliusMartinez committed Dec 14, 2023
1 parent b445731 commit 3d1c43f
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 1 deletion.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
main
====

No changes yet!
Improvements:
- [Issue #143]: `ctrl-z` will now send jless to the background

v0.9.0 (2023-07-16)
==================
Expand Down
22 changes: 22 additions & 0 deletions src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,28 @@ impl App {
continue;
}

// If the user hits Ctrl-z, we don't modify state at all, just send SIGSTOP to
// ourself, then loop around and process the next input.
if matches!(event, KeyEvent(Key::Ctrl('z'))) {
// Restore terminal prior to suspending.
let _ = self.screen_writer.stdout.suspend_raw_mode();
let _ = write!(self.screen_writer.stdout, "{DISABLE_MOUSE_BUTTON_TRACKING}");
let _ = write!(self.screen_writer.stdout, "{ToMainScreen}");
let _ = write!(self.screen_writer.stdout, "{}", termion::cursor::Show);
let _ = self.screen_writer.stdout.flush();
unsafe {
libc::kill(0, libc::SIGSTOP);
}
// Re-enable all the terminal settings.
let _ = write!(self.screen_writer.stdout, "{}", termion::cursor::Hide);
let _ = write!(self.screen_writer.stdout, "{ToAlternateScreen}");
let _ = write!(self.screen_writer.stdout, "{ENABLE_MOUSE_BUTTON_TRACKING}");
let _ = self.screen_writer.stdout.activate_raw_mode();
// I'm not exactly sure why we have to do this.
self.draw_screen();
continue;
}

// When "actively" searching, we want to show highlighted search terms.
// We consider someone "actively" searching immediately after the start
// of a search, and while they navigate between matches using n/N.
Expand Down
2 changes: 2 additions & 0 deletions src/jless.help
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@

F1 :help Show this help screen.

^z Suspend jless.

MOVING

j DownArrow * Move focus down one line (or N lines).
Expand Down

0 comments on commit 3d1c43f

Please sign in to comment.