mirror of
https://github.com/sxyazi/yazi.git
synced 2026-07-25 08:41:05 +00:00
feat: open support open dir
This commit is contained in:
parent
dfa338500c
commit
a75f307cc7
3 changed files with 11 additions and 14 deletions
|
|
@ -21,8 +21,8 @@ keymap = [
|
||||||
{ on = [ "<Up>" ], exec = "arrow -1" },
|
{ on = [ "<Up>" ], exec = "arrow -1" },
|
||||||
{ on = [ "<Down>" ], exec = "arrow 1" },
|
{ on = [ "<Down>" ], exec = "arrow 1" },
|
||||||
{ on = [ "<Left>" ], exec = "leave" },
|
{ on = [ "<Left>" ], exec = "leave" },
|
||||||
{ on = [ "<Right>" ], exec = "enter" },
|
{ on = [ "<Right>" ], exec = "open" },
|
||||||
{ on = [ "<C-Right>" ], exec = "enter --select" },
|
{ on = [ "<C-Right>" ], exec = "open --select" },
|
||||||
|
|
||||||
# Selection
|
# Selection
|
||||||
{ on = [ "<Space>" ], exec = "select --state=none" },
|
{ on = [ "<Space>" ], exec = "select --state=none" },
|
||||||
|
|
|
||||||
|
|
@ -263,17 +263,14 @@ impl Tab {
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn current_is_file(&self) -> bool{
|
pub fn current_is_dir(&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()
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
};
|
};
|
||||||
|
|
||||||
if hovered.meta.is_dir() {
|
hovered.meta.is_dir()
|
||||||
return false;
|
|
||||||
}
|
|
||||||
true
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -62,12 +62,7 @@ impl Executor {
|
||||||
cx.manager.active_mut().arrow(step)
|
cx.manager.active_mut().arrow(step)
|
||||||
}
|
}
|
||||||
"leave" => cx.manager.active_mut().leave(),
|
"leave" => cx.manager.active_mut().leave(),
|
||||||
"enter" =>{
|
"enter" => cx.manager.active_mut().enter(),
|
||||||
if cx.manager.active().current_is_file() {
|
|
||||||
return cx.manager.open(exec.named.contains_key("select"))
|
|
||||||
}
|
|
||||||
cx.manager.active_mut().enter()
|
|
||||||
},
|
|
||||||
"back" => cx.manager.active_mut().back(),
|
"back" => cx.manager.active_mut().back(),
|
||||||
"forward" => cx.manager.active_mut().forward(),
|
"forward" => cx.manager.active_mut().forward(),
|
||||||
|
|
||||||
|
|
@ -83,7 +78,12 @@ impl Executor {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Operation
|
// Operation
|
||||||
"open" => cx.manager.open(exec.named.contains_key("select")),
|
"open" => {
|
||||||
|
if cx.manager.active().current_is_dir() {
|
||||||
|
return cx.manager.active_mut().enter();
|
||||||
|
}
|
||||||
|
cx.manager.open(exec.named.contains_key("select"))
|
||||||
|
},
|
||||||
"yank" => cx.manager.yank(exec.named.contains_key("cut")),
|
"yank" => cx.manager.yank(exec.named.contains_key("cut")),
|
||||||
"paste" => {
|
"paste" => {
|
||||||
let dest = cx.manager.current().cwd.clone();
|
let dest = cx.manager.current().cwd.clone();
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue