mirror of
https://github.com/sxyazi/yazi.git
synced 2026-07-25 08:41:05 +00:00
removed stdout flag
Signed-off-by: aserowy <serowy@hotmail.com>
This commit is contained in:
parent
df2a5ee95c
commit
0e2893ef25
9 changed files with 19 additions and 37 deletions
18
flake.lock
generated
18
flake.lock
generated
|
|
@ -5,11 +5,11 @@
|
||||||
"systems": "systems"
|
"systems": "systems"
|
||||||
},
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1694529238,
|
"lastModified": 1701680307,
|
||||||
"narHash": "sha256-zsNZZGTGnMOf9YpHKJqMSsa0dXbfmxeoJ7xHlrt+xmY=",
|
"narHash": "sha256-kAuep2h5ajznlPMD9rnQyffWG8EM/C73lejGofXvdM8=",
|
||||||
"owner": "numtide",
|
"owner": "numtide",
|
||||||
"repo": "flake-utils",
|
"repo": "flake-utils",
|
||||||
"rev": "ff7b65b44d01cf9ba6a71320833626af21126384",
|
"rev": "4022d587cbbfd70fe950c1e2083a02621806a725",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
|
@ -20,11 +20,11 @@
|
||||||
},
|
},
|
||||||
"nixpkgs": {
|
"nixpkgs": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1701174899,
|
"lastModified": 1704161960,
|
||||||
"narHash": "sha256-1W+FMe8mWsJKXoBc+QgKmEeRj33kTFnPq7XCjU+bfnA=",
|
"narHash": "sha256-QGua89Pmq+FBAro8NriTuoO/wNaUtugt29/qqA8zeeM=",
|
||||||
"owner": "NixOS",
|
"owner": "NixOS",
|
||||||
"repo": "nixpkgs",
|
"repo": "nixpkgs",
|
||||||
"rev": "010c7296f3b19a58b206fdf7d68d75a5b0a09e9e",
|
"rev": "63143ac2c9186be6d9da6035fa22620018c85932",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
|
@ -51,11 +51,11 @@
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1701224160,
|
"lastModified": 1704507282,
|
||||||
"narHash": "sha256-qnMmxNMKmd6Soel0cfauyMJ+LzuZbvmiDQPSIuTbQ+M=",
|
"narHash": "sha256-PDfS8fj40mm2QWpbd/aiocgwcI/WHzqLKERRJkoEvXU=",
|
||||||
"owner": "oxalica",
|
"owner": "oxalica",
|
||||||
"repo": "rust-overlay",
|
"repo": "rust-overlay",
|
||||||
"rev": "4a080e26d55eaedb95ab1bf8eeaeb84149c10f12",
|
"rev": "a127cccf7943beae944953963ba118d643299c3b",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,7 @@ pkgs.mkShell {
|
||||||
rustToolchain
|
rustToolchain
|
||||||
rust-analyzer
|
rust-analyzer
|
||||||
|
|
||||||
|
nodejs_20
|
||||||
nodePackages.cspell
|
nodePackages.cspell
|
||||||
|
|
||||||
file
|
file
|
||||||
|
|
|
||||||
|
|
@ -15,9 +15,6 @@ pub struct Args {
|
||||||
/// Write the selected files on open emitted by the chooser mode
|
/// Write the selected files on open emitted by the chooser mode
|
||||||
#[arg(long)]
|
#[arg(long)]
|
||||||
pub chooser_file: Option<PathBuf>,
|
pub chooser_file: Option<PathBuf>,
|
||||||
/// Write the selected files on open to stdout
|
|
||||||
#[arg(long, action)]
|
|
||||||
pub chooser_stdout: bool,
|
|
||||||
|
|
||||||
/// Clear the cache directory
|
/// Clear the cache directory
|
||||||
#[arg(long, action)]
|
#[arg(long, action)]
|
||||||
|
|
|
||||||
|
|
@ -107,10 +107,6 @@ impl Manager {
|
||||||
quit_actions.push(QuitAction::SelectToFile(paths.clone()));
|
quit_actions.push(QuitAction::SelectToFile(paths.clone()));
|
||||||
};
|
};
|
||||||
|
|
||||||
if ARGS.chooser_stdout {
|
|
||||||
quit_actions.push(QuitAction::SelectToStdout(paths.clone()));
|
|
||||||
};
|
|
||||||
|
|
||||||
if quit_actions.len() > 1 {
|
if quit_actions.len() > 1 {
|
||||||
tokio::spawn(async move {
|
tokio::spawn(async move {
|
||||||
emit!(Quit(quit_actions));
|
emit!(Quit(quit_actions));
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@ impl Select {
|
||||||
pub async fn _show(cfg: SelectCfg) -> Result<usize> {
|
pub async fn _show(cfg: SelectCfg) -> Result<usize> {
|
||||||
let (tx, rx) = oneshot::channel();
|
let (tx, rx) = oneshot::channel();
|
||||||
emit!(Call(Exec::call("show", vec![]).with_data(Opt { cfg, tx }).vec(), Layer::Select));
|
emit!(Call(Exec::call("show", vec![]).with_data(Opt { cfg, tx }).vec(), Layer::Select));
|
||||||
rx.await.unwrap_or_else(|_| Term::goodbye(|| false, None))
|
rx.await.unwrap_or_else(|_| Term::goodbye(|| false))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn show(&mut self, opt: impl TryInto<Opt>) {
|
pub fn show(&mut self, opt: impl TryInto<Opt>) {
|
||||||
|
|
|
||||||
|
|
@ -9,22 +9,18 @@ use crate::app::App;
|
||||||
impl App {
|
impl App {
|
||||||
pub(crate) fn quit(&mut self, quit_actions: Vec<QuitAction>) -> Result<()> {
|
pub(crate) fn quit(&mut self, quit_actions: Vec<QuitAction>) -> Result<()> {
|
||||||
if quit_actions.contains(&QuitAction::None) {
|
if quit_actions.contains(&QuitAction::None) {
|
||||||
Term::goodbye(|| false, None)
|
Term::goodbye(|| false)
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut stdout = None;
|
|
||||||
for quit_action in quit_actions {
|
for quit_action in quit_actions {
|
||||||
match quit_action {
|
match quit_action {
|
||||||
QuitAction::None => unreachable!(),
|
QuitAction::None => unreachable!(),
|
||||||
QuitAction::CwdToFile => self.cwd_to_file(),
|
QuitAction::CwdToFile => self.cwd_to_file(),
|
||||||
QuitAction::SelectToFile(selected) => self.select_to_file(selected),
|
QuitAction::SelectToFile(selected) => self.select_to_file(selected),
|
||||||
QuitAction::SelectToStdout(selected) => {
|
|
||||||
stdout = Some(selected.as_encoded_bytes().to_owned())
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Term::goodbye(|| false, stdout.as_deref());
|
Term::goodbye(|| false);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn cwd_to_file(&self) {
|
fn cwd_to_file(&self) {
|
||||||
|
|
|
||||||
|
|
@ -8,13 +8,10 @@ impl Panic {
|
||||||
|
|
||||||
let hook = std::panic::take_hook();
|
let hook = std::panic::take_hook();
|
||||||
std::panic::set_hook(Box::new(move |info| {
|
std::panic::set_hook(Box::new(move |info| {
|
||||||
Term::goodbye(
|
Term::goodbye(|| {
|
||||||
|| {
|
hook(info);
|
||||||
hook(info);
|
true
|
||||||
true
|
});
|
||||||
},
|
|
||||||
None,
|
|
||||||
);
|
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,6 @@ pub enum QuitAction {
|
||||||
None,
|
None,
|
||||||
CwdToFile,
|
CwdToFile,
|
||||||
SelectToFile(OsString),
|
SelectToFile(OsString),
|
||||||
SelectToStdout(OsString),
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Event {
|
impl Event {
|
||||||
|
|
@ -35,7 +34,7 @@ impl Event {
|
||||||
|
|
||||||
pub async fn wait<T>(self, rx: oneshot::Receiver<T>) -> T {
|
pub async fn wait<T>(self, rx: oneshot::Receiver<T>) -> T {
|
||||||
TX.send(self).ok();
|
TX.send(self).ok();
|
||||||
rx.await.unwrap_or_else(|_| Term::goodbye(|| false, None))
|
rx.await.unwrap_or_else(|_| Term::goodbye(|| false))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -49,7 +49,7 @@ impl Term {
|
||||||
Ok(disable_raw_mode()?)
|
Ok(disable_raw_mode()?)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn goodbye(f: impl FnOnce() -> bool, last_words: Option<&[u8]>) -> ! {
|
pub fn goodbye(f: impl FnOnce() -> bool) -> ! {
|
||||||
execute!(
|
execute!(
|
||||||
stdout(),
|
stdout(),
|
||||||
PopKeyboardEnhancementFlags,
|
PopKeyboardEnhancementFlags,
|
||||||
|
|
@ -63,10 +63,6 @@ impl Term {
|
||||||
|
|
||||||
disable_raw_mode().ok();
|
disable_raw_mode().ok();
|
||||||
|
|
||||||
if let Some(words) = last_words {
|
|
||||||
std::io::stdout().write_all(words).ok();
|
|
||||||
}
|
|
||||||
|
|
||||||
std::process::exit(f() as i32);
|
std::process::exit(f() as i32);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue