diff --git a/yazi-core/src/completion/commands/show.rs b/yazi-core/src/completion/commands/show.rs index 5454b289..609cebba 100644 --- a/yazi-core/src/completion/commands/show.rs +++ b/yazi-core/src/completion/commands/show.rs @@ -1,6 +1,6 @@ use std::{mem, ops::ControlFlow}; -use yazi_shared::event::Exec; +use yazi_shared::{event::Exec, render}; use crate::completion::Completion; @@ -54,28 +54,28 @@ impl Completion { prefixed.into_iter().map(ToOwned::to_owned).collect() } - pub fn show<'a>(&mut self, opt: impl Into>) -> bool { + pub fn show<'a>(&mut self, opt: impl Into>) { let opt = opt.into() as Opt; if self.ticket != opt.ticket { - return false; + return; } if !opt.cache.is_empty() { self.caches.insert(opt.cache_name.to_owned(), opt.cache.clone()); } let Some(cache) = self.caches.get(opt.cache_name) else { - return false; + return; }; self.ticket = opt.ticket; self.cands = Self::match_candidates(opt.word, cache); if self.cands.is_empty() { - return mem::replace(&mut self.visible, false); + return render!(mem::replace(&mut self.visible, false)); } self.offset = 0; self.cursor = 0; self.visible = true; - true + render!(); } } diff --git a/yazi-core/src/completion/commands/trigger.rs b/yazi-core/src/completion/commands/trigger.rs index 14f4980b..85180bce 100644 --- a/yazi-core/src/completion/commands/trigger.rs +++ b/yazi-core/src/completion/commands/trigger.rs @@ -1,7 +1,7 @@ use std::{mem, path::{MAIN_SEPARATOR, MAIN_SEPARATOR_STR}}; use tokio::fs; -use yazi_shared::{emit, event::Exec, Layer}; +use yazi_shared::{emit, event::Exec, render, Layer}; use crate::completion::Completion; @@ -28,10 +28,10 @@ impl Completion { )); } - pub fn trigger<'a>(&mut self, opt: impl Into>) -> bool { + pub fn trigger<'a>(&mut self, opt: impl Into>) { let opt = opt.into() as Opt; if opt.ticket < self.ticket { - return false; + return; } self.ticket = opt.ticket; @@ -76,7 +76,7 @@ impl Completion { Ok::<(), anyhow::Error>(()) }); - mem::replace(&mut self.visible, false) + render!(mem::replace(&mut self.visible, false)); } #[inline] diff --git a/yazi-core/src/help/commands/arrow.rs b/yazi-core/src/help/commands/arrow.rs index b78dbfbb..df51e04b 100644 --- a/yazi-core/src/help/commands/arrow.rs +++ b/yazi-core/src/help/commands/arrow.rs @@ -1,4 +1,4 @@ -use yazi_shared::event::Exec; +use yazi_shared::{event::Exec, render}; use crate::help::Help; @@ -17,19 +17,23 @@ impl From for Opt { impl Help { #[inline] - pub fn arrow(&mut self, opt: impl Into) -> bool { + pub fn arrow(&mut self, opt: impl Into) { let max = self.bindings.len().saturating_sub(1); self.offset = self.offset.min(max); self.cursor = self.cursor.min(max); 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()); + } } - fn next(&mut self, step: usize) -> bool { + fn next(&mut self, step: usize) { let len = self.bindings.len(); if len == 0 { - return false; + return; } let old = self.cursor; @@ -40,10 +44,10 @@ impl Help { 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); @@ -51,6 +55,6 @@ impl Help { self.offset = self.offset.saturating_sub(old - self.cursor); } - old != self.cursor + render!(old != self.cursor); } } diff --git a/yazi-core/src/help/commands/escape.rs b/yazi-core/src/help/commands/escape.rs index d0569676..b85b4845 100644 --- a/yazi-core/src/help/commands/escape.rs +++ b/yazi-core/src/help/commands/escape.rs @@ -1,15 +1,15 @@ -use yazi_shared::event::Exec; +use yazi_shared::{event::Exec, render}; use crate::help::Help; impl Help { - pub fn escape(&mut self, _: &Exec) -> bool { - if self.in_filter.is_some() { - self.in_filter = None; - self.filter_apply(); - true - } else { - self.toggle(self.layer) + pub fn escape(&mut self, _: &Exec) { + if self.in_filter.is_none() { + return self.toggle(self.layer); } + + self.in_filter = None; + self.filter_apply(); + render!(); } } diff --git a/yazi-core/src/help/help.rs b/yazi-core/src/help/help.rs index 455a2882..5028529c 100644 --- a/yazi-core/src/help/help.rs +++ b/yazi-core/src/help/help.rs @@ -1,7 +1,7 @@ use crossterm::event::KeyCode; use unicode_width::UnicodeWidthStr; use yazi_config::{keymap::{Control, Key}, KEYMAP}; -use yazi_shared::{term::Term, Layer}; +use yazi_shared::{render, term::Term, Layer}; use super::HELP_MARGIN; use crate::input::Input; @@ -24,7 +24,7 @@ impl Help { #[inline] pub fn limit() -> usize { Term::size().rows.saturating_sub(HELP_MARGIN) as usize } - pub fn toggle(&mut self, layer: Layer) -> bool { + pub fn toggle(&mut self, layer: Layer) { self.visible = !self.visible; self.layer = layer; @@ -34,7 +34,7 @@ impl Help { self.offset = 0; self.cursor = 0; - true + render!(); } pub(super) fn filter_apply(&mut self) -> bool { @@ -54,24 +54,23 @@ impl Help { true } - pub fn type_(&mut self, key: &Key) -> bool { + pub fn type_(&mut self, key: &Key) { let Some(input) = &mut self.in_filter else { - return false; + return; }; if key.is_enter() { self.in_filter = None; - return true; + return render!(); } - let b = match &key { + match &key { Key { code: KeyCode::Backspace, shift: false, ctrl: false, alt: false } => { input.backspace(false) } _ => input.type_(key), - }; - - if b { self.filter_apply() } else { false } + } + self.filter_apply(); } } diff --git a/yazi-core/src/input/commands/backspace.rs b/yazi-core/src/input/commands/backspace.rs index 1bb89a86..51d17539 100644 --- a/yazi-core/src/input/commands/backspace.rs +++ b/yazi-core/src/input/commands/backspace.rs @@ -1,4 +1,4 @@ -use yazi_shared::event::Exec; +use yazi_shared::{event::Exec, render}; use crate::input::Input; @@ -14,14 +14,14 @@ impl From for Opt { } impl Input { - pub fn backspace(&mut self, opt: impl Into) -> bool { + pub fn backspace(&mut self, opt: impl Into) { let opt = opt.into() as Opt; let snap = self.snaps.current_mut(); if !opt.under && snap.cursor < 1 { - return false; + return; } else if opt.under && snap.cursor >= snap.value.len() { - return false; + return; } if opt.under { @@ -33,6 +33,6 @@ impl Input { } self.flush_value(); - true + render!(); } } diff --git a/yazi-core/src/input/commands/backward.rs b/yazi-core/src/input/commands/backward.rs index 4131ad02..88e834a2 100644 --- a/yazi-core/src/input/commands/backward.rs +++ b/yazi-core/src/input/commands/backward.rs @@ -3,7 +3,7 @@ use yazi_shared::{event::Exec, CharKind}; use crate::input::Input; impl Input { - pub fn backward(&mut self, _: &Exec) -> bool { + pub fn backward(&mut self, _: &Exec) { let snap = self.snap(); if snap.cursor == 0 { return self.move_(0); @@ -23,6 +23,5 @@ impl Input { if prev != CharKind::Space { return self.move_(-(snap.len() as isize)); } - false } } diff --git a/yazi-core/src/input/commands/close.rs b/yazi-core/src/input/commands/close.rs index 594258af..1224c156 100644 --- a/yazi-core/src/input/commands/close.rs +++ b/yazi-core/src/input/commands/close.rs @@ -1,4 +1,4 @@ -use yazi_shared::{event::Exec, InputError}; +use yazi_shared::{event::Exec, render, InputError}; use crate::{completion::Completion, input::Input}; @@ -14,7 +14,7 @@ impl From for Opt { } impl Input { - pub fn close(&mut self, opt: impl Into) -> bool { + pub fn close(&mut self, opt: impl Into) { let opt = opt.into() as Opt; if self.completion { @@ -28,6 +28,6 @@ impl Input { self.ticket = self.ticket.wrapping_add(1); self.visible = false; - true + render!(); } } diff --git a/yazi-core/src/input/commands/complete.rs b/yazi-core/src/input/commands/complete.rs index 50752f8e..11cabf91 100644 --- a/yazi-core/src/input/commands/complete.rs +++ b/yazi-core/src/input/commands/complete.rs @@ -1,6 +1,6 @@ use std::path::MAIN_SEPARATOR; -use yazi_shared::{emit, event::Exec, Layer}; +use yazi_shared::{emit, event::Exec, render, Layer}; use crate::input::Input; @@ -27,10 +27,10 @@ impl Input { )); } - pub fn complete<'a>(&mut self, opt: impl Into>) -> bool { + pub fn complete<'a>(&mut self, opt: impl Into>) { let opt = opt.into() as Opt; if self.ticket != opt.ticket { - return false; + return; } let [before, after] = self.partition(); @@ -42,7 +42,7 @@ impl Input { let snap = self.snaps.current_mut(); if new == snap.value { - return false; + return; } let delta = new.chars().count() as isize - snap.value.chars().count() as isize; @@ -50,6 +50,6 @@ impl Input { self.move_(delta); self.flush_value(); - true + render!(); } } diff --git a/yazi-core/src/input/commands/delete.rs b/yazi-core/src/input/commands/delete.rs index a46f6585..c60a99fd 100644 --- a/yazi-core/src/input/commands/delete.rs +++ b/yazi-core/src/input/commands/delete.rs @@ -14,22 +14,24 @@ impl From<&Exec> for Opt { } impl Input { - pub fn delete(&mut self, opt: impl Into) -> bool { + pub fn delete(&mut self, opt: impl Into) { let opt = opt.into() as Opt; match self.snap().op { InputOp::None => { self.snap_mut().op = InputOp::Delete(opt.cut, opt.insert, self.snap().cursor); - false } InputOp::Select(start) => { self.snap_mut().op = InputOp::Delete(opt.cut, opt.insert, start); - return self.handle_op(self.snap().cursor, true).then(|| self.move_(0)).is_some(); + // TODO: render + todo!(); + // return self.handle_op(self.snap().cursor, true).then(|| + // self.move_(0)).is_some(); } InputOp::Delete(..) => { self.snap_mut().op = InputOp::Delete(opt.cut, opt.insert, 0); - return self.move_(self.snap().len() as isize); + self.move_(self.snap().len() as isize); } - _ => false, + _ => {} } } } diff --git a/yazi-core/src/input/commands/escape.rs b/yazi-core/src/input/commands/escape.rs index 4f09955f..59d4dc62 100644 --- a/yazi-core/src/input/commands/escape.rs +++ b/yazi-core/src/input/commands/escape.rs @@ -1,4 +1,4 @@ -use yazi_shared::event::Exec; +use yazi_shared::{event::Exec, render}; use crate::{completion::Completion, input::{op::InputOp, Input, InputMode}}; @@ -12,7 +12,7 @@ impl From<()> for Opt { } impl Input { - pub fn escape(&mut self, _: impl Into) -> bool { + pub fn escape(&mut self, _: impl Into) { let snap = self.snap_mut(); match snap.mode { InputMode::Normal if snap.op == InputOp::None => { @@ -31,6 +31,6 @@ impl Input { } } self.snaps.tag(self.limit()); - true + render!(); } } diff --git a/yazi-core/src/input/commands/forward.rs b/yazi-core/src/input/commands/forward.rs index fc07a27d..bbaff4ab 100644 --- a/yazi-core/src/input/commands/forward.rs +++ b/yazi-core/src/input/commands/forward.rs @@ -11,7 +11,7 @@ impl From<&Exec> for Opt { } impl Input { - pub fn forward(&mut self, opt: impl Into) -> bool { + pub fn forward(&mut self, opt: impl Into) { let opt = opt.into() as Opt; let snap = self.snap(); diff --git a/yazi-core/src/input/commands/insert.rs b/yazi-core/src/input/commands/insert.rs index db4d6c6e..d95226fa 100644 --- a/yazi-core/src/input/commands/insert.rs +++ b/yazi-core/src/input/commands/insert.rs @@ -1,4 +1,4 @@ -use yazi_shared::event::Exec; +use yazi_shared::{event::Exec, render}; use crate::input::{op::InputOp, Input, InputMode}; @@ -14,13 +14,13 @@ impl From for Opt { } impl Input { - pub fn insert(&mut self, opt: impl Into) -> bool { + pub fn insert(&mut self, opt: impl Into) { let snap = self.snap_mut(); if snap.mode == InputMode::Normal { snap.op = InputOp::None; snap.mode = InputMode::Insert; } else { - return false; + return; } let opt = opt.into() as Opt; @@ -28,6 +28,6 @@ impl Input { self.move_(1); } - true + render!(); } } diff --git a/yazi-core/src/input/commands/kill.rs b/yazi-core/src/input/commands/kill.rs index 759f8d22..db1af71c 100644 --- a/yazi-core/src/input/commands/kill.rs +++ b/yazi-core/src/input/commands/kill.rs @@ -1,6 +1,6 @@ use std::ops::RangeBounds; -use yazi_shared::{event::Exec, CharKind}; +use yazi_shared::{event::Exec, render, CharKind}; use crate::input::Input; @@ -15,7 +15,7 @@ impl<'a> From<&'a Exec> for Opt<'a> { } impl Input { - fn kill_range(&mut self, range: impl RangeBounds) -> bool { + fn kill_range(&mut self, range: impl RangeBounds) { let snap = self.snap_mut(); snap.cursor = match range.start_bound() { std::ops::Bound::Included(i) => *i, @@ -23,12 +23,12 @@ impl Input { std::ops::Bound::Unbounded => 0, }; if snap.value.drain(range).next().is_none() { - return false; + return; } self.move_(0); self.flush_value(); - true + render!(); } /// Searches for a word boundary and returns the movement in the cursor @@ -66,7 +66,7 @@ impl Input { spaces + count_characters(input.skip(spaces)) } - pub fn kill<'a>(&mut self, opt: impl Into>) -> bool { + pub fn kill<'a>(&mut self, opt: impl Into>) { let opt = opt.into() as Opt; let snap = self.snap_mut(); @@ -89,7 +89,7 @@ impl Input { let end = start + Self::find_word_boundary(snap.value[start..].chars()); self.kill_range(start..end) } - _ => false, + _ => {} } } } diff --git a/yazi-core/src/input/commands/move_.rs b/yazi-core/src/input/commands/move_.rs index f2b20a3e..c056010e 100644 --- a/yazi-core/src/input/commands/move_.rs +++ b/yazi-core/src/input/commands/move_.rs @@ -1,5 +1,5 @@ use unicode_width::UnicodeWidthStr; -use yazi_shared::event::Exec; +use yazi_shared::{event::Exec, render}; use crate::input::{op::InputOp, snap::InputSnap, Input}; @@ -21,22 +21,22 @@ impl From for Opt { } impl Input { - pub fn move_(&mut self, opt: impl Into) -> bool { + pub fn move_(&mut self, opt: impl Into) { let opt = opt.into() as Opt; let snap = self.snap(); if opt.in_operating && snap.op == InputOp::None { - return false; + return; } - let b = self.handle_op( + render!(self.handle_op( if opt.step <= 0 { snap.cursor.saturating_sub(opt.step.unsigned_abs()) } else { snap.count().min(snap.cursor + opt.step as usize) }, false, - ); + )); let (limit, snap) = (self.limit(), self.snap_mut()); if snap.offset > snap.cursor { @@ -51,7 +51,5 @@ impl Input { snap.offset = snap.cursor - InputSnap::find_window(&s, 0, limit).end.saturating_sub(delta); } } - - b } } diff --git a/yazi-core/src/input/commands/paste.rs b/yazi-core/src/input/commands/paste.rs index 18027875..59879910 100644 --- a/yazi-core/src/input/commands/paste.rs +++ b/yazi-core/src/input/commands/paste.rs @@ -1,4 +1,4 @@ -use yazi_shared::event::Exec; +use yazi_shared::{event::Exec, render}; use crate::{input::{op::InputOp, Input}, CLIPBOARD}; @@ -11,7 +11,7 @@ impl From<&Exec> for Opt { } impl Input { - pub fn paste(&mut self, opt: impl Into) -> bool { + pub fn paste(&mut self, opt: impl Into) { if let Some(start) = self.snap().op.start() { self.snap_mut().op = InputOp::Delete(false, false, start); self.handle_op(self.snap().cursor, true); @@ -19,13 +19,13 @@ impl Input { let s = futures::executor::block_on(CLIPBOARD.get()); if s.is_empty() { - return false; + return; } let opt = opt.into() as Opt; self.insert(!opt.before); self.type_str(&s.to_string_lossy()); self.escape(()); - true + render!(); } } diff --git a/yazi-core/src/input/commands/redo.rs b/yazi-core/src/input/commands/redo.rs index 135238e3..3ca7ca1c 100644 --- a/yazi-core/src/input/commands/redo.rs +++ b/yazi-core/src/input/commands/redo.rs @@ -1,7 +1,9 @@ -use yazi_shared::event::Exec; +use yazi_shared::{event::Exec, render}; use crate::input::Input; impl Input { - pub fn redo(&mut self, _: &Exec) -> bool { self.snaps.redo() } + pub fn redo(&mut self, _: &Exec) { + render!(self.snaps.redo()); + } } diff --git a/yazi-core/src/input/commands/show.rs b/yazi-core/src/input/commands/show.rs index ba9f74b9..ce2a44b7 100644 --- a/yazi-core/src/input/commands/show.rs +++ b/yazi-core/src/input/commands/show.rs @@ -1,7 +1,7 @@ use anyhow::anyhow; use tokio::sync::mpsc; use yazi_config::popup::InputCfg; -use yazi_shared::{emit, event::Exec, InputError, Layer}; +use yazi_shared::{emit, event::Exec, render, InputError, Layer}; use crate::input::Input; @@ -25,9 +25,9 @@ impl Input { rx } - pub fn show(&mut self, opt: impl TryInto) -> bool { + pub fn show(&mut self, opt: impl TryInto) { let Ok(opt) = opt.try_into() else { - return false; + return; }; self.close(false); @@ -45,6 +45,6 @@ impl Input { // Reset snaps self.snaps.reset(opt.cfg.value, self.limit()); - true + render!(); } } diff --git a/yazi-core/src/input/commands/type_.rs b/yazi-core/src/input/commands/type_.rs index e693a825..306f847e 100644 --- a/yazi-core/src/input/commands/type_.rs +++ b/yazi-core/src/input/commands/type_.rs @@ -1,5 +1,5 @@ use yazi_config::keymap::Key; -use yazi_shared::event::Exec; +use yazi_shared::{event::Exec, render}; use crate::input::{Input, InputMode}; @@ -10,15 +10,14 @@ impl From<&Exec> for Opt { } impl Input { - pub fn type_(&mut self, key: &Key) -> bool { + pub fn type_(&mut self, key: &Key) { if self.mode() != InputMode::Insert { - return false; + return; } if let Some(c) = key.plain() { let mut bits = [0; 4]; - return self.type_str(c.encode_utf8(&mut bits)); + render!(self.type_str(c.encode_utf8(&mut bits))); } - false } } diff --git a/yazi-core/src/input/commands/undo.rs b/yazi-core/src/input/commands/undo.rs index 8ba4b729..e0001c9f 100644 --- a/yazi-core/src/input/commands/undo.rs +++ b/yazi-core/src/input/commands/undo.rs @@ -1,15 +1,15 @@ -use yazi_shared::event::Exec; +use yazi_shared::{event::Exec, render}; use crate::input::{Input, InputMode}; impl Input { - pub fn undo(&mut self, _: &Exec) -> bool { + pub fn undo(&mut self, _: &Exec) { if !self.snaps.undo() { - return false; + return; } if self.snap().mode == InputMode::Insert { self.escape(()); } - true + render!(); } } diff --git a/yazi-core/src/input/commands/visual.rs b/yazi-core/src/input/commands/visual.rs index 67ba3fcb..bffdf6cd 100644 --- a/yazi-core/src/input/commands/visual.rs +++ b/yazi-core/src/input/commands/visual.rs @@ -1,18 +1,18 @@ -use yazi_shared::event::Exec; +use yazi_shared::{event::Exec, render}; use crate::input::{op::InputOp, Input, InputMode}; impl Input { #[inline] - pub fn visual(&mut self, _: &Exec) -> bool { + pub fn visual(&mut self, _: &Exec) { let snap = self.snap_mut(); if snap.mode != InputMode::Normal { - return false; + return; } else if snap.value.is_empty() { - return false; + return; } snap.op = InputOp::Select(snap.cursor); - true + render!(); } } diff --git a/yazi-core/src/input/commands/yank.rs b/yazi-core/src/input/commands/yank.rs index 14ee9914..3cea620f 100644 --- a/yazi-core/src/input/commands/yank.rs +++ b/yazi-core/src/input/commands/yank.rs @@ -3,22 +3,23 @@ use yazi_shared::event::Exec; use crate::input::{op::InputOp, Input}; impl Input { - pub fn yank(&mut self, _: &Exec) -> bool { + pub fn yank(&mut self, _: &Exec) { match self.snap().op { InputOp::None => { self.snap_mut().op = InputOp::Yank(self.snap().cursor); - false } InputOp::Select(start) => { self.snap_mut().op = InputOp::Yank(start); - return self.handle_op(self.snap().cursor, true).then(|| self.move_(0)).is_some(); + // TODO: render + todo!(); + // return self.handle_op(self.snap().cursor, true).then(|| + // self.move_(0)).is_some(); } InputOp::Yank(_) => { self.snap_mut().op = InputOp::Yank(0); self.move_(self.snap().len() as isize); - false } - _ => false, + _ => {} } } } diff --git a/yazi-core/src/select/commands/arrow.rs b/yazi-core/src/select/commands/arrow.rs index 66f51fa2..7948d965 100644 --- a/yazi-core/src/select/commands/arrow.rs +++ b/yazi-core/src/select/commands/arrow.rs @@ -1,4 +1,4 @@ -use yazi_shared::event::Exec; +use yazi_shared::{event::Exec, render}; use crate::select::Select; @@ -13,10 +13,10 @@ impl From<&Exec> for Opt { } impl Select { - fn next(&mut self, step: usize) -> bool { + fn next(&mut self, step: usize) { let len = self.items.len(); if len == 0 { - return false; + return; } let old = self.cursor; @@ -27,10 +27,10 @@ impl Select { 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,10 +38,10 @@ impl Select { self.offset = self.offset.saturating_sub(old - self.cursor); } - old != self.cursor + render!(old != self.cursor); } - pub fn arrow(&mut self, opt: impl Into) -> bool { + pub fn arrow(&mut self, opt: impl Into) { let opt = opt.into() as Opt; if opt.step > 0 { self.next(opt.step as usize) } else { self.prev(opt.step.unsigned_abs()) } } diff --git a/yazi-core/src/select/commands/close.rs b/yazi-core/src/select/commands/close.rs index 5977cc29..bdf0eb68 100644 --- a/yazi-core/src/select/commands/close.rs +++ b/yazi-core/src/select/commands/close.rs @@ -1,5 +1,5 @@ use anyhow::anyhow; -use yazi_shared::event::Exec; +use yazi_shared::{event::Exec, render}; use crate::select::Select; @@ -15,7 +15,7 @@ impl From for Opt { } impl Select { - pub fn close(&mut self, opt: impl Into) -> bool { + pub fn close(&mut self, opt: impl Into) { let opt = opt.into() as Opt; if let Some(cb) = self.callback.take() { _ = cb.send(if opt.submit { Ok(self.cursor) } else { Err(anyhow!("canceled")) }); @@ -24,6 +24,6 @@ impl Select { self.cursor = 0; self.offset = 0; self.visible = false; - true + render!(); } } diff --git a/yazi-core/src/select/commands/show.rs b/yazi-core/src/select/commands/show.rs index 5abf8d6d..617a209f 100644 --- a/yazi-core/src/select/commands/show.rs +++ b/yazi-core/src/select/commands/show.rs @@ -1,7 +1,7 @@ use anyhow::{anyhow, Result}; use tokio::sync::oneshot; use yazi_config::popup::SelectCfg; -use yazi_shared::{emit, event::Exec, term::Term, Layer}; +use yazi_shared::{emit, event::Exec, render, term::Term, Layer}; use crate::select::Select; @@ -25,9 +25,9 @@ impl Select { rx.await.unwrap_or_else(|_| Term::goodbye(|| false)) } - pub fn show(&mut self, opt: impl TryInto) -> bool { + pub fn show(&mut self, opt: impl TryInto) { let Ok(opt) = opt.try_into() else { - return false; + return; }; self.close(false); @@ -37,6 +37,6 @@ impl Select { self.callback = Some(opt.tx); self.visible = true; - true + render!(); } } diff --git a/yazi-core/src/tab/commands/arrow.rs b/yazi-core/src/tab/commands/arrow.rs index 098c7f53..37c6f492 100644 --- a/yazi-core/src/tab/commands/arrow.rs +++ b/yazi-core/src/tab/commands/arrow.rs @@ -1,4 +1,4 @@ -use yazi_shared::event::Exec; +use yazi_shared::{event::Exec, render}; use crate::{manager::Manager, tab::Tab, Step}; @@ -20,7 +20,7 @@ where } impl Tab { - pub fn arrow(&mut self, opt: impl Into) -> bool { + pub fn arrow(&mut self, opt: impl Into) { let opt = opt.into() as Opt; let ok = if opt.step.is_positive() { self.current.next(opt.step) @@ -28,7 +28,7 @@ impl Tab { self.current.prev(opt.step) }; if !ok { - return false; + return; } // Visual selection @@ -42,6 +42,6 @@ impl Tab { } Manager::_hover(None); - true + render!(); } } diff --git a/yazi-core/src/tab/commands/backstack.rs b/yazi-core/src/tab/commands/backstack.rs index 0ddab3f5..7bd9cad1 100644 --- a/yazi-core/src/tab/commands/backstack.rs +++ b/yazi-core/src/tab/commands/backstack.rs @@ -11,17 +11,15 @@ impl From<&Exec> for Opt { } impl Tab { - pub fn back(&mut self, _: impl Into) -> bool { + pub fn back(&mut self, _: impl Into) { if let Some(url) = self.backstack.shift_backward().cloned() { self.cd(url); } - false } - pub fn forward(&mut self, _: impl Into) -> bool { + pub fn forward(&mut self, _: impl Into) { if let Some(url) = self.backstack.shift_forward().cloned() { self.cd(url); } - false } } diff --git a/yazi-core/src/tab/commands/cd.rs b/yazi-core/src/tab/commands/cd.rs index dc173f69..38b1b550 100644 --- a/yazi-core/src/tab/commands/cd.rs +++ b/yazi-core/src/tab/commands/cd.rs @@ -3,7 +3,7 @@ use std::{mem, time::Duration}; use tokio::{fs, pin}; use tokio_stream::{wrappers::UnboundedReceiverStream, StreamExt}; use yazi_config::popup::InputCfg; -use yazi_shared::{emit, event::Exec, fs::{expand_path, Url}, Debounce, InputError, Layer}; +use yazi_shared::{emit, event::Exec, fs::{expand_path, Url}, render, Debounce, InputError, Layer}; use crate::{completion::Completion, input::Input, manager::Manager, tab::Tab}; @@ -32,14 +32,14 @@ impl Tab { emit!(Call(Exec::call("cd", vec![target.to_string()]).vec(), Layer::Manager)); } - pub fn cd(&mut self, opt: impl Into) -> bool { + pub fn cd(&mut self, opt: impl Into) { let opt = opt.into() as Opt; if opt.interactive { return self.cd_interactive(); } if self.current.cwd == opt.target { - return false; + return; } // Take parent to history @@ -65,10 +65,10 @@ impl Tab { } Manager::_refresh(); - true + render!(); } - fn cd_interactive(&mut self) -> bool { + fn cd_interactive(&mut self) { tokio::spawn(async move { let rx = Input::_show(InputCfg::cd()); @@ -96,6 +96,5 @@ impl Tab { } } }); - false } } diff --git a/yazi-core/src/tab/commands/enter.rs b/yazi-core/src/tab/commands/enter.rs index a8a04e2b..e84da7e3 100644 --- a/yazi-core/src/tab/commands/enter.rs +++ b/yazi-core/src/tab/commands/enter.rs @@ -1,6 +1,6 @@ use std::mem; -use yazi_shared::event::Exec; +use yazi_shared::{event::Exec, render}; use crate::{manager::Manager, tab::Tab}; @@ -13,9 +13,9 @@ impl From<&Exec> for Opt { } impl Tab { - pub fn enter(&mut self, _: impl Into) -> bool { + pub fn enter(&mut self, _: impl Into) { let Some(hovered) = self.current.hovered().filter(|h| h.is_dir()).map(|h| h.url()) else { - return false; + return; }; // Current @@ -35,6 +35,6 @@ impl Tab { self.backstack.push(hovered); Manager::_refresh(); - true + render!(); } } diff --git a/yazi-core/src/tab/commands/escape.rs b/yazi-core/src/tab/commands/escape.rs index 043a38b2..8ebe15ce 100644 --- a/yazi-core/src/tab/commands/escape.rs +++ b/yazi-core/src/tab/commands/escape.rs @@ -42,7 +42,7 @@ impl Tab { } #[inline] - fn escape_select(&mut self) -> bool { self.select_all(Some(false)) } + fn escape_select(&mut self) -> bool { self.current.files.select_all(None) } #[inline] fn escape_filter(&mut self) -> bool { diff --git a/yazi-core/src/tab/commands/find.rs b/yazi-core/src/tab/commands/find.rs index 6db158a8..6dcfeb22 100644 --- a/yazi-core/src/tab/commands/find.rs +++ b/yazi-core/src/tab/commands/find.rs @@ -84,18 +84,16 @@ impl Tab { render!(); } - pub fn find_arrow(&mut self, opt: impl Into) -> bool { + pub fn find_arrow(&mut self, opt: impl Into) { let Some(finder) = &mut self.finder else { - return false; + return; }; - let b = finder.catchup(&self.current.files); - let step = if opt.into().prev { - finder.prev(&self.current.files, self.current.cursor, false) + render!(finder.catchup(&self.current.files)); + if opt.into().prev { + finder.prev(&self.current.files, self.current.cursor, false).map(|s| self.arrow(s)); } else { - finder.next(&self.current.files, self.current.cursor, false) - }; - - b | step.is_some_and(|s| self.arrow(s)) + finder.next(&self.current.files, self.current.cursor, false).map(|s| self.arrow(s)); + } } } diff --git a/yazi-core/src/tab/commands/leave.rs b/yazi-core/src/tab/commands/leave.rs index 04769e1f..226a18fa 100644 --- a/yazi-core/src/tab/commands/leave.rs +++ b/yazi-core/src/tab/commands/leave.rs @@ -1,6 +1,6 @@ use std::mem; -use yazi_shared::event::Exec; +use yazi_shared::{event::Exec, render}; use crate::{manager::Manager, tab::Tab}; @@ -13,7 +13,7 @@ impl From<&Exec> for Opt { } impl Tab { - pub fn leave(&mut self, _: impl Into) -> bool { + pub fn leave(&mut self, _: impl Into) { let current = self .current .hovered() @@ -22,7 +22,7 @@ impl Tab { .or_else(|| self.current.cwd.parent_url()); let Some(current) = current else { - return false; + return; }; // Parent @@ -44,6 +44,6 @@ impl Tab { self.backstack.push(current); Manager::_refresh(); - true + render!(); } } diff --git a/yazi-core/src/tab/commands/preview.rs b/yazi-core/src/tab/commands/preview.rs index a23ae3c2..291e327d 100644 --- a/yazi-core/src/tab/commands/preview.rs +++ b/yazi-core/src/tab/commands/preview.rs @@ -1,6 +1,6 @@ use anyhow::anyhow; use yazi_plugin::utils::PreviewLock; -use yazi_shared::event::Exec; +use yazi_shared::{event::Exec, render}; use crate::tab::Tab; @@ -17,20 +17,20 @@ impl TryFrom<&Exec> for Opt { } impl Tab { - pub fn preview(&mut self, opt: impl TryInto) -> bool { + pub fn preview(&mut self, opt: impl TryInto) { let Some(hovered) = self.current.hovered().map(|h| &h.url) else { - return self.preview.reset(); + return render!(self.preview.reset()); }; let Ok(opt) = opt.try_into() else { - return false; + return; }; if hovered != &opt.lock.url { - return false; + return; } self.preview.lock = Some(opt.lock); - true + render!(); } } diff --git a/yazi-core/src/tab/commands/reveal.rs b/yazi-core/src/tab/commands/reveal.rs index f75832a2..46045fb7 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}, Layer}; +use yazi_shared::{emit, event::Exec, fs::{expand_path, File, FilesOp, Url}, render, Layer}; use crate::{manager::Manager, tab::Tab}; @@ -26,16 +26,15 @@ impl Tab { emit!(Call(Exec::call("reveal", vec![target.to_string()]).vec(), Layer::Manager)); } - pub fn reveal(&mut self, opt: impl Into) -> bool { + pub fn reveal(&mut self, opt: impl Into) { let opt = opt.into() as Opt; let Some(parent) = opt.target.parent_url() else { - return false; + return; }; - let b = self.cd(parent.clone()); + self.cd(parent.clone()); FilesOp::Creating(parent, vec![File::from_dummy(opt.target.clone())]).emit(); Manager::_hover(Some(opt.target)); - b } } diff --git a/yazi-core/src/tab/commands/select.rs b/yazi-core/src/tab/commands/select.rs index eb18b091..328432d1 100644 --- a/yazi-core/src/tab/commands/select.rs +++ b/yazi-core/src/tab/commands/select.rs @@ -1,4 +1,4 @@ -use yazi_shared::event::Exec; +use yazi_shared::{event::Exec, render}; use crate::tab::Tab; @@ -22,14 +22,13 @@ impl From> for Opt { } impl Tab { - pub fn select(&mut self, opt: impl Into) -> bool { + pub fn select(&mut self, opt: impl Into) { if let Some(u) = self.current.hovered().map(|h| h.url()) { - return self.current.files.select(&u, opt.into().state); + render!(self.current.files.select(&u, opt.into().state)); } - false } - pub fn select_all(&mut self, opt: impl Into) -> bool { - self.current.files.select_all(opt.into().state) + pub fn select_all(&mut self, opt: impl Into) { + render!(self.current.files.select_all(opt.into().state)); } } diff --git a/yazi-core/src/tab/commands/visual_mode.rs b/yazi-core/src/tab/commands/visual_mode.rs index 470f6649..b5b1386e 100644 --- a/yazi-core/src/tab/commands/visual_mode.rs +++ b/yazi-core/src/tab/commands/visual_mode.rs @@ -1,6 +1,6 @@ use std::collections::BTreeSet; -use yazi_shared::event::Exec; +use yazi_shared::{event::Exec, render}; use crate::tab::{Mode, Tab}; @@ -13,7 +13,7 @@ impl From<&Exec> for Opt { } impl Tab { - pub fn visual_mode(&mut self, opt: impl Into) -> bool { + pub fn visual_mode(&mut self, opt: impl Into) { let opt = opt.into() as Opt; let idx = self.current.cursor; @@ -22,6 +22,6 @@ impl Tab { } else { self.mode = Mode::Select(idx, BTreeSet::from([idx])); }; - true + render!(); } } diff --git a/yazi-core/src/tasks/commands/arrow.rs b/yazi-core/src/tasks/commands/arrow.rs index a662f5fe..c62059e8 100644 --- a/yazi-core/src/tasks/commands/arrow.rs +++ b/yazi-core/src/tasks/commands/arrow.rs @@ -1,4 +1,4 @@ -use yazi_shared::event::Exec; +use yazi_shared::{event::Exec, render}; use crate::tasks::Tasks; @@ -14,23 +14,28 @@ impl From<&Exec> for Opt { impl Tasks { #[allow(clippy::should_implement_trait)] - fn next(&mut self) -> bool { + fn next(&mut self) { let limit = Self::limit().min(self.len()); let old = self.cursor; self.cursor = limit.saturating_sub(1).min(self.cursor + 1); - old != self.cursor + render!(old != self.cursor); } - fn prev(&mut self) -> bool { + fn prev(&mut self) { let old = self.cursor; self.cursor = self.cursor.saturating_sub(1); - old != self.cursor + + render!(old != self.cursor); } - pub fn arrow(&mut self, opt: impl Into) -> bool { + pub fn arrow(&mut self, opt: impl Into) { let opt = opt.into() as Opt; - if opt.step > 0 { self.next() } else { self.prev() } + if opt.step > 0 { + self.next(); + } else { + self.prev(); + } } } diff --git a/yazi-core/src/tasks/commands/cancel.rs b/yazi-core/src/tasks/commands/cancel.rs index 6800b175..6dd32977 100644 --- a/yazi-core/src/tasks/commands/cancel.rs +++ b/yazi-core/src/tasks/commands/cancel.rs @@ -1,16 +1,16 @@ -use yazi_shared::event::Exec; +use yazi_shared::{event::Exec, render}; use crate::tasks::Tasks; impl Tasks { - pub fn cancel(&mut self, _: &Exec) -> bool { + pub fn cancel(&mut self, _: &Exec) { let id = self.scheduler.running.read().get_id(self.cursor); if id.map(|id| self.scheduler.cancel(id)) != Some(true) { - return false; + return; } let len = self.scheduler.running.read().len(); self.cursor = self.cursor.min(len.saturating_sub(1)); - true + render!(); } } diff --git a/yazi-core/src/tasks/commands/inspect.rs b/yazi-core/src/tasks/commands/inspect.rs index 8c5d1782..7842c975 100644 --- a/yazi-core/src/tasks/commands/inspect.rs +++ b/yazi-core/src/tasks/commands/inspect.rs @@ -8,9 +8,9 @@ use yazi_shared::{event::Exec, term::Term, Defer}; use crate::tasks::Tasks; impl Tasks { - pub fn inspect(&self, _: &Exec) -> bool { + pub fn inspect(&self, _: &Exec) { let Some(id) = self.scheduler.running.read().get_id(self.cursor) else { - return false; + return; }; let scheduler = self.scheduler.clone(); @@ -66,6 +66,5 @@ impl Tasks { stdin.read(&mut quit).await.ok(); } }); - false } } diff --git a/yazi-core/src/tasks/commands/open.rs b/yazi-core/src/tasks/commands/open.rs index 5b831e31..a29d92d8 100644 --- a/yazi-core/src/tasks/commands/open.rs +++ b/yazi-core/src/tasks/commands/open.rs @@ -22,10 +22,9 @@ impl Tasks { emit!(Call(Exec::call("open", vec![]).with_data(Opt { targets, opener }).vec(), Layer::Tasks)); } - pub fn open(&mut self, opt: impl TryInto) -> bool { + pub fn open(&mut self, opt: impl TryInto) { if let Ok(opt) = opt.try_into() { self.file_open_with(&opt.opener, &opt.targets); } - false } } diff --git a/yazi-core/src/tasks/commands/toggle.rs b/yazi-core/src/tasks/commands/toggle.rs index b97c5ba5..57534395 100644 --- a/yazi-core/src/tasks/commands/toggle.rs +++ b/yazi-core/src/tasks/commands/toggle.rs @@ -1,4 +1,4 @@ -use yazi_shared::event::Exec; +use yazi_shared::{event::Exec, render}; use crate::tasks::Tasks; @@ -12,8 +12,8 @@ impl From<()> for Opt { } impl Tasks { - pub fn toggle(&mut self, _: impl Into) -> bool { + pub fn toggle(&mut self, _: impl Into) { self.visible = !self.visible; - true + render!(); } } diff --git a/yazi-core/src/tasks/commands/update.rs b/yazi-core/src/tasks/commands/update.rs index 8f3d0f57..0cdcdb13 100644 --- a/yazi-core/src/tasks/commands/update.rs +++ b/yazi-core/src/tasks/commands/update.rs @@ -1,5 +1,5 @@ use anyhow::anyhow; -use yazi_shared::{emit, event::Exec, Layer}; +use yazi_shared::{emit, event::Exec, render, Layer}; use crate::tasks::{Tasks, TasksProgress}; @@ -20,12 +20,12 @@ impl Tasks { emit!(Call(Exec::call("update", vec![]).with_data(Opt { progress }).vec(), Layer::Tasks)); } - pub fn update(&mut self, opt: impl TryInto) -> bool { + pub fn update(&mut self, opt: impl TryInto) { let Ok(opt) = opt.try_into() else { - return false; + return; }; self.progress = opt.progress; - true + render!(); } } diff --git a/yazi-fm/src/executor.rs b/yazi-fm/src/executor.rs index 16a7fb09..f0d40d52 100644 --- a/yazi-fm/src/executor.rs +++ b/yazi-fm/src/executor.rs @@ -171,7 +171,7 @@ impl<'a> Executor<'a> { b"tasks_show" => self.app.cx.tasks.toggle(()), // Help b"help" => self.app.cx.help.toggle(Layer::Manager), - _ => false, + _ => {} } } @@ -198,7 +198,7 @@ impl<'a> Executor<'a> { match exec.cmd.as_str() { "help" => self.app.cx.help.toggle(Layer::Tasks), - _ => false, + _ => {} } } @@ -217,7 +217,7 @@ impl<'a> Executor<'a> { match exec.cmd.as_str() { "help" => self.app.cx.help.toggle(Layer::Select), - _ => false, + _ => {} } } @@ -264,14 +264,12 @@ impl<'a> Executor<'a> { match exec.cmd.as_str() { "help" => self.app.cx.help.toggle(Layer::Input), - _ => false, + _ => {} } } InputMode::Insert => { on!(backspace); on!(kill); - - false } } }