mirror of
https://github.com/sxyazi/yazi.git
synced 2026-07-25 08:41:05 +00:00
..
This commit is contained in:
parent
598d63ccb9
commit
329ce25179
2 changed files with 19 additions and 21 deletions
|
|
@ -1,4 +1,4 @@
|
||||||
use core::{files::FilesSort, input::InputMode};
|
use core::{emit, files::FilesSort, input::InputMode};
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
|
|
||||||
use config::{keymap::{Control, Exec, Key, KeymapLayer}, manager::SortBy, KEYMAP};
|
use config::{keymap::{Control, Exec, Key, KeymapLayer}, manager::SortBy, KEYMAP};
|
||||||
|
|
@ -67,8 +67,12 @@ impl Executor {
|
||||||
"forward" => cx.manager.active_mut().forward(),
|
"forward" => cx.manager.active_mut().forward(),
|
||||||
"cd" => {
|
"cd" => {
|
||||||
let path = exec.args.get(0).map(PathBuf::from).unwrap_or_default();
|
let path = exec.args.get(0).map(PathBuf::from).unwrap_or_default();
|
||||||
let interactive = exec.named.contains_key("interactive");
|
if exec.named.contains_key("interactive") {
|
||||||
cx.manager.active_mut().cd_interactive(interactive, path)
|
cx.manager.active_mut().cd_interactive(path)
|
||||||
|
} else {
|
||||||
|
emit!(Cd(path));
|
||||||
|
false
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Selection
|
// Selection
|
||||||
|
|
|
||||||
|
|
@ -74,24 +74,6 @@ impl Tab {
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn cd_interactive(&mut self, interactive: bool, target: PathBuf) -> bool {
|
|
||||||
if interactive {
|
|
||||||
tokio::spawn(async move {
|
|
||||||
let result = emit!(Input(InputOpt::top("Path:").with_value(target.to_string_lossy())));
|
|
||||||
|
|
||||||
if let Ok(path) = result.await {
|
|
||||||
let path = PathBuf::from(path);
|
|
||||||
emit!(Cd(path));
|
|
||||||
}
|
|
||||||
Ok::<(), Error>(())
|
|
||||||
});
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
emit!(Cd(target));
|
|
||||||
}
|
|
||||||
false
|
|
||||||
}
|
|
||||||
|
|
||||||
pub async fn cd(&mut self, mut target: PathBuf) -> bool {
|
pub async fn cd(&mut self, mut target: PathBuf) -> bool {
|
||||||
let file = if let Ok(f) = File::from(&target).await {
|
let file = if let Ok(f) = File::from(&target).await {
|
||||||
f
|
f
|
||||||
|
|
@ -133,6 +115,18 @@ impl Tab {
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn cd_interactive(&mut self, target: PathBuf) -> bool {
|
||||||
|
tokio::spawn(async move {
|
||||||
|
let result =
|
||||||
|
emit!(Input(InputOpt::top("Change directory:").with_value(target.to_string_lossy())));
|
||||||
|
|
||||||
|
if let Ok(target) = result.await {
|
||||||
|
emit!(Cd(PathBuf::from(target)));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
false
|
||||||
|
}
|
||||||
|
|
||||||
pub fn enter(&mut self) -> bool {
|
pub fn enter(&mut self) -> bool {
|
||||||
let hovered = if let Some(ref h) = self.current.hovered {
|
let hovered = if let Some(ref h) = self.current.hovered {
|
||||||
h.clone()
|
h.clone()
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue