mirror of
https://github.com/sxyazi/yazi.git
synced 2026-07-25 08:41:05 +00:00
..
This commit is contained in:
parent
faebd78219
commit
19ebbd3df3
19 changed files with 58 additions and 60 deletions
|
|
@ -21,7 +21,7 @@ impl Input {
|
||||||
}
|
}
|
||||||
|
|
||||||
if prev != CharKind::Space {
|
if prev != CharKind::Space {
|
||||||
return self.move_(-(snap.len() as isize));
|
self.move_(-(snap.len() as isize));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,11 @@
|
||||||
use yazi_shared::{event::Exec, render};
|
use yazi_shared::event::Exec;
|
||||||
|
|
||||||
use crate::{manager::Manager, tasks::Tasks};
|
use crate::{manager::Manager, tasks::Tasks};
|
||||||
|
|
||||||
impl Manager {
|
impl Manager {
|
||||||
pub fn close(&mut self, _: &Exec, tasks: &Tasks) {
|
pub fn close(&mut self, _: &Exec, tasks: &Tasks) {
|
||||||
if self.tabs.len() > 1 {
|
if self.tabs.len() > 1 {
|
||||||
return render!(self.tabs.close(self.tabs.idx));
|
return self.tabs.close(self.tabs.idx);
|
||||||
}
|
}
|
||||||
self.quit((), tasks);
|
self.quit((), tasks);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@ use tokio::fs;
|
||||||
use tracing::error;
|
use tracing::error;
|
||||||
use yazi_config::{popup::SelectCfg, ARGS, OPEN};
|
use yazi_config::{popup::SelectCfg, ARGS, OPEN};
|
||||||
use yazi_plugin::isolate;
|
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};
|
use crate::{manager::Manager, select::Select, tasks::Tasks};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -67,7 +67,7 @@ impl Manager {
|
||||||
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 render!(self.active_mut().preview.reset());
|
render!(self.active_mut().preview.reset());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
use yazi_shared::event::Exec;
|
use yazi_shared::{event::Exec, render};
|
||||||
|
|
||||||
use crate::manager::Tabs;
|
use crate::manager::Tabs;
|
||||||
|
|
||||||
|
|
@ -17,12 +17,12 @@ impl From<usize> for Opt {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Tabs {
|
impl Tabs {
|
||||||
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;
|
let opt = opt.into() as Opt;
|
||||||
|
|
||||||
let len = self.items.len();
|
let len = self.items.len();
|
||||||
if len < 2 || opt.idx >= len {
|
if len < 2 || opt.idx >= len {
|
||||||
return false;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
self.items.remove(opt.idx);
|
self.items.remove(opt.idx);
|
||||||
|
|
@ -30,6 +30,6 @@ impl Tabs {
|
||||||
self.set_idx(self.absolute(1));
|
self.set_idx(self.absolute(1));
|
||||||
}
|
}
|
||||||
|
|
||||||
true
|
render!();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -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};
|
use crate::{manager::Tabs, tab::Tab};
|
||||||
|
|
||||||
|
|
@ -21,9 +21,9 @@ impl From<&Exec> for Opt {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Tabs {
|
impl Tabs {
|
||||||
pub fn create(&mut self, opt: impl Into<Opt>) -> bool {
|
pub fn create(&mut self, opt: impl Into<Opt>) {
|
||||||
if self.items.len() >= MAX_TABS {
|
if self.items.len() >= MAX_TABS {
|
||||||
return false;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
let opt = opt.into() as Opt;
|
let opt = opt.into() as Opt;
|
||||||
|
|
@ -35,6 +35,6 @@ impl Tabs {
|
||||||
|
|
||||||
self.items.insert(self.idx + 1, tab);
|
self.items.insert(self.idx + 1, tab);
|
||||||
self.set_idx(self.idx + 1);
|
self.set_idx(self.idx + 1);
|
||||||
true
|
render!();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
use yazi_shared::event::Exec;
|
use yazi_shared::{event::Exec, render};
|
||||||
|
|
||||||
use crate::manager::Tabs;
|
use crate::manager::Tabs;
|
||||||
|
|
||||||
|
|
@ -13,14 +13,14 @@ impl From<&Exec> for Opt {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Tabs {
|
impl Tabs {
|
||||||
pub fn swap(&mut self, opt: impl Into<Opt>) -> bool {
|
pub fn swap(&mut self, opt: impl Into<Opt>) {
|
||||||
let idx = self.absolute(opt.into().step);
|
let idx = self.absolute(opt.into().step);
|
||||||
if idx == self.idx {
|
if idx == self.idx {
|
||||||
return false;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
self.items.swap(self.idx, idx);
|
self.items.swap(self.idx, idx);
|
||||||
self.set_idx(idx);
|
self.set_idx(idx);
|
||||||
true
|
render!();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
use yazi_shared::event::Exec;
|
use yazi_shared::{event::Exec, render};
|
||||||
|
|
||||||
use crate::manager::Tabs;
|
use crate::manager::Tabs;
|
||||||
|
|
||||||
|
|
@ -17,7 +17,7 @@ impl From<&Exec> for Opt {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Tabs {
|
impl Tabs {
|
||||||
pub fn switch(&mut self, opt: impl Into<Opt>) -> bool {
|
pub fn switch(&mut self, opt: impl Into<Opt>) {
|
||||||
let opt = opt.into() as Opt;
|
let opt = opt.into() as Opt;
|
||||||
let idx = if opt.relative {
|
let idx = if opt.relative {
|
||||||
(self.idx as isize + opt.step).rem_euclid(self.items.len() as isize) as usize
|
(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() {
|
if idx == self.idx || idx >= self.items.len() {
|
||||||
return false;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
self.set_idx(idx);
|
self.set_idx(idx);
|
||||||
true
|
render!();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -46,7 +46,9 @@ impl Tab {
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn escape_filter(&mut self) -> bool {
|
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]
|
#[inline]
|
||||||
|
|
|
||||||
|
|
@ -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::{Filter, FilterCase}, input::Input, manager::Manager, tab::Tab};
|
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 {
|
impl Tab {
|
||||||
pub fn filter<'a>(&mut self, opt: impl Into<Opt<'a>>) -> bool {
|
pub fn filter<'a>(&mut self, opt: impl Into<Opt<'a>>) {
|
||||||
let opt = opt.into() as Opt;
|
let opt = opt.into() as Opt;
|
||||||
tokio::spawn(async move {
|
tokio::spawn(async move {
|
||||||
let rx = Input::_show(InputCfg::filter());
|
let rx = Input::_show(InputCfg::filter());
|
||||||
|
|
@ -38,10 +38,9 @@ impl Tab {
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
false
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn filter_do<'a>(&mut self, opt: impl Into<Opt<'a>>) -> bool {
|
pub fn filter_do<'a>(&mut self, opt: impl Into<Opt<'a>>) {
|
||||||
let opt = opt.into() as Opt;
|
let opt = opt.into() as Opt;
|
||||||
|
|
||||||
let filter = if opt.query.is_empty() {
|
let filter = if opt.query.is_empty() {
|
||||||
|
|
@ -49,17 +48,17 @@ impl Tab {
|
||||||
} else if let Ok(f) = Filter::new(opt.query, opt.case) {
|
} else if let Ok(f) = Filter::new(opt.query, opt.case) {
|
||||||
Some(f)
|
Some(f)
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return;
|
||||||
};
|
};
|
||||||
|
|
||||||
let hovered = self.current.hovered().map(|f| f.url());
|
let hovered = self.current.hovered().map(|f| f.url());
|
||||||
if !self.current.files.set_filter(filter) {
|
if !self.current.files.set_filter(filter) {
|
||||||
return false;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if self.current.repos(hovered) {
|
if self.current.repos(hovered) {
|
||||||
Manager::_hover(None);
|
Manager::_hover(None);
|
||||||
}
|
}
|
||||||
true
|
render!();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -32,7 +32,7 @@ impl From<&Exec> for ArrowOpt {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Tab {
|
impl Tab {
|
||||||
pub fn find<'a>(&mut self, opt: impl Into<Opt<'a>>) -> bool {
|
pub fn find<'a>(&mut self, opt: impl Into<Opt<'a>>) {
|
||||||
let opt = opt.into() as Opt;
|
let opt = opt.into() as Opt;
|
||||||
tokio::spawn(async move {
|
tokio::spawn(async move {
|
||||||
let rx = Input::_show(InputCfg::find(opt.prev));
|
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<Opt<'a>>) {
|
pub fn find_do<'a>(&mut self, opt: impl Into<Opt<'a>>) {
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
use yazi_shared::{event::Exec, render};
|
use yazi_shared::event::Exec;
|
||||||
|
|
||||||
use crate::{manager::Manager, tab::Tab};
|
use crate::{manager::Manager, tab::Tab};
|
||||||
|
|
||||||
|
|
@ -9,9 +9,8 @@ impl Tab {
|
||||||
Some(b"hide") => false,
|
Some(b"hide") => false,
|
||||||
_ => !self.conf.show_hidden,
|
_ => !self.conf.show_hidden,
|
||||||
};
|
};
|
||||||
if self.apply_files_attrs(false) {
|
|
||||||
|
self.apply_files_attrs(false);
|
||||||
Manager::_hover(None);
|
Manager::_hover(None);
|
||||||
render!();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -28,10 +28,10 @@ impl From<&Exec> for Opt {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Tab {
|
impl Tab {
|
||||||
pub fn jump(&self, opt: impl Into<Opt>) -> bool {
|
pub fn jump(&self, opt: impl Into<Opt>) {
|
||||||
let opt = opt.into() as Opt;
|
let opt = opt.into() as Opt;
|
||||||
if opt.type_ == OptType::None {
|
if opt.type_ == OptType::None {
|
||||||
return false;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
let cwd = self.current.cwd.clone();
|
let cwd = self.current.cwd.clone();
|
||||||
|
|
@ -56,6 +56,5 @@ impl Tab {
|
||||||
Tab::_cd(&url)
|
Tab::_cd(&url)
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
false
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -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};
|
use crate::{manager::Manager, tab::Tab};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@ use yazi_shared::event::Exec;
|
||||||
use crate::tab::Tab;
|
use crate::tab::Tab;
|
||||||
|
|
||||||
impl 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() {
|
if let Some(by) = e.args.first() {
|
||||||
self.conf.sort_by = SortBy::from_str(by).unwrap_or_default();
|
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_reverse = e.named.contains_key("reverse");
|
||||||
self.conf.sort_dir_first = e.named.contains_key("dir-first");
|
self.conf.sort_dir_first = e.named.contains_key("dir-first");
|
||||||
|
|
||||||
self.apply_files_attrs(false)
|
self.apply_files_attrs(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@ use std::{borrow::Cow, collections::BTreeMap};
|
||||||
|
|
||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
use tokio::task::JoinHandle;
|
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 super::{Backstack, Config, Finder, Mode, Preview};
|
||||||
use crate::folder::Folder;
|
use crate::folder::Folder;
|
||||||
|
|
@ -72,30 +72,28 @@ impl Tab {
|
||||||
self.history.remove(url).unwrap_or_else(|| Folder::from(url))
|
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 apply = |f: &mut Folder| {
|
||||||
let hovered = f.hovered().map(|h| h.url());
|
let hovered = f.hovered().map(|h| h.url());
|
||||||
|
|
||||||
f.files.set_show_hidden(self.conf.show_hidden);
|
f.files.set_show_hidden(self.conf.show_hidden);
|
||||||
f.files.set_sorter(self.conf.sorter());
|
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) =
|
if let Some(f) =
|
||||||
self.current.hovered().filter(|h| h.is_dir()).and_then(|h| self.history.get_mut(&h.url))
|
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 {
|
if just_preview {
|
||||||
return b;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
b |= apply(&mut self.current);
|
apply(&mut self.current);
|
||||||
if let Some(parent) = self.parent.as_mut() {
|
if let Some(parent) = self.parent.as_mut() {
|
||||||
b |= apply(parent);
|
apply(parent);
|
||||||
}
|
}
|
||||||
|
|
||||||
b
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@ use anyhow::{Ok, Result};
|
||||||
use crossterm::event::KeyEvent;
|
use crossterm::event::KeyEvent;
|
||||||
use yazi_config::{keymap::Key, ARGS};
|
use yazi_config::{keymap::Key, ARGS};
|
||||||
use yazi_core::input::InputMode;
|
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};
|
use crate::{lives::Lives, Ctx, Executor, Logs, Panic, Signals};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -18,12 +18,14 @@ impl<'a> Executor<'a> {
|
||||||
if cx.which.visible {
|
if cx.which.visible {
|
||||||
return cx.which.press(key);
|
return cx.which.press(key);
|
||||||
}
|
}
|
||||||
if cx.help.visible && cx.help.type_(&key) {
|
// TODO: render
|
||||||
return true;
|
// if cx.help.visible && cx.help.type_(&key) {
|
||||||
}
|
// return true;
|
||||||
if cx.input.visible && cx.input.type_(&key) {
|
// }
|
||||||
return true;
|
// TODO: render
|
||||||
}
|
// if cx.input.visible && cx.input.type_(&key) {
|
||||||
|
// return true;
|
||||||
|
// }
|
||||||
|
|
||||||
if cx.completion.visible {
|
if cx.completion.visible {
|
||||||
self.matches(Layer::Completion, key) || self.matches(Layer::Input, key)
|
self.matches(Layer::Completion, key) || self.matches(Layer::Input, key)
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@ use ratatui::{buffer::Buffer, layout::Rect, widgets::Widget};
|
||||||
use yazi_adaptor::ADAPTOR;
|
use yazi_adaptor::ADAPTOR;
|
||||||
use yazi_config::LAYOUT;
|
use yazi_config::LAYOUT;
|
||||||
|
|
||||||
use crate::renderer::COLLISION;
|
use crate::root::COLLISION;
|
||||||
|
|
||||||
pub(crate) struct Clear;
|
pub(crate) struct Clear;
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue