mirror of
https://github.com/sxyazi/yazi.git
synced 2024-11-28 11:28:02 +03:00
feat: suspend process (Ctrl-Z
) (#120)
This commit is contained in:
parent
0ff1479ce0
commit
230362d6c7
1
Cargo.lock
generated
1
Cargo.lock
generated
@ -378,6 +378,7 @@ dependencies = [
|
||||
"crossterm",
|
||||
"futures",
|
||||
"indexmap 2.0.0",
|
||||
"libc",
|
||||
"natord",
|
||||
"notify",
|
||||
"parking_lot",
|
||||
|
@ -57,6 +57,7 @@ impl Executor {
|
||||
"escape" => cx.manager.active_mut().escape(),
|
||||
"quit" => cx.manager.quit(&cx.tasks),
|
||||
"close" => cx.manager.close(&cx.tasks),
|
||||
"suspend" => cx.manager.suspend(),
|
||||
|
||||
// Navigation
|
||||
"arrow" => {
|
||||
|
@ -50,19 +50,27 @@ impl Signals {
|
||||
|
||||
#[cfg(not(target_os = "windows"))]
|
||||
fn spawn_system_task(&self) -> Result<JoinHandle<()>> {
|
||||
use libc::{SIGHUP, SIGINT, SIGQUIT, SIGTERM};
|
||||
use libc::{SIGCONT, SIGHUP, SIGINT, SIGQUIT, SIGTERM};
|
||||
|
||||
let tx = self.tx.clone();
|
||||
let mut signals = signal_hook_tokio::Signals::new([SIGHUP, SIGTERM, SIGINT, SIGQUIT])?;
|
||||
let mut signals = signal_hook_tokio::Signals::new([
|
||||
// Terminating signals
|
||||
SIGHUP, SIGTERM, SIGQUIT, SIGINT, //
|
||||
// Job control signals
|
||||
SIGCONT,
|
||||
])?;
|
||||
|
||||
Ok(tokio::spawn(async move {
|
||||
while let Some(signal) = signals.next().await {
|
||||
match signal {
|
||||
SIGHUP | SIGTERM | SIGINT | SIGQUIT => {
|
||||
SIGHUP | SIGTERM | SIGQUIT | SIGINT => {
|
||||
if tx.send(Event::Quit).is_err() {
|
||||
break;
|
||||
}
|
||||
}
|
||||
SIGCONT => {
|
||||
tx.send(Event::Stop(false, None)).ok();
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ keymap = [
|
||||
{ on = [ "<Esc>" ], exec = "escape", desc = "Exit visual mode, clear selected, or cancel search" },
|
||||
{ on = [ "q" ], exec = "quit", desc = "Exit the process" },
|
||||
{ on = [ "<C-q>" ], exec = "close", desc = "Close the current tab, or quit if it is last tab" },
|
||||
{ on = [ "<C-z>" ], exec = "suspend", desc = "Suspend the process" },
|
||||
|
||||
# Navigation
|
||||
{ on = [ "k" ], exec = "arrow -1", desc = "Move cursor up" },
|
||||
|
@ -14,6 +14,7 @@ async-channel = "^1"
|
||||
crossterm = "^0"
|
||||
futures = "^0"
|
||||
indexmap = "^2"
|
||||
libc = "^0"
|
||||
natord = "^1"
|
||||
notify = { version = "^6", default-features = false, features = [ "macos_fsevent" ] }
|
||||
parking_lot = "^0"
|
||||
|
@ -121,6 +121,14 @@ impl Manager {
|
||||
self.quit(tasks)
|
||||
}
|
||||
|
||||
pub fn suspend(&mut self) -> bool {
|
||||
tokio::spawn(async move {
|
||||
emit!(Stop(true)).await;
|
||||
unsafe { libc::raise(libc::SIGTSTP) };
|
||||
});
|
||||
false
|
||||
}
|
||||
|
||||
pub fn open(&mut self, interactive: bool) -> bool {
|
||||
let mut files: Vec<_> = self
|
||||
.selected()
|
||||
|
@ -1 +1 @@
|
||||
{"language":"en","words":["Punct","KEYMAP","splitn","crossterm","YAZI","unar","peekable","ratatui","syntect","pbpaste","pbcopy","ffmpegthumbnailer","oneshot","Posix","Lsar","XADDOS","zoxide","cands","Deque","precache","imageops","IFBLK","IFCHR","IFDIR","IFIFO","IFLNK","IFMT","IFSOCK","IRGRP","IROTH","IRUSR","ISGID","ISUID","ISVTX","IWGRP","IWOTH","IWUSR","IXGRP","IXOTH","IXUSR","libc","winsize","TIOCGWINSZ","xpixel","ypixel","ioerr","appender","Catppuccin","macchiato","gitmodules","Dotfiles","bashprofile","vimrc","flac","webp","exiftool","mediainfo","ripgrep","nvim","indexmap","indexmap","unwatch","canonicalize","serde","fsevent","Ueberzug","iterm","wezterm","sixel","chafa","ueberzugpp","️ Überzug","️ Überzug","Konsole","Alacritty","Überzug","pkgs","paru","unarchiver","pdftoppm","poppler","prebuild","singlefile","jpegopt","EXIF","rustfmt","mktemp","nanos","xclip","xsel","natord","Mintty","nixos","nixpkgs"],"version":"0.2","flagWords":[]}
|
||||
{"language":"en","words":["Punct","KEYMAP","splitn","crossterm","YAZI","unar","peekable","ratatui","syntect","pbpaste","pbcopy","ffmpegthumbnailer","oneshot","Posix","Lsar","XADDOS","zoxide","cands","Deque","precache","imageops","IFBLK","IFCHR","IFDIR","IFIFO","IFLNK","IFMT","IFSOCK","IRGRP","IROTH","IRUSR","ISGID","ISUID","ISVTX","IWGRP","IWOTH","IWUSR","IXGRP","IXOTH","IXUSR","libc","winsize","TIOCGWINSZ","xpixel","ypixel","ioerr","appender","Catppuccin","macchiato","gitmodules","Dotfiles","bashprofile","vimrc","flac","webp","exiftool","mediainfo","ripgrep","nvim","indexmap","indexmap","unwatch","canonicalize","serde","fsevent","Ueberzug","iterm","wezterm","sixel","chafa","ueberzugpp","️ Überzug","️ Überzug","Konsole","Alacritty","Überzug","pkgs","paru","unarchiver","pdftoppm","poppler","prebuild","singlefile","jpegopt","EXIF","rustfmt","mktemp","nanos","xclip","xsel","natord","Mintty","nixos","nixpkgs","SIGTSTP","SIGCONT","SIGCONT"],"version":"0.2","flagWords":[]}
|
||||
|
Loading…
Reference in New Issue
Block a user