From 19ebbd3df3dd67d6eb181df6822a10f9e578a157 Mon Sep 17 00:00:00 2001 From: sxyazi Date: Tue, 2 Jan 2024 01:46:12 +0800 Subject: [PATCH] .. --- yazi-core/src/input/commands/backward.rs | 2 +- yazi-core/src/manager/commands/close.rs | 4 ++-- yazi-core/src/manager/commands/open.rs | 2 +- yazi-core/src/manager/commands/peek.rs | 2 +- yazi-core/src/manager/commands/tab_close.rs | 8 ++++---- yazi-core/src/manager/commands/tab_create.rs | 8 ++++---- yazi-core/src/manager/commands/tab_swap.rs | 8 ++++---- yazi-core/src/manager/commands/tab_switch.rs | 8 ++++---- yazi-core/src/tab/commands/escape.rs | 4 +++- yazi-core/src/tab/commands/filter.rs | 13 ++++++------- yazi-core/src/tab/commands/find.rs | 3 +-- yazi-core/src/tab/commands/hidden.rs | 9 ++++----- yazi-core/src/tab/commands/jump.rs | 5 ++--- yazi-core/src/tab/commands/reveal.rs | 2 +- yazi-core/src/tab/commands/sort.rs | 4 ++-- yazi-core/src/tab/tab.rs | 18 ++++++++---------- yazi-fm/src/app/app.rs | 2 +- yazi-fm/src/executor.rs | 14 ++++++++------ yazi-fm/src/widgets/clear.rs | 2 +- 19 files changed, 58 insertions(+), 60 deletions(-) diff --git a/yazi-core/src/input/commands/backward.rs b/yazi-core/src/input/commands/backward.rs index 88e834a2..30d18af6 100644 --- a/yazi-core/src/input/commands/backward.rs +++ b/yazi-core/src/input/commands/backward.rs @@ -21,7 +21,7 @@ impl Input { } if prev != CharKind::Space { - return self.move_(-(snap.len() as isize)); + self.move_(-(snap.len() as isize)); } } } diff --git a/yazi-core/src/manager/commands/close.rs b/yazi-core/src/manager/commands/close.rs index 0c7dbb8b..53a7ffb9 100644 --- a/yazi-core/src/manager/commands/close.rs +++ b/yazi-core/src/manager/commands/close.rs @@ -1,11 +1,11 @@ -use yazi_shared::{event::Exec, render}; +use yazi_shared::event::Exec; use crate::{manager::Manager, tasks::Tasks}; impl Manager { pub fn close(&mut self, _: &Exec, tasks: &Tasks) { if self.tabs.len() > 1 { - return render!(self.tabs.close(self.tabs.idx)); + return self.tabs.close(self.tabs.idx); } self.quit((), tasks); } diff --git a/yazi-core/src/manager/commands/open.rs b/yazi-core/src/manager/commands/open.rs index b1da416e..a519d70c 100644 --- a/yazi-core/src/manager/commands/open.rs +++ b/yazi-core/src/manager/commands/open.rs @@ -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}, render, Layer, MIME_DIR}; +use yazi_shared::{emit, event::Exec, fs::{File, Url}, Layer, MIME_DIR}; use crate::{manager::Manager, select::Select, tasks::Tasks}; diff --git a/yazi-core/src/manager/commands/peek.rs b/yazi-core/src/manager/commands/peek.rs index c73e094d..92873393 100644 --- a/yazi-core/src/manager/commands/peek.rs +++ b/yazi-core/src/manager/commands/peek.rs @@ -67,7 +67,7 @@ impl Manager { if let Some(s) = self.mimetype.get(&hovered.url).cloned() { self.active_mut().preview.go(hovered, &s, opt.force); } else { - return render!(self.active_mut().preview.reset()); + render!(self.active_mut().preview.reset()); } } } diff --git a/yazi-core/src/manager/commands/tab_close.rs b/yazi-core/src/manager/commands/tab_close.rs index eb4083ca..356b4dc7 100644 --- a/yazi-core/src/manager/commands/tab_close.rs +++ b/yazi-core/src/manager/commands/tab_close.rs @@ -1,4 +1,4 @@ -use yazi_shared::event::Exec; +use yazi_shared::{event::Exec, render}; use crate::manager::Tabs; @@ -17,12 +17,12 @@ impl From for Opt { } impl Tabs { - pub fn close(&mut self, opt: impl Into) -> bool { + pub fn close(&mut self, opt: impl Into) { let opt = opt.into() as Opt; let len = self.items.len(); if len < 2 || opt.idx >= len { - return false; + return; } self.items.remove(opt.idx); @@ -30,6 +30,6 @@ impl Tabs { self.set_idx(self.absolute(1)); } - true + render!(); } } diff --git a/yazi-core/src/manager/commands/tab_create.rs b/yazi-core/src/manager/commands/tab_create.rs index 8fa89d39..556dabe1 100644 --- a/yazi-core/src/manager/commands/tab_create.rs +++ b/yazi-core/src/manager/commands/tab_create.rs @@ -1,4 +1,4 @@ -use yazi_shared::{event::Exec, fs::Url}; +use yazi_shared::{event::Exec, fs::Url, render}; use crate::{manager::Tabs, tab::Tab}; @@ -21,9 +21,9 @@ impl From<&Exec> for Opt { } impl Tabs { - pub fn create(&mut self, opt: impl Into) -> bool { + pub fn create(&mut self, opt: impl Into) { if self.items.len() >= MAX_TABS { - return false; + return; } let opt = opt.into() as Opt; @@ -35,6 +35,6 @@ impl Tabs { self.items.insert(self.idx + 1, tab); self.set_idx(self.idx + 1); - true + render!(); } } diff --git a/yazi-core/src/manager/commands/tab_swap.rs b/yazi-core/src/manager/commands/tab_swap.rs index e7f02425..aae8300c 100644 --- a/yazi-core/src/manager/commands/tab_swap.rs +++ b/yazi-core/src/manager/commands/tab_swap.rs @@ -1,4 +1,4 @@ -use yazi_shared::event::Exec; +use yazi_shared::{event::Exec, render}; use crate::manager::Tabs; @@ -13,14 +13,14 @@ impl From<&Exec> for Opt { } impl Tabs { - pub fn swap(&mut self, opt: impl Into) -> bool { + pub fn swap(&mut self, opt: impl Into) { let idx = self.absolute(opt.into().step); if idx == self.idx { - return false; + return; } self.items.swap(self.idx, idx); self.set_idx(idx); - true + render!(); } } diff --git a/yazi-core/src/manager/commands/tab_switch.rs b/yazi-core/src/manager/commands/tab_switch.rs index 4eeb41fe..7cd134a6 100644 --- a/yazi-core/src/manager/commands/tab_switch.rs +++ b/yazi-core/src/manager/commands/tab_switch.rs @@ -1,4 +1,4 @@ -use yazi_shared::event::Exec; +use yazi_shared::{event::Exec, render}; use crate::manager::Tabs; @@ -17,7 +17,7 @@ impl From<&Exec> for Opt { } impl Tabs { - pub fn switch(&mut self, opt: impl Into) -> bool { + pub fn switch(&mut self, opt: impl Into) { let opt = opt.into() as Opt; let idx = if opt.relative { (self.idx as isize + opt.step).rem_euclid(self.items.len() as isize) as usize @@ -26,10 +26,10 @@ impl Tabs { }; if idx == self.idx || idx >= self.items.len() { - return false; + return; } self.set_idx(idx); - true + render!(); } } diff --git a/yazi-core/src/tab/commands/escape.rs b/yazi-core/src/tab/commands/escape.rs index 950f2b2d..ba3ac6e6 100644 --- a/yazi-core/src/tab/commands/escape.rs +++ b/yazi-core/src/tab/commands/escape.rs @@ -46,7 +46,9 @@ impl Tab { #[inline] fn escape_filter(&mut self) -> bool { - self.filter_do(super::filter::Opt { query: "", ..Default::default() }) + // TODO: render + todo!(); + // self.filter_do(super::filter::Opt { query: "", ..Default::default() }) } #[inline] diff --git a/yazi-core/src/tab/commands/filter.rs b/yazi-core/src/tab/commands/filter.rs index c471b40f..d0e79241 100644 --- a/yazi-core/src/tab/commands/filter.rs +++ b/yazi-core/src/tab/commands/filter.rs @@ -3,7 +3,7 @@ use std::time::Duration; use tokio::pin; use tokio_stream::{wrappers::UnboundedReceiverStream, StreamExt}; 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::{Filter, FilterCase}, input::Input, manager::Manager, tab::Tab}; @@ -20,7 +20,7 @@ impl<'a> From<&'a Exec> for Opt<'a> { } impl Tab { - pub fn filter<'a>(&mut self, opt: impl Into>) -> bool { + pub fn filter<'a>(&mut self, opt: impl Into>) { let opt = opt.into() as Opt; tokio::spawn(async move { let rx = Input::_show(InputCfg::filter()); @@ -38,10 +38,9 @@ impl Tab { )); } }); - false } - pub fn filter_do<'a>(&mut self, opt: impl Into>) -> bool { + pub fn filter_do<'a>(&mut self, opt: impl Into>) { let opt = opt.into() as Opt; let filter = if opt.query.is_empty() { @@ -49,17 +48,17 @@ impl Tab { } else if let Ok(f) = Filter::new(opt.query, opt.case) { Some(f) } else { - return false; + return; }; let hovered = self.current.hovered().map(|f| f.url()); if !self.current.files.set_filter(filter) { - return false; + return; } if self.current.repos(hovered) { Manager::_hover(None); } - true + render!(); } } diff --git a/yazi-core/src/tab/commands/find.rs b/yazi-core/src/tab/commands/find.rs index 6dcfeb22..f865c6d2 100644 --- a/yazi-core/src/tab/commands/find.rs +++ b/yazi-core/src/tab/commands/find.rs @@ -32,7 +32,7 @@ impl From<&Exec> for ArrowOpt { } impl Tab { - pub fn find<'a>(&mut self, opt: impl Into>) -> bool { + pub fn find<'a>(&mut self, opt: impl Into>) { let opt = opt.into() as Opt; tokio::spawn(async move { let rx = Input::_show(InputCfg::find(opt.prev)); @@ -51,7 +51,6 @@ impl Tab { )); } }); - false } pub fn find_do<'a>(&mut self, opt: impl Into>) { diff --git a/yazi-core/src/tab/commands/hidden.rs b/yazi-core/src/tab/commands/hidden.rs index f0e1dbc2..8761865a 100644 --- a/yazi-core/src/tab/commands/hidden.rs +++ b/yazi-core/src/tab/commands/hidden.rs @@ -1,4 +1,4 @@ -use yazi_shared::{event::Exec, render}; +use yazi_shared::event::Exec; use crate::{manager::Manager, tab::Tab}; @@ -9,9 +9,8 @@ impl Tab { Some(b"hide") => false, _ => !self.conf.show_hidden, }; - if self.apply_files_attrs(false) { - Manager::_hover(None); - render!(); - } + + self.apply_files_attrs(false); + Manager::_hover(None); } } diff --git a/yazi-core/src/tab/commands/jump.rs b/yazi-core/src/tab/commands/jump.rs index 8a2913d9..e1876753 100644 --- a/yazi-core/src/tab/commands/jump.rs +++ b/yazi-core/src/tab/commands/jump.rs @@ -28,10 +28,10 @@ impl From<&Exec> for Opt { } impl Tab { - pub fn jump(&self, opt: impl Into) -> bool { + pub fn jump(&self, opt: impl Into) { let opt = opt.into() as Opt; if opt.type_ == OptType::None { - return false; + return; } let cwd = self.current.cwd.clone(); @@ -56,6 +56,5 @@ impl Tab { Tab::_cd(&url) } }); - false } } diff --git a/yazi-core/src/tab/commands/reveal.rs b/yazi-core/src/tab/commands/reveal.rs index 46045fb7..ff0e51ab 100644 --- a/yazi-core/src/tab/commands/reveal.rs +++ b/yazi-core/src/tab/commands/reveal.rs @@ -1,4 +1,4 @@ -use yazi_shared::{emit, event::Exec, fs::{expand_path, File, FilesOp, Url}, render, Layer}; +use yazi_shared::{emit, event::Exec, fs::{expand_path, File, FilesOp, Url}, Layer}; use crate::{manager::Manager, tab::Tab}; diff --git a/yazi-core/src/tab/commands/sort.rs b/yazi-core/src/tab/commands/sort.rs index 7def15ce..56a53292 100644 --- a/yazi-core/src/tab/commands/sort.rs +++ b/yazi-core/src/tab/commands/sort.rs @@ -6,7 +6,7 @@ use yazi_shared::event::Exec; use crate::tab::Tab; impl Tab { - pub fn sort(&mut self, e: &Exec) -> bool { + pub fn sort(&mut self, e: &Exec) { if let Some(by) = e.args.first() { self.conf.sort_by = SortBy::from_str(by).unwrap_or_default(); } @@ -14,6 +14,6 @@ impl Tab { self.conf.sort_reverse = e.named.contains_key("reverse"); self.conf.sort_dir_first = e.named.contains_key("dir-first"); - self.apply_files_attrs(false) + self.apply_files_attrs(false); } } diff --git a/yazi-core/src/tab/tab.rs b/yazi-core/src/tab/tab.rs index c493ca38..15ee5534 100644 --- a/yazi-core/src/tab/tab.rs +++ b/yazi-core/src/tab/tab.rs @@ -2,7 +2,7 @@ use std::{borrow::Cow, collections::BTreeMap}; use anyhow::Result; use tokio::task::JoinHandle; -use yazi_shared::fs::{File, Url}; +use yazi_shared::{fs::{File, Url}, render}; use super::{Backstack, Config, Finder, Mode, Preview}; use crate::folder::Folder; @@ -72,30 +72,28 @@ impl Tab { self.history.remove(url).unwrap_or_else(|| Folder::from(url)) } - pub fn apply_files_attrs(&mut self, just_preview: bool) -> bool { + pub fn apply_files_attrs(&mut self, just_preview: bool) { let apply = |f: &mut Folder| { let hovered = f.hovered().map(|h| h.url()); f.files.set_show_hidden(self.conf.show_hidden); f.files.set_sorter(self.conf.sorter()); - f.files.catchup_revision() | f.repos(hovered) + render!(f.files.catchup_revision()); + render!(f.repos(hovered)); }; - let mut b = false; if let Some(f) = self.current.hovered().filter(|h| h.is_dir()).and_then(|h| self.history.get_mut(&h.url)) { - b |= apply(f); + apply(f); } if just_preview { - return b; + return; } - b |= apply(&mut self.current); + apply(&mut self.current); if let Some(parent) = self.parent.as_mut() { - b |= apply(parent); + apply(parent); } - - b } } diff --git a/yazi-fm/src/app/app.rs b/yazi-fm/src/app/app.rs index 1a4af334..47e840c1 100644 --- a/yazi-fm/src/app/app.rs +++ b/yazi-fm/src/app/app.rs @@ -2,7 +2,7 @@ use anyhow::{Ok, Result}; use crossterm::event::KeyEvent; use yazi_config::{keymap::Key, ARGS}; use yazi_core::input::InputMode; -use yazi_shared::{emit, event::{Event, Exec}, render, term::Term, Layer}; +use yazi_shared::{event::{Event, Exec}, render, term::Term, Layer}; use crate::{lives::Lives, Ctx, Executor, Logs, Panic, Signals}; diff --git a/yazi-fm/src/executor.rs b/yazi-fm/src/executor.rs index dd1b8bce..a28c2534 100644 --- a/yazi-fm/src/executor.rs +++ b/yazi-fm/src/executor.rs @@ -18,12 +18,14 @@ impl<'a> Executor<'a> { if cx.which.visible { return cx.which.press(key); } - if cx.help.visible && cx.help.type_(&key) { - return true; - } - if cx.input.visible && cx.input.type_(&key) { - return true; - } + // TODO: render + // if cx.help.visible && cx.help.type_(&key) { + // return true; + // } + // TODO: render + // if cx.input.visible && cx.input.type_(&key) { + // return true; + // } if cx.completion.visible { self.matches(Layer::Completion, key) || self.matches(Layer::Input, key) diff --git a/yazi-fm/src/widgets/clear.rs b/yazi-fm/src/widgets/clear.rs index fb73b7d4..013cd5c5 100644 --- a/yazi-fm/src/widgets/clear.rs +++ b/yazi-fm/src/widgets/clear.rs @@ -4,7 +4,7 @@ use ratatui::{buffer::Buffer, layout::Rect, widgets::Widget}; use yazi_adaptor::ADAPTOR; use yazi_config::LAYOUT; -use crate::renderer::COLLISION; +use crate::root::COLLISION; pub(crate) struct Clear;