mirror of
https://github.com/sxyazi/yazi.git
synced 2026-07-25 08:41:05 +00:00
.. [no ci]
This commit is contained in:
parent
f8d73a95e3
commit
159d59a0ea
14 changed files with 90 additions and 101 deletions
|
|
@ -1,12 +1,12 @@
|
||||||
use yazi_shared::event::Exec;
|
use yazi_shared::{event::Exec, render};
|
||||||
|
|
||||||
use crate::{manager::Manager, tasks::Tasks};
|
use crate::{manager::Manager, tasks::Tasks};
|
||||||
|
|
||||||
impl Manager {
|
impl Manager {
|
||||||
pub fn close(&mut self, _: &Exec, tasks: &Tasks) -> bool {
|
pub fn close(&mut self, _: &Exec, tasks: &Tasks) {
|
||||||
if self.tabs.len() > 1 {
|
if self.tabs.len() > 1 {
|
||||||
return self.tabs.close(self.tabs.idx);
|
return render!(self.tabs.close(self.tabs.idx));
|
||||||
}
|
}
|
||||||
self.quit((), tasks)
|
self.quit((), tasks);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
use std::collections::BTreeSet;
|
use std::collections::BTreeSet;
|
||||||
|
|
||||||
use yazi_shared::{emit, event::Exec, fs::Url, Layer};
|
use yazi_shared::{emit, event::Exec, fs::Url, render, Layer};
|
||||||
|
|
||||||
use crate::manager::Manager;
|
use crate::manager::Manager;
|
||||||
|
|
||||||
|
|
@ -24,13 +24,13 @@ impl Manager {
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn hover(&mut self, opt: impl Into<Opt>) -> bool {
|
pub fn hover(&mut self, opt: impl Into<Opt>) {
|
||||||
// Hover on the file
|
// Hover on the file
|
||||||
let opt = opt.into() as Opt;
|
let opt = opt.into() as Opt;
|
||||||
let mut b = self.current_mut().repos(opt.url);
|
render!(self.current_mut().repos(opt.url));
|
||||||
|
|
||||||
// Re-peek
|
// Re-peek
|
||||||
b |= self.peek(false);
|
self.peek(false);
|
||||||
|
|
||||||
// Refresh watcher
|
// Refresh watcher
|
||||||
let mut to_watch = BTreeSet::new();
|
let mut to_watch = BTreeSet::new();
|
||||||
|
|
@ -44,7 +44,5 @@ impl Manager {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
self.watcher.watch(to_watch);
|
self.watcher.watch(to_watch);
|
||||||
|
|
||||||
b
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
use yazi_shared::{emit, event::Exec, fs::Url, Layer, MIME_DIR};
|
use yazi_shared::{emit, event::Exec, fs::Url, render, Layer, MIME_DIR};
|
||||||
|
|
||||||
use crate::manager::Manager;
|
use crate::manager::Manager;
|
||||||
|
|
||||||
|
|
@ -30,14 +30,14 @@ impl Manager {
|
||||||
emit!(Call(Exec::call("peek", vec![]).with_bool("force", force).vec(), Layer::Manager));
|
emit!(Call(Exec::call("peek", vec![]).with_bool("force", force).vec(), Layer::Manager));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn peek(&mut self, opt: impl Into<Opt>) -> bool {
|
pub fn peek(&mut self, opt: impl Into<Opt>) {
|
||||||
let Some(hovered) = self.hovered() else {
|
let Some(hovered) = self.hovered() else {
|
||||||
return self.active_mut().preview.reset();
|
return render!(self.active_mut().preview.reset());
|
||||||
};
|
};
|
||||||
|
|
||||||
let opt = opt.into() as Opt;
|
let opt = opt.into() as Opt;
|
||||||
if matches!(opt.only_if, Some(ref u) if *u != hovered.url) {
|
if matches!(opt.only_if, Some(ref u) if *u != hovered.url) {
|
||||||
return false;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
let hovered = hovered.clone();
|
let hovered = hovered.clone();
|
||||||
|
|
@ -61,14 +61,13 @@ impl Manager {
|
||||||
} else {
|
} else {
|
||||||
self.active_mut().preview.go_folder(hovered, opt.force);
|
self.active_mut().preview.go_folder(hovered, opt.force);
|
||||||
}
|
}
|
||||||
return false;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(s) = self.mimetype.get(&hovered.url).cloned() {
|
if let Some(s) = self.mimetype.get(&hovered.url).cloned() {
|
||||||
self.active_mut().preview.go(hovered, &s, opt.force);
|
self.active_mut().preview.go(hovered, &s, opt.force);
|
||||||
} else {
|
} else {
|
||||||
return self.active_mut().preview.reset();
|
return render!(self.active_mut().preview.reset());
|
||||||
}
|
}
|
||||||
false
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -15,13 +15,13 @@ impl From<&Exec> for Opt {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Manager {
|
impl Manager {
|
||||||
pub fn quit(&self, opt: impl Into<Opt>, tasks: &Tasks) -> bool {
|
pub fn quit(&self, opt: impl Into<Opt>, tasks: &Tasks) {
|
||||||
let opt = opt.into() as Opt;
|
let opt = opt.into() as Opt;
|
||||||
|
|
||||||
let tasks = tasks.len();
|
let tasks = tasks.len();
|
||||||
if tasks == 0 {
|
if tasks == 0 {
|
||||||
emit!(Quit(opt.no_cwd_file));
|
emit!(Quit(opt.no_cwd_file));
|
||||||
return false;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
tokio::spawn(async move {
|
tokio::spawn(async move {
|
||||||
|
|
@ -32,6 +32,5 @@ impl Manager {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
false
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@ impl Manager {
|
||||||
emit!(Call(Exec::call("refresh", vec![]).vec(), Layer::Manager));
|
emit!(Call(Exec::call("refresh", vec![]).vec(), Layer::Manager));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn refresh(&mut self, _: &Exec) -> bool {
|
pub fn refresh(&mut self, _: &Exec) {
|
||||||
env::set_current_dir(self.cwd()).ok();
|
env::set_current_dir(self.cwd()).ok();
|
||||||
env::set_var("PWD", self.cwd());
|
env::set_var("PWD", self.cwd());
|
||||||
|
|
||||||
|
|
@ -22,6 +22,6 @@ impl Manager {
|
||||||
self.watcher.trigger_dirs(&[self.cwd()]);
|
self.watcher.trigger_dirs(&[self.cwd()]);
|
||||||
}
|
}
|
||||||
|
|
||||||
self.hover(None)
|
self.hover(None);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
use yazi_config::PLUGIN;
|
use yazi_config::PLUGIN;
|
||||||
use yazi_plugin::isolate;
|
use yazi_plugin::isolate;
|
||||||
use yazi_shared::{event::Exec, MIME_DIR};
|
use yazi_shared::{event::Exec, render, MIME_DIR};
|
||||||
|
|
||||||
use crate::manager::Manager;
|
use crate::manager::Manager;
|
||||||
|
|
||||||
|
|
@ -16,9 +16,9 @@ impl From<&Exec> for Opt {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Manager {
|
impl Manager {
|
||||||
pub fn seek(&mut self, opt: impl Into<Opt>) -> bool {
|
pub fn seek(&mut self, opt: impl Into<Opt>) {
|
||||||
let Some(hovered) = self.hovered() else {
|
let Some(hovered) = self.hovered() else {
|
||||||
return self.active_mut().preview.reset();
|
return render!(self.active_mut().preview.reset());
|
||||||
};
|
};
|
||||||
|
|
||||||
let mime = if hovered.is_dir() {
|
let mime = if hovered.is_dir() {
|
||||||
|
|
@ -26,15 +26,14 @@ impl Manager {
|
||||||
} else if let Some(s) = self.mimetype.get(&hovered.url) {
|
} else if let Some(s) = self.mimetype.get(&hovered.url) {
|
||||||
s
|
s
|
||||||
} else {
|
} else {
|
||||||
return self.active_mut().preview.reset();
|
return render!(self.active_mut().preview.reset());
|
||||||
};
|
};
|
||||||
|
|
||||||
let Some(previewer) = PLUGIN.previewer(&hovered.url, mime) else {
|
let Some(previewer) = PLUGIN.previewer(&hovered.url, mime) else {
|
||||||
return self.active_mut().preview.reset();
|
return render!(self.active_mut().preview.reset());
|
||||||
};
|
};
|
||||||
|
|
||||||
let opt = opt.into() as Opt;
|
let opt = opt.into() as Opt;
|
||||||
isolate::seek_sync(&previewer.exec, hovered.clone(), opt.units);
|
isolate::seek_sync(&previewer.exec, hovered.clone(), opt.units);
|
||||||
false
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -4,12 +4,11 @@ use yazi_shared::event::Exec;
|
||||||
use crate::manager::Manager;
|
use crate::manager::Manager;
|
||||||
|
|
||||||
impl Manager {
|
impl Manager {
|
||||||
pub fn suspend(&mut self, _: &Exec) -> bool {
|
pub fn suspend(&mut self, _: &Exec) {
|
||||||
#[cfg(unix)]
|
#[cfg(unix)]
|
||||||
tokio::spawn(async move {
|
tokio::spawn(async move {
|
||||||
Scheduler::app_stop().await;
|
Scheduler::app_stop().await;
|
||||||
unsafe { libc::raise(libc::SIGTSTP) };
|
unsafe { libc::raise(libc::SIGTSTP) };
|
||||||
});
|
});
|
||||||
false
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
use yazi_shared::{event::Exec, fs::FilesOp};
|
use yazi_shared::{event::Exec, fs::FilesOp, render};
|
||||||
|
|
||||||
use crate::{folder::Folder, manager::Manager, tasks::Tasks};
|
use crate::{folder::Folder, manager::Manager, tasks::Tasks};
|
||||||
|
|
||||||
|
|
@ -13,51 +13,49 @@ impl TryFrom<&Exec> for Opt {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Manager {
|
impl Manager {
|
||||||
fn handle_read(&mut self, op: FilesOp) -> bool {
|
// TODO: refactor this
|
||||||
|
fn handle_read(&mut self, op: FilesOp) {
|
||||||
let url = op.url().clone();
|
let url = op.url().clone();
|
||||||
let cwd = self.cwd().to_owned();
|
let cwd = self.cwd().to_owned();
|
||||||
let hovered = self.hovered().map(|h| h.url());
|
let hovered = self.hovered().map(|h| h.url());
|
||||||
|
|
||||||
let mut b = if cwd == url {
|
if cwd == url {
|
||||||
self.current_mut().update(op)
|
render!(self.current_mut().update(op));
|
||||||
} else if matches!(self.parent(), Some(p) if p.cwd == url) {
|
} else if matches!(self.parent(), Some(p) if p.cwd == url) {
|
||||||
self.active_mut().parent.as_mut().unwrap().update(op)
|
render!(self.active_mut().parent.as_mut().unwrap().update(op));
|
||||||
} else if matches!(self.hovered(), Some(h) if h.url == url) {
|
} else if matches!(self.hovered(), Some(h) if h.url == url) {
|
||||||
self.active_mut().history.entry(url.clone()).or_insert_with(|| Folder::from(&url));
|
self.active_mut().history.entry(url.clone()).or_insert_with(|| Folder::from(&url));
|
||||||
self.active_mut().apply_files_attrs(true);
|
self.active_mut().apply_files_attrs(true);
|
||||||
self.active_mut().history.get_mut(&url).unwrap().update(op) | self.peek(true)
|
render!(self.active_mut().history.get_mut(&url).unwrap().update(op));
|
||||||
|
self.peek(true);
|
||||||
} else {
|
} else {
|
||||||
self.active_mut().history.entry(url.clone()).or_insert_with(|| Folder::from(&url)).update(op);
|
self.active_mut().history.entry(url.clone()).or_insert_with(|| Folder::from(&url)).update(op);
|
||||||
false
|
}
|
||||||
};
|
|
||||||
|
|
||||||
b |= self.active_mut().parent.as_mut().is_some_and(|p| p.hover(&cwd));
|
render!(self.active_mut().parent.as_mut().is_some_and(|p| p.hover(&cwd)));
|
||||||
b |= hovered.as_ref().is_some_and(|h| self.current_mut().hover(h));
|
render!(hovered.as_ref().is_some_and(|h| self.current_mut().hover(h)));
|
||||||
|
|
||||||
if hovered.as_ref() != self.hovered().map(|h| &h.url) {
|
if hovered.as_ref() != self.hovered().map(|h| &h.url) {
|
||||||
b |= self.hover(None);
|
self.hover(None);
|
||||||
}
|
}
|
||||||
b
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn handle_ioerr(&mut self, op: FilesOp) -> bool {
|
fn handle_ioerr(&mut self, op: FilesOp) {
|
||||||
let url = op.url();
|
let url = op.url();
|
||||||
let op = FilesOp::Full(url.clone(), vec![]);
|
let op = FilesOp::Full(url.clone(), vec![]);
|
||||||
|
|
||||||
if url == self.cwd() {
|
if url == self.cwd() {
|
||||||
self.current_mut().update(op);
|
self.current_mut().update(op);
|
||||||
self.active_mut().leave(());
|
self.active_mut().leave(());
|
||||||
true
|
render!();
|
||||||
} else if matches!(self.parent(), Some(p) if &p.cwd == url) {
|
} else if matches!(self.parent(), Some(p) if &p.cwd == url) {
|
||||||
self.active_mut().parent.as_mut().unwrap().update(op)
|
render!(self.active_mut().parent.as_mut().unwrap().update(op));
|
||||||
} else {
|
|
||||||
false
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn update_files(&mut self, opt: impl TryInto<Opt>, tasks: &Tasks) -> bool {
|
pub fn update_files(&mut self, opt: impl TryInto<Opt>, tasks: &Tasks) {
|
||||||
let Ok(opt) = opt.try_into() else {
|
let Ok(opt) = opt.try_into() else {
|
||||||
return false;
|
return;
|
||||||
};
|
};
|
||||||
let calc = !matches!(opt.op, FilesOp::Size(..) | FilesOp::IOErr(_) | FilesOp::Deleting(..));
|
let calc = !matches!(opt.op, FilesOp::Size(..) | FilesOp::IOErr(_) | FilesOp::Deleting(..));
|
||||||
|
|
||||||
|
|
@ -66,9 +64,8 @@ impl Manager {
|
||||||
ops.push(ops[0].chroot(u));
|
ops.push(ops[0].chroot(u));
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut b = false;
|
|
||||||
for op in ops {
|
for op in ops {
|
||||||
b |= match op {
|
match op {
|
||||||
FilesOp::IOErr(..) => self.handle_ioerr(op),
|
FilesOp::IOErr(..) => self.handle_ioerr(op),
|
||||||
_ => self.handle_read(op),
|
_ => self.handle_read(op),
|
||||||
};
|
};
|
||||||
|
|
@ -77,6 +74,5 @@ impl Manager {
|
||||||
if calc {
|
if calc {
|
||||||
tasks.preload_sorted(&self.current().files);
|
tasks.preload_sorted(&self.current().files);
|
||||||
}
|
}
|
||||||
b
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
|
|
||||||
use yazi_plugin::ValueSendable;
|
use yazi_plugin::ValueSendable;
|
||||||
use yazi_shared::{event::Exec, fs::Url};
|
use yazi_shared::{event::Exec, fs::Url, render};
|
||||||
|
|
||||||
use crate::{manager::Manager, tasks::Tasks};
|
use crate::{manager::Manager, tasks::Tasks};
|
||||||
|
|
||||||
|
|
@ -16,9 +16,9 @@ impl TryFrom<&Exec> for Opt {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Manager {
|
impl Manager {
|
||||||
pub fn update_mimetype(&mut self, opt: impl TryInto<Opt>, tasks: &Tasks) -> bool {
|
pub fn update_mimetype(&mut self, opt: impl TryInto<Opt>, tasks: &Tasks) {
|
||||||
let Ok(opt) = opt.try_into() else {
|
let Ok(opt) = opt.try_into() else {
|
||||||
return false;
|
return;
|
||||||
};
|
};
|
||||||
|
|
||||||
let linked = self.watcher.linked.read();
|
let linked = self.watcher.linked.read();
|
||||||
|
|
@ -38,7 +38,7 @@ impl Manager {
|
||||||
|
|
||||||
drop(linked);
|
drop(linked);
|
||||||
if updates.is_empty() {
|
if updates.is_empty() {
|
||||||
return false;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
let affected: Vec<_> = self
|
let affected: Vec<_> = self
|
||||||
|
|
@ -53,6 +53,6 @@ impl Manager {
|
||||||
self.peek(false);
|
self.peek(false);
|
||||||
|
|
||||||
tasks.preload_affected(&affected, &self.mimetype);
|
tasks.preload_affected(&affected, &self.mimetype);
|
||||||
true
|
render!();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
use bitflags::bitflags;
|
use bitflags::bitflags;
|
||||||
use yazi_shared::event::Exec;
|
use yazi_shared::{event::Exec, render};
|
||||||
|
|
||||||
use crate::tab::{Mode, Tab};
|
use crate::tab::{Mode, Tab};
|
||||||
|
|
||||||
|
|
@ -52,32 +52,32 @@ impl Tab {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn escape_search(&mut self) -> bool { self.search_stop() }
|
fn escape_search(&mut self) -> bool { self.search_stop() }
|
||||||
|
|
||||||
pub fn escape(&mut self, opt: impl Into<Opt>) -> bool {
|
pub fn escape(&mut self, opt: impl Into<Opt>) {
|
||||||
let opt = opt.into() as Opt;
|
let opt = opt.into() as Opt;
|
||||||
if opt.is_empty() {
|
if opt.is_empty() {
|
||||||
return self.escape_find()
|
return render!(
|
||||||
|| self.escape_visual()
|
self.escape_find()
|
||||||
|| self.escape_select()
|
|| self.escape_visual()
|
||||||
|| self.escape_filter()
|
|| self.escape_select()
|
||||||
|| self.escape_search();
|
|| self.escape_filter()
|
||||||
|
|| self.escape_search()
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut b = false;
|
|
||||||
if opt.contains(Opt::FIND) {
|
if opt.contains(Opt::FIND) {
|
||||||
b |= self.escape_find();
|
render!(self.escape_find());
|
||||||
}
|
}
|
||||||
if opt.contains(Opt::VISUAL) {
|
if opt.contains(Opt::VISUAL) {
|
||||||
b |= self.escape_visual();
|
render!(self.escape_visual());
|
||||||
}
|
}
|
||||||
if opt.contains(Opt::SELECT) {
|
if opt.contains(Opt::SELECT) {
|
||||||
b |= self.escape_select();
|
render!(self.escape_select());
|
||||||
}
|
}
|
||||||
if opt.contains(Opt::FILTER) {
|
if opt.contains(Opt::FILTER) {
|
||||||
b |= self.escape_filter();
|
render!(self.escape_filter());
|
||||||
}
|
}
|
||||||
if opt.contains(Opt::SEARCH) {
|
if opt.contains(Opt::SEARCH) {
|
||||||
b |= self.escape_search();
|
render!(self.escape_search());
|
||||||
}
|
}
|
||||||
b
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@ use std::time::Duration;
|
||||||
use tokio::pin;
|
use tokio::pin;
|
||||||
use tokio_stream::{wrappers::UnboundedReceiverStream, StreamExt};
|
use tokio_stream::{wrappers::UnboundedReceiverStream, StreamExt};
|
||||||
use yazi_config::popup::InputCfg;
|
use yazi_config::popup::InputCfg;
|
||||||
use yazi_shared::{emit, event::Exec, Debounce, InputError, Layer};
|
use yazi_shared::{emit, event::Exec, render, Debounce, InputError, Layer};
|
||||||
|
|
||||||
use crate::{folder::FilterCase, input::Input, tab::{Finder, Tab}};
|
use crate::{folder::FilterCase, input::Input, tab::{Finder, Tab}};
|
||||||
|
|
||||||
|
|
@ -54,20 +54,20 @@ impl Tab {
|
||||||
false
|
false
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn find_do<'a>(&mut self, opt: impl Into<Opt<'a>>) -> bool {
|
pub fn find_do<'a>(&mut self, opt: impl Into<Opt<'a>>) {
|
||||||
let opt = opt.into() as Opt;
|
let opt = opt.into() as Opt;
|
||||||
let Some(query) = opt.query else {
|
let Some(query) = opt.query else {
|
||||||
return false;
|
return;
|
||||||
};
|
};
|
||||||
if query.is_empty() {
|
if query.is_empty() {
|
||||||
return self.escape(super::escape::Opt::FIND);
|
return self.escape(super::escape::Opt::FIND);
|
||||||
}
|
}
|
||||||
|
|
||||||
let Ok(finder) = Finder::new(query, opt.case) else {
|
let Ok(finder) = Finder::new(query, opt.case) else {
|
||||||
return false;
|
return;
|
||||||
};
|
};
|
||||||
if matches!(&self.finder, Some(f) if f.filter == finder.filter) {
|
if matches!(&self.finder, Some(f) if f.filter == finder.filter) {
|
||||||
return false;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
let step = if opt.prev {
|
let step = if opt.prev {
|
||||||
|
|
@ -81,7 +81,7 @@ impl Tab {
|
||||||
}
|
}
|
||||||
|
|
||||||
self.finder = Some(finder);
|
self.finder = Some(finder);
|
||||||
true
|
render!();
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn find_arrow(&mut self, opt: impl Into<ArrowOpt>) -> bool {
|
pub fn find_arrow(&mut self, opt: impl Into<ArrowOpt>) -> bool {
|
||||||
|
|
|
||||||
|
|
@ -149,15 +149,9 @@ impl Tasks {
|
||||||
false
|
false
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn plugin_micro(&self, name: &str) -> bool {
|
pub fn plugin_micro(&self, name: &str) { self.scheduler.plugin_micro(name.to_owned()); }
|
||||||
self.scheduler.plugin_micro(name.to_owned());
|
|
||||||
false
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn plugin_macro(&self, name: &str) -> bool {
|
pub fn plugin_macro(&self, name: &str) { self.scheduler.plugin_macro(name.to_owned()); }
|
||||||
self.scheduler.plugin_macro(name.to_owned());
|
|
||||||
false
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn preload_paged(&self, paged: &[File], mimetype: &HashMap<Url, String>) {
|
pub fn preload_paged(&self, paged: &[File], mimetype: &HashMap<Url, String>) {
|
||||||
let mut single_tasks = Vec::with_capacity(paged.len());
|
let mut single_tasks = Vec::with_capacity(paged.len());
|
||||||
|
|
|
||||||
|
|
@ -25,8 +25,8 @@ impl<'a> Executor<'a> {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
let b = if cx.completion.visible {
|
if cx.completion.visible {
|
||||||
self.matches(Layer::Completion, key).or_else(|| self.matches(Layer::Input, key))
|
self.matches(Layer::Completion, key) || self.matches(Layer::Input, key)
|
||||||
} else if cx.help.visible {
|
} else if cx.help.visible {
|
||||||
self.matches(Layer::Help, key)
|
self.matches(Layer::Help, key)
|
||||||
} else if cx.input.visible {
|
} else if cx.input.visible {
|
||||||
|
|
@ -37,24 +37,24 @@ impl<'a> Executor<'a> {
|
||||||
self.matches(Layer::Tasks, key)
|
self.matches(Layer::Tasks, key)
|
||||||
} else {
|
} else {
|
||||||
self.matches(Layer::Manager, key)
|
self.matches(Layer::Manager, key)
|
||||||
};
|
}
|
||||||
b == Some(true)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn matches(&mut self, layer: Layer, key: Key) -> Option<bool> {
|
fn matches(&mut self, layer: Layer, key: Key) -> bool {
|
||||||
for Control { on, exec, .. } in KEYMAP.get(layer) {
|
for Control { on, exec, .. } in KEYMAP.get(layer) {
|
||||||
if on.is_empty() || on[0] != key {
|
if on.is_empty() || on[0] != key {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
return Some(if on.len() > 1 {
|
if on.len() > 1 {
|
||||||
self.app.cx.which.show(&key, layer)
|
self.app.cx.which.show(&key, layer);
|
||||||
} else {
|
} else {
|
||||||
self.dispatch(exec, layer)
|
self.dispatch(exec, layer);
|
||||||
});
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
None
|
false
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
|
|
@ -87,7 +87,7 @@ impl<'a> Executor<'a> {
|
||||||
on!(stop);
|
on!(stop);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn manager(&mut self, exec: &Exec) -> bool {
|
fn manager(&mut self, exec: &Exec) {
|
||||||
macro_rules! on {
|
macro_rules! on {
|
||||||
(MANAGER, $name:ident $(,$args:expr)*) => {
|
(MANAGER, $name:ident $(,$args:expr)*) => {
|
||||||
if exec.cmd == stringify!($name) {
|
if exec.cmd == stringify!($name) {
|
||||||
|
|
@ -175,7 +175,7 @@ impl<'a> Executor<'a> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn tasks(&mut self, exec: &Exec) -> bool {
|
fn tasks(&mut self, exec: &Exec) {
|
||||||
macro_rules! on {
|
macro_rules! on {
|
||||||
($name:ident) => {
|
($name:ident) => {
|
||||||
if exec.cmd == stringify!($name) {
|
if exec.cmd == stringify!($name) {
|
||||||
|
|
@ -202,7 +202,7 @@ impl<'a> Executor<'a> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn select(&mut self, exec: &Exec) -> bool {
|
fn select(&mut self, exec: &Exec) {
|
||||||
macro_rules! on {
|
macro_rules! on {
|
||||||
($name:ident) => {
|
($name:ident) => {
|
||||||
if exec.cmd == stringify!($name) {
|
if exec.cmd == stringify!($name) {
|
||||||
|
|
@ -221,7 +221,7 @@ impl<'a> Executor<'a> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn input(&mut self, exec: &Exec) -> bool {
|
fn input(&mut self, exec: &Exec) {
|
||||||
macro_rules! on {
|
macro_rules! on {
|
||||||
($name:ident) => {
|
($name:ident) => {
|
||||||
if exec.cmd == stringify!($name) {
|
if exec.cmd == stringify!($name) {
|
||||||
|
|
@ -276,7 +276,7 @@ impl<'a> Executor<'a> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn help(&mut self, exec: &Exec) -> bool {
|
fn help(&mut self, exec: &Exec) {
|
||||||
macro_rules! on {
|
macro_rules! on {
|
||||||
($name:ident) => {
|
($name:ident) => {
|
||||||
if exec.cmd == stringify!($name) {
|
if exec.cmd == stringify!($name) {
|
||||||
|
|
@ -295,7 +295,7 @@ impl<'a> Executor<'a> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn completion(&mut self, exec: &Exec) -> bool {
|
fn completion(&mut self, exec: &Exec) {
|
||||||
macro_rules! on {
|
macro_rules! on {
|
||||||
($name:ident) => {
|
($name:ident) => {
|
||||||
if exec.cmd == stringify!($name) {
|
if exec.cmd == stringify!($name) {
|
||||||
|
|
|
||||||
|
|
@ -7,4 +7,9 @@ macro_rules! render {
|
||||||
() => {
|
() => {
|
||||||
$crate::event::NEED_RENDER.store(true, std::sync::atomic::Ordering::Relaxed);
|
$crate::event::NEED_RENDER.store(true, std::sync::atomic::Ordering::Relaxed);
|
||||||
};
|
};
|
||||||
|
($expr:expr) => {
|
||||||
|
if $expr {
|
||||||
|
render!();
|
||||||
|
}
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue