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
a54af2e66f
commit
faebd78219
18 changed files with 73 additions and 74 deletions
|
|
@ -1,4 +1,4 @@
|
|||
use yazi_shared::event::Exec;
|
||||
use yazi_shared::{event::Exec, render};
|
||||
|
||||
use crate::completion::Completion;
|
||||
|
||||
|
|
@ -13,10 +13,10 @@ impl From<&Exec> for Opt {
|
|||
}
|
||||
|
||||
impl Completion {
|
||||
fn next(&mut self, step: usize) -> bool {
|
||||
fn next(&mut self, step: usize) {
|
||||
let len = self.cands.len();
|
||||
if len == 0 {
|
||||
return false;
|
||||
return;
|
||||
}
|
||||
|
||||
let old = self.cursor;
|
||||
|
|
@ -27,10 +27,10 @@ impl Completion {
|
|||
self.offset = len.saturating_sub(limit).min(self.offset + self.cursor - old);
|
||||
}
|
||||
|
||||
old != self.cursor
|
||||
render!(old != self.cursor);
|
||||
}
|
||||
|
||||
fn prev(&mut self, step: usize) -> bool {
|
||||
fn prev(&mut self, step: usize) {
|
||||
let old = self.cursor;
|
||||
self.cursor = self.cursor.saturating_sub(step);
|
||||
|
||||
|
|
@ -38,11 +38,15 @@ impl Completion {
|
|||
self.offset = self.offset.saturating_sub(old - self.cursor);
|
||||
}
|
||||
|
||||
old != self.cursor
|
||||
render!(old != self.cursor);
|
||||
}
|
||||
|
||||
pub fn arrow(&mut self, opt: impl Into<Opt>) -> bool {
|
||||
pub fn arrow(&mut self, opt: impl Into<Opt>) {
|
||||
let opt = opt.into() as Opt;
|
||||
if opt.step > 0 { self.next(opt.step as usize) } else { self.prev(opt.step.unsigned_abs()) }
|
||||
if opt.step > 0 {
|
||||
self.next(opt.step as usize);
|
||||
} else {
|
||||
self.prev(opt.step.unsigned_abs());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
use yazi_shared::{emit, event::Exec, Layer};
|
||||
use yazi_shared::{emit, event::Exec, render, Layer};
|
||||
|
||||
use crate::{completion::Completion, input::Input};
|
||||
|
||||
|
|
@ -16,7 +16,7 @@ impl Completion {
|
|||
emit!(Call(Exec::call("close", vec![]).vec(), Layer::Completion));
|
||||
}
|
||||
|
||||
pub fn close(&mut self, opt: impl Into<Opt>) -> bool {
|
||||
pub fn close(&mut self, opt: impl Into<Opt>) {
|
||||
let opt = opt.into() as Opt;
|
||||
if opt.submit {
|
||||
Input::_complete(self.selected(), self.ticket);
|
||||
|
|
@ -24,6 +24,6 @@ impl Completion {
|
|||
|
||||
self.caches.clear();
|
||||
self.visible = false;
|
||||
true
|
||||
render!();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,15 +1,15 @@
|
|||
use yazi_config::popup::{Offset, Origin, Position};
|
||||
use yazi_shared::event::Exec;
|
||||
use yazi_shared::{event::Exec, render};
|
||||
|
||||
use crate::{help::Help, input::Input};
|
||||
|
||||
impl Help {
|
||||
pub fn filter(&mut self, _: &Exec) -> bool {
|
||||
pub fn filter(&mut self, _: &Exec) {
|
||||
let mut input = Input::default();
|
||||
input.position = Position::new(Origin::BottomLeft, Offset::line());
|
||||
|
||||
self.in_filter = Some(input);
|
||||
self.filter_apply();
|
||||
true
|
||||
render!();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ impl From<&Exec> for Opt {
|
|||
}
|
||||
|
||||
impl Manager {
|
||||
pub fn create(&self, opt: impl Into<Opt>) -> bool {
|
||||
pub fn create(&self, opt: impl Into<Opt>) {
|
||||
let opt = opt.into() as Opt;
|
||||
let cwd = self.cwd().to_owned();
|
||||
tokio::spawn(async move {
|
||||
|
|
@ -47,6 +47,5 @@ impl Manager {
|
|||
}
|
||||
Ok::<(), anyhow::Error>(())
|
||||
});
|
||||
false
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,9 +14,13 @@ impl From<&Exec> for Opt {
|
|||
}
|
||||
|
||||
impl Manager {
|
||||
pub fn link(&mut self, opt: impl Into<Opt>, tasks: &Tasks) -> bool {
|
||||
let opt = opt.into() as Opt;
|
||||
pub fn link(&mut self, opt: impl Into<Opt>, tasks: &Tasks) {
|
||||
let (cut, ref src) = self.yanked;
|
||||
!cut && tasks.file_link(src, self.cwd(), opt.relative, opt.force)
|
||||
if cut {
|
||||
return;
|
||||
}
|
||||
|
||||
let opt = opt.into() as Opt;
|
||||
tasks.file_link(src, self.cwd(), opt.relative, opt.force);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ use tokio::fs;
|
|||
use tracing::error;
|
||||
use yazi_config::{popup::SelectCfg, ARGS, OPEN};
|
||||
use yazi_plugin::isolate;
|
||||
use yazi_shared::{emit, event::Exec, fs::{File, Url}, Layer, MIME_DIR};
|
||||
use yazi_shared::{emit, event::Exec, fs::{File, Url}, render, Layer, MIME_DIR};
|
||||
|
||||
use crate::{manager::Manager, select::Select, tasks::Tasks};
|
||||
|
||||
|
|
@ -20,12 +20,12 @@ impl From<&Exec> for Opt {
|
|||
}
|
||||
|
||||
impl Manager {
|
||||
pub fn open(&mut self, opt: impl Into<Opt>, tasks: &Tasks) -> bool {
|
||||
pub fn open(&mut self, opt: impl Into<Opt>, tasks: &Tasks) {
|
||||
let selected = self.selected();
|
||||
if selected.is_empty() {
|
||||
return false;
|
||||
return;
|
||||
} else if Self::quit_with_selected(&selected) {
|
||||
return false;
|
||||
return;
|
||||
}
|
||||
|
||||
let (mut done, mut todo) = (Vec::with_capacity(selected.len()), vec![]);
|
||||
|
|
@ -53,7 +53,6 @@ impl Manager {
|
|||
|
||||
Self::_open_do(opt.interactive, done);
|
||||
});
|
||||
false
|
||||
}
|
||||
|
||||
#[inline]
|
||||
|
|
@ -64,10 +63,10 @@ impl Manager {
|
|||
));
|
||||
}
|
||||
|
||||
pub fn open_do(&mut self, opt: impl Into<Opt>, tasks: &Tasks) -> bool {
|
||||
pub fn open_do(&mut self, opt: impl Into<Opt>, tasks: &Tasks) {
|
||||
let opt = opt.into() as Opt;
|
||||
let Some(targets) = opt.targets else {
|
||||
return false;
|
||||
return;
|
||||
};
|
||||
|
||||
let targets: Vec<_> = targets
|
||||
|
|
@ -76,15 +75,15 @@ impl Manager {
|
|||
.collect();
|
||||
|
||||
if targets.is_empty() {
|
||||
return false;
|
||||
return;
|
||||
} else if !opt.interactive {
|
||||
tasks.file_open(&targets);
|
||||
return false;
|
||||
return;
|
||||
}
|
||||
|
||||
let openers: Vec<_> = OPEN.common_openers(&targets).into_iter().cloned().collect();
|
||||
if openers.is_empty() {
|
||||
return false;
|
||||
return;
|
||||
}
|
||||
|
||||
let urls = targets.into_iter().map(|(u, _)| u).collect();
|
||||
|
|
@ -94,7 +93,6 @@ impl Manager {
|
|||
Tasks::_open(urls, openers[choice].clone());
|
||||
}
|
||||
});
|
||||
false
|
||||
}
|
||||
|
||||
fn quit_with_selected(selected: &[&File]) -> bool {
|
||||
|
|
|
|||
|
|
@ -14,15 +14,15 @@ impl From<&Exec> for Opt {
|
|||
}
|
||||
|
||||
impl Manager {
|
||||
pub fn paste(&mut self, opt: impl Into<Opt>, tasks: &Tasks) -> bool {
|
||||
pub fn paste(&mut self, opt: impl Into<Opt>, tasks: &Tasks) {
|
||||
let dest = self.cwd();
|
||||
let (cut, ref src) = self.yanked;
|
||||
|
||||
let opt = opt.into() as Opt;
|
||||
if cut {
|
||||
tasks.file_cut(src, dest, opt.force)
|
||||
tasks.file_cut(src, dest, opt.force);
|
||||
} else {
|
||||
tasks.file_copy(src, dest, opt.force, opt.follow)
|
||||
tasks.file_copy(src, dest, opt.force);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,9 +17,9 @@ impl From<&Exec> for Opt {
|
|||
}
|
||||
|
||||
impl Manager {
|
||||
pub fn remove(&mut self, opt: impl Into<Opt>, tasks: &Tasks) -> bool {
|
||||
pub fn remove(&mut self, opt: impl Into<Opt>, tasks: &Tasks) {
|
||||
let opt = opt.into() as Opt;
|
||||
let targets = self.selected().into_iter().map(|f| f.url()).collect();
|
||||
tasks.file_remove(targets, opt.force, opt.permanently)
|
||||
tasks.file_remove(targets, opt.force, opt.permanently);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -29,13 +29,13 @@ impl Manager {
|
|||
Ok(Self::_hover(Some(new)))
|
||||
}
|
||||
|
||||
pub fn rename(&self, opt: impl Into<Opt>) -> bool {
|
||||
pub fn rename(&self, opt: impl Into<Opt>) {
|
||||
if self.active().in_selecting() {
|
||||
return self.bulk_rename();
|
||||
}
|
||||
|
||||
let Some(hovered) = self.hovered().map(|h| h.url()) else {
|
||||
return false;
|
||||
return;
|
||||
};
|
||||
|
||||
let opt = opt.into() as Opt;
|
||||
|
|
@ -60,10 +60,9 @@ impl Manager {
|
|||
}
|
||||
};
|
||||
});
|
||||
false
|
||||
}
|
||||
|
||||
fn bulk_rename(&self) -> bool {
|
||||
fn bulk_rename(&self) {
|
||||
let old: Vec<_> = self.selected().into_iter().map(|f| &f.url).collect();
|
||||
|
||||
let root = max_common_root(&old);
|
||||
|
|
@ -104,8 +103,6 @@ impl Manager {
|
|||
let new: Vec<_> = fs::read_to_string(&tmp).await?.lines().map(PathBuf::from).collect();
|
||||
Self::bulk_rename_do(root, old, new).await
|
||||
});
|
||||
|
||||
false
|
||||
}
|
||||
|
||||
async fn bulk_rename_do(root: PathBuf, old: Vec<PathBuf>, new: Vec<PathBuf>) -> Result<()> {
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
use yazi_shared::event::Exec;
|
||||
use yazi_shared::{event::Exec, render};
|
||||
|
||||
use crate::manager::Manager;
|
||||
|
||||
|
|
@ -11,11 +11,11 @@ impl From<&Exec> for Opt {
|
|||
}
|
||||
|
||||
impl Manager {
|
||||
pub fn yank(&mut self, opt: impl Into<Opt>) -> bool {
|
||||
pub fn yank(&mut self, opt: impl Into<Opt>) {
|
||||
let opt = opt.into() as Opt;
|
||||
|
||||
self.yanked.0 = opt.cut;
|
||||
self.yanked.1 = self.selected().into_iter().map(|f| f.url()).collect();
|
||||
true
|
||||
render!();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ impl<'a> From<&'a Exec> for Opt<'a> {
|
|||
}
|
||||
|
||||
impl Tab {
|
||||
pub fn copy<'a>(&self, opt: impl Into<Opt<'a>>) -> bool {
|
||||
pub fn copy<'a>(&self, opt: impl Into<Opt<'a>>) {
|
||||
let opt = opt.into() as Opt;
|
||||
|
||||
let mut s = OsString::new();
|
||||
|
|
@ -24,7 +24,7 @@ impl Tab {
|
|||
"dirname" => f.url.parent().map_or(OsStr::new(""), |p| p.as_os_str()),
|
||||
"filename" => f.name().unwrap_or(OsStr::new("")),
|
||||
"name_without_ext" => f.stem().unwrap_or(OsStr::new("")),
|
||||
_ => return false,
|
||||
_ => return,
|
||||
});
|
||||
if it.peek().is_some() {
|
||||
s.push("\n");
|
||||
|
|
@ -32,6 +32,5 @@ impl Tab {
|
|||
}
|
||||
|
||||
futures::executor::block_on(CLIPBOARD.set(s));
|
||||
false
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -50,7 +50,11 @@ impl Tab {
|
|||
}
|
||||
|
||||
#[inline]
|
||||
fn escape_search(&mut self) -> bool { self.search_stop() }
|
||||
fn escape_search(&mut self) -> bool {
|
||||
self.search_stop();
|
||||
// TODO: render
|
||||
false
|
||||
}
|
||||
|
||||
pub fn escape(&mut self, opt: impl Into<Opt>) {
|
||||
let opt = opt.into() as Opt;
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
use yazi_shared::event::Exec;
|
||||
use yazi_shared::{event::Exec, render};
|
||||
|
||||
use crate::{manager::Manager, tab::Tab};
|
||||
|
||||
impl Tab {
|
||||
pub fn hidden(&mut self, e: &Exec) -> bool {
|
||||
pub fn hidden(&mut self, e: &Exec) {
|
||||
self.conf.show_hidden = match e.args.first().map(|s| s.as_bytes()) {
|
||||
Some(b"show") => true,
|
||||
Some(b"hide") => false,
|
||||
|
|
@ -11,8 +11,7 @@ impl Tab {
|
|||
};
|
||||
if self.apply_files_attrs(false) {
|
||||
Manager::_hover(None);
|
||||
return true;
|
||||
render!();
|
||||
}
|
||||
false
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,16 +1,16 @@
|
|||
use yazi_shared::event::Exec;
|
||||
use yazi_shared::{event::Exec, render};
|
||||
|
||||
use crate::tab::Tab;
|
||||
|
||||
impl Tab {
|
||||
pub fn linemode(&mut self, e: &Exec) -> bool {
|
||||
self.conf.patch(|c| {
|
||||
pub fn linemode(&mut self, e: &Exec) {
|
||||
render!(self.conf.patch(|c| {
|
||||
let Some(mode) = e.args.first() else {
|
||||
return;
|
||||
};
|
||||
if !mode.is_empty() && mode.len() <= 20 {
|
||||
c.linemode = mode.to_owned();
|
||||
}
|
||||
})
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ use tokio::pin;
|
|||
use tokio_stream::{wrappers::UnboundedReceiverStream, StreamExt};
|
||||
use yazi_config::popup::InputCfg;
|
||||
use yazi_plugin::external;
|
||||
use yazi_shared::{event::Exec, fs::FilesOp};
|
||||
use yazi_shared::{event::Exec, fs::FilesOp, render};
|
||||
|
||||
use crate::{input::Input, manager::Manager, tab::Tab};
|
||||
|
||||
|
|
@ -33,7 +33,7 @@ impl From<&Exec> for Opt {
|
|||
}
|
||||
|
||||
impl Tab {
|
||||
pub fn search(&mut self, opt: impl Into<Opt>) -> bool {
|
||||
pub fn search(&mut self, opt: impl Into<Opt>) {
|
||||
let opt = opt.into() as Opt;
|
||||
if opt.type_ == OptType::None {
|
||||
return self.search_stop();
|
||||
|
|
@ -70,10 +70,11 @@ impl Tab {
|
|||
}
|
||||
Ok(())
|
||||
}));
|
||||
true
|
||||
|
||||
render!();
|
||||
}
|
||||
|
||||
pub(super) fn search_stop(&mut self) -> bool {
|
||||
pub(super) fn search_stop(&mut self) {
|
||||
if let Some(handle) = self.search.take() {
|
||||
handle.abort();
|
||||
}
|
||||
|
|
@ -82,6 +83,5 @@ impl Tab {
|
|||
drop(mem::replace(&mut self.current, rep));
|
||||
Manager::_refresh();
|
||||
}
|
||||
false
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ impl<'a> From<&'a Exec> for Opt {
|
|||
}
|
||||
|
||||
impl Tab {
|
||||
pub fn shell(&self, opt: impl Into<Opt>) -> bool {
|
||||
pub fn shell(&self, opt: impl Into<Opt>) {
|
||||
let mut opt = opt.into() as Opt;
|
||||
let selected: Vec<_> = self.selected().into_iter().map(|f| f.url()).collect();
|
||||
|
||||
|
|
@ -42,6 +42,5 @@ impl Tab {
|
|||
spread: true,
|
||||
});
|
||||
});
|
||||
false
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -77,7 +77,7 @@ impl Tasks {
|
|||
false
|
||||
}
|
||||
|
||||
pub fn file_cut(&self, src: &HashSet<Url>, dest: &Url, force: bool) -> bool {
|
||||
pub fn file_cut(&self, src: &HashSet<Url>, dest: &Url, force: bool) {
|
||||
for u in src {
|
||||
let to = dest.join(u.file_name().unwrap());
|
||||
if force && u == &to {
|
||||
|
|
@ -86,10 +86,9 @@ impl Tasks {
|
|||
self.scheduler.file_cut(u.clone(), to, force);
|
||||
}
|
||||
}
|
||||
false
|
||||
}
|
||||
|
||||
pub fn file_copy(&self, src: &HashSet<Url>, dest: &Url, force: bool, follow: bool) -> bool {
|
||||
pub fn file_copy(&self, src: &HashSet<Url>, dest: &Url, force: bool) {
|
||||
for u in src {
|
||||
let to = dest.join(u.file_name().unwrap());
|
||||
if force && u == &to {
|
||||
|
|
@ -98,10 +97,9 @@ impl Tasks {
|
|||
self.scheduler.file_copy(u.clone(), to, force, follow);
|
||||
}
|
||||
}
|
||||
false
|
||||
}
|
||||
|
||||
pub fn file_link(&self, src: &HashSet<Url>, dest: &Url, relative: bool, force: bool) -> bool {
|
||||
pub fn file_link(&self, src: &HashSet<Url>, dest: &Url, relative: bool, force: bool) {
|
||||
for u in src {
|
||||
let to = dest.join(u.file_name().unwrap());
|
||||
if force && *u == to {
|
||||
|
|
@ -110,10 +108,9 @@ impl Tasks {
|
|||
self.scheduler.file_link(u.clone(), to, relative, force);
|
||||
}
|
||||
}
|
||||
false
|
||||
}
|
||||
|
||||
pub fn file_remove(&self, targets: Vec<Url>, force: bool, permanently: bool) -> bool {
|
||||
pub fn file_remove(&self, targets: Vec<Url>, force: bool, permanently: bool) {
|
||||
if force {
|
||||
for u in targets {
|
||||
if permanently {
|
||||
|
|
@ -122,7 +119,7 @@ impl Tasks {
|
|||
self.scheduler.file_trash(u);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
return;
|
||||
}
|
||||
|
||||
let scheduler = self.scheduler.clone();
|
||||
|
|
@ -146,7 +143,6 @@ impl Tasks {
|
|||
}
|
||||
}
|
||||
});
|
||||
false
|
||||
}
|
||||
|
||||
pub fn plugin_micro(&self, name: &str) { self.scheduler.plugin_micro(name.to_owned()); }
|
||||
|
|
|
|||
|
|
@ -289,7 +289,7 @@ impl<'a> Executor<'a> {
|
|||
|
||||
match exec.cmd.as_str() {
|
||||
"close" => self.app.cx.help.toggle(Layer::Help),
|
||||
_ => false,
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -309,7 +309,7 @@ impl<'a> Executor<'a> {
|
|||
|
||||
match exec.cmd.as_str() {
|
||||
"help" => self.app.cx.help.toggle(Layer::Completion),
|
||||
_ => false,
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue