diff --git a/yazi-core/src/input/input.rs b/yazi-core/src/input/input.rs index ce442526..338b59ea 100644 --- a/yazi-core/src/input/input.rs +++ b/yazi-core/src/input/input.rs @@ -2,30 +2,49 @@ use std::ops::{Deref, DerefMut}; use anyhow::Result; use yazi_config::popup::Position; +use yazi_macro::{render, succ}; use yazi_shared::{data::Data, event::ActionCow}; +use yazi_widgets::input::{InputOp, parser::HistoryOpt}; #[derive(Default)] pub struct Input { pub(super) inner: yazi_widgets::input::Input, - pub history: yazi_widgets::input::InputHistory, + pub history: yazi_widgets::input::InputHistory, - pub visible: bool, - pub title: String, + pub visible: bool, + pub title: String, pub position: Position, } impl Input { pub fn execute(&mut self, action: ActionCow) -> Result { - self.inner.execute(action, &mut self.history) + if action.name == "history" { + return self.history(action.into()); + } + self.inner.execute(action) + } + + pub fn history(&mut self, opt: HistoryOpt) -> Result { + if self.inner.snap().op != InputOp::None || self.inner.obscure { + succ!(); + } + if !self.history.navigate(opt.offset, &mut self.inner.snaps, self.inner.limit) { + succ!(); + } + succ!(render!()); } } impl Deref for Input { type Target = yazi_widgets::input::Input; - fn deref(&self) -> &Self::Target { &self.inner } + fn deref(&self) -> &Self::Target { + &self.inner + } } impl DerefMut for Input { - fn deref_mut(&mut self) -> &mut Self::Target { &mut self.inner } + fn deref_mut(&mut self) -> &mut Self::Target { + &mut self.inner + } } diff --git a/yazi-widgets/src/input/actor/actor.rs b/yazi-widgets/src/input/actor/actor.rs index 2b526663..a029417d 100644 --- a/yazi-widgets/src/input/actor/actor.rs +++ b/yazi-widgets/src/input/actor/actor.rs @@ -2,10 +2,10 @@ use anyhow::Result; use yazi_macro::{act, succ}; use yazi_shared::{data::Data, event::ActionCow}; -use crate::input::{Input, InputHistory, InputMode}; +use crate::input::{Input, InputMode}; impl Input { - pub fn execute(&mut self, action: ActionCow, history: &mut InputHistory) -> Result { + pub fn execute(&mut self, action: ActionCow) -> Result { macro_rules! on { ($name:ident) => { if action.name == stringify!($name) { @@ -22,9 +22,6 @@ impl Input { on!(r#move, "move"); on!(backward); on!(forward); - if action.name == "history" { - return self.history(action.into(), history); - } match self.mode() { InputMode::Normal => { diff --git a/yazi-widgets/src/input/actor/history.rs b/yazi-widgets/src/input/actor/history.rs deleted file mode 100644 index 8e0b10dd..00000000 --- a/yazi-widgets/src/input/actor/history.rs +++ /dev/null @@ -1,19 +0,0 @@ -use anyhow::Result; -use yazi_macro::{render, succ}; -use yazi_shared::data::Data; - -use crate::input::{Input, InputHistory, InputOp, parser::HistoryOpt}; - -impl Input { - pub fn history(&mut self, opt: HistoryOpt, history: &mut InputHistory) -> Result { - if self.snap().op != InputOp::None || self.obscure { - succ!(); - } - - if !history.navigate(opt.offset, &mut self.snaps, self.limit) { - succ!(); - } - - succ!(render!()); - } -} diff --git a/yazi-widgets/src/input/actor/mod.rs b/yazi-widgets/src/input/actor/mod.rs index 3e891aa2..7913df7d 100644 --- a/yazi-widgets/src/input/actor/mod.rs +++ b/yazi-widgets/src/input/actor/mod.rs @@ -1 +1 @@ -yazi_macro::mod_flat!(actor backspace backward casefy complete delete escape forward history insert kill paste r#move r#type redo replace undo visual yank); +yazi_macro::mod_flat!(actor backspace backward casefy complete delete escape forward insert kill paste r#move r#type redo replace undo visual yank);