mirror of
https://github.com/sxyazi/yazi.git
synced 2026-07-25 08:41:05 +00:00
..
This commit is contained in:
parent
ac20e79a84
commit
dff12bcdbe
3 changed files with 45 additions and 5 deletions
|
|
@ -89,12 +89,23 @@ impl Exec {
|
|||
|
||||
impl Exec {
|
||||
#[inline]
|
||||
pub fn call(cwd: &str, args: Vec<String>) -> Vec<Self> {
|
||||
vec![Exec { cmd: cwd.to_owned(), args, named: Default::default() }]
|
||||
pub fn call(cwd: &str, args: Vec<String>) -> Self {
|
||||
Exec { cmd: cwd.to_owned(), args, named: Default::default() }
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn call_named(cwd: &str, named: BTreeMap<String, String>) -> Vec<Self> {
|
||||
vec![Exec { cmd: cwd.to_owned(), args: Default::default(), named }]
|
||||
pub fn call_named(cwd: &str, named: BTreeMap<String, String>) -> Self {
|
||||
Exec { cmd: cwd.to_owned(), args: Default::default(), named }
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn vec(self) -> Vec<Self> { vec![self] }
|
||||
|
||||
#[inline]
|
||||
pub fn with_bool(mut self, name: &str, state: bool) -> Self {
|
||||
if state {
|
||||
self.named.insert(name.to_string(), "".to_string());
|
||||
}
|
||||
self
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -39,7 +39,6 @@ impl Finder {
|
|||
if self.version == files.version() {
|
||||
return false;
|
||||
}
|
||||
|
||||
self.matched.clear();
|
||||
|
||||
let mut i = 0u8;
|
||||
|
|
|
|||
|
|
@ -232,6 +232,36 @@ impl Tab {
|
|||
false
|
||||
}
|
||||
|
||||
pub fn find(&mut self, query: Option<&str>, prev: bool) -> bool {
|
||||
if let Some(query) = query {
|
||||
self.finder = Finder::new(query).ok();
|
||||
return self.find_arrow(prev);
|
||||
}
|
||||
|
||||
tokio::spawn(async move {
|
||||
if let Ok(s) = emit!(Input(InputOpt::top("Find:"))).await {
|
||||
emit!(Call(
|
||||
Exec::call("find", vec![s]).with_bool("previous", prev).vec(),
|
||||
KeymapLayer::Manager
|
||||
));
|
||||
}
|
||||
});
|
||||
false
|
||||
}
|
||||
|
||||
pub fn find_arrow(&mut self, prev: bool) -> bool {
|
||||
let Some(finder) = &mut self.finder else {
|
||||
return false;
|
||||
};
|
||||
|
||||
let mut b = finder.catchup(&self.current.files);
|
||||
if let Some(step) = finder.arrow(&self.current.files, self.current.cursor(), prev) {
|
||||
b |= self.arrow(step);
|
||||
}
|
||||
|
||||
b
|
||||
}
|
||||
|
||||
pub fn search(&mut self, grep: bool) -> bool {
|
||||
if let Some(handle) = self.search.take() {
|
||||
handle.abort();
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue