This commit is contained in:
sxyazi 2024-02-17 18:00:52 +08:00
parent 5d599167a1
commit cad0e061eb
No known key found for this signature in database
6 changed files with 22 additions and 28 deletions

View file

@ -31,8 +31,8 @@ keymap = [
{ on = [ "<PageUp>" ], exec = "arrow -100%", desc = "Move cursor up one page" }, { on = [ "<PageUp>" ], exec = "arrow -100%", desc = "Move cursor up one page" },
{ on = [ "<PageDown>" ], exec = "arrow 100%", desc = "Move cursor down one page" }, { on = [ "<PageDown>" ], exec = "arrow 100%", desc = "Move cursor down one page" },
{ on = [ "h" ], exec = [ "escape --visual", "leave" ], desc = "Go back to the parent directory" }, { on = [ "h" ], exec = "leave", desc = "Go back to the parent directory" },
{ on = [ "l" ], exec = [ "escape --visual", "enter" ], desc = "Enter the child directory" }, { on = [ "l" ], exec = "enter", desc = "Enter the child directory" },
{ on = [ "H" ], exec = "back", desc = "Go back to the previous directory" }, { on = [ "H" ], exec = "back", desc = "Go back to the previous directory" },
{ on = [ "L" ], exec = "forward", desc = "Go forward to the next directory" }, { on = [ "L" ], exec = "forward", desc = "Go forward to the next directory" },

View file

@ -0,0 +1,7 @@
use yazi_shared::event::Cmd;
use crate::tab::Tab;
impl Tab {
pub fn back(&mut self, _: Cmd) { self.backstack.shift_backward().cloned().map(|u| self.cd(u)); }
}

View file

@ -1,25 +0,0 @@
use yazi_shared::event::Cmd;
use crate::tab::Tab;
pub struct Opt;
impl From<()> for Opt {
fn from(_: ()) -> Self { Self }
}
impl From<Cmd> for Opt {
fn from(_: Cmd) -> Self { Self }
}
impl Tab {
pub fn back(&mut self, _: impl Into<Opt>) {
if let Some(url) = self.backstack.shift_backward().cloned() {
self.cd(url);
}
}
pub fn forward(&mut self, _: impl Into<Opt>) {
if let Some(url) = self.backstack.shift_forward().cloned() {
self.cd(url);
}
}
}

View file

@ -33,6 +33,10 @@ impl Tab {
} }
pub fn cd(&mut self, opt: impl Into<Opt>) { pub fn cd(&mut self, opt: impl Into<Opt>) {
if !self.try_escape_visual() {
return;
}
let opt = opt.into() as Opt; let opt = opt.into() as Opt;
if opt.interactive { if opt.interactive {
return self.cd_interactive(); return self.cd_interactive();

View file

@ -0,0 +1,7 @@
use yazi_shared::event::Cmd;
use crate::tab::Tab;
impl Tab {
pub fn forward(&mut self, _: Cmd) { self.backstack.shift_forward().cloned().map(|u| self.cd(u)); }
}

View file

@ -1,11 +1,12 @@
mod arrow; mod arrow;
mod backstack; mod back;
mod cd; mod cd;
mod copy; mod copy;
mod enter; mod enter;
mod escape; mod escape;
mod filter; mod filter;
mod find; mod find;
mod forward;
mod hidden; mod hidden;
mod jump; mod jump;
mod leave; mod leave;