mirror of
https://github.com/sxyazi/yazi.git
synced 2026-07-25 08:41:05 +00:00
rerstore firmatting diffs
This commit is contained in:
parent
518612857b
commit
83b46c8230
6 changed files with 69 additions and 147 deletions
|
|
@ -6,10 +6,7 @@ use tokio_stream::{StreamExt, wrappers::UnboundedReceiverStream};
|
|||
use yazi_config::popup::InputCfg;
|
||||
use yazi_fs::{FilesOp, cha::Cha};
|
||||
use yazi_macro::{act, succ};
|
||||
use yazi_parser::{
|
||||
VoidOpt,
|
||||
mgr::{SearchOpt, SearchOptVia},
|
||||
};
|
||||
use yazi_parser::{VoidOpt, mgr::{SearchOpt, SearchOptVia}};
|
||||
use yazi_plugin::external;
|
||||
use yazi_proxy::{InputProxy, MgrProxy};
|
||||
use yazi_shared::event::Data;
|
||||
|
|
|
|||
|
|
@ -1,7 +1,4 @@
|
|||
use std::{
|
||||
fs::{FileType, Metadata},
|
||||
time::SystemTime,
|
||||
};
|
||||
use std::{fs::{FileType, Metadata}, time::SystemTime};
|
||||
|
||||
use yazi_macro::{unix_either, win_either};
|
||||
use yazi_shared::url::Url;
|
||||
|
|
@ -132,10 +129,7 @@ impl Cha {
|
|||
|
||||
fn from_just_meta(m: &Metadata) -> Self {
|
||||
#[cfg(unix)]
|
||||
use std::{
|
||||
os::unix::{fs::MetadataExt, prelude::PermissionsExt},
|
||||
time::{Duration, UNIX_EPOCH},
|
||||
};
|
||||
use std::{os::unix::{fs::MetadataExt, prelude::PermissionsExt}, time::{Duration, UNIX_EPOCH}};
|
||||
|
||||
let mut kind = ChaKind::empty();
|
||||
if m.is_dir() {
|
||||
|
|
@ -184,9 +178,7 @@ impl Cha {
|
|||
|
||||
impl Cha {
|
||||
#[inline]
|
||||
pub const fn is_dir(&self) -> bool {
|
||||
self.kind.contains(ChaKind::DIR)
|
||||
}
|
||||
pub const fn is_dir(&self) -> bool { self.kind.contains(ChaKind::DIR) }
|
||||
|
||||
#[inline]
|
||||
pub const fn is_hidden(&self) -> bool {
|
||||
|
|
@ -197,19 +189,13 @@ impl Cha {
|
|||
}
|
||||
|
||||
#[inline]
|
||||
pub const fn is_link(&self) -> bool {
|
||||
self.kind.contains(ChaKind::LINK)
|
||||
}
|
||||
pub const fn is_link(&self) -> bool { self.kind.contains(ChaKind::LINK) }
|
||||
|
||||
#[inline]
|
||||
pub const fn is_orphan(&self) -> bool {
|
||||
self.kind.contains(ChaKind::ORPHAN)
|
||||
}
|
||||
pub const fn is_orphan(&self) -> bool { self.kind.contains(ChaKind::ORPHAN) }
|
||||
|
||||
#[inline]
|
||||
pub const fn is_dummy(&self) -> bool {
|
||||
self.kind.contains(ChaKind::DUMMY)
|
||||
}
|
||||
pub const fn is_dummy(&self) -> bool { self.kind.contains(ChaKind::DUMMY) }
|
||||
|
||||
#[inline]
|
||||
pub const fn is_block(&self) -> bool {
|
||||
|
|
@ -232,12 +218,8 @@ impl Cha {
|
|||
}
|
||||
|
||||
#[inline]
|
||||
pub const fn is_exec(&self) -> bool {
|
||||
unix_either!(self.mode & libc::S_IXUSR != 0, false)
|
||||
}
|
||||
pub const fn is_exec(&self) -> bool { unix_either!(self.mode & libc::S_IXUSR != 0, false) }
|
||||
|
||||
#[inline]
|
||||
pub const fn is_sticky(&self) -> bool {
|
||||
unix_either!(self.mode & libc::S_ISVTX != 0, false)
|
||||
}
|
||||
pub const fn is_sticky(&self) -> bool { unix_either!(self.mode & libc::S_ISVTX != 0, false) }
|
||||
}
|
||||
|
|
@ -36,9 +36,7 @@ impl TryFrom<CmdCow> for SearchOpt {
|
|||
}
|
||||
|
||||
impl IntoLua for &SearchOpt {
|
||||
fn into_lua(self, _: &Lua) -> mlua::Result<Value> {
|
||||
Err("unsupported".into_lua_err())
|
||||
}
|
||||
fn into_lua(self, _: &Lua) -> mlua::Result<Value> { Err("unsupported".into_lua_err()) }
|
||||
}
|
||||
|
||||
// Via
|
||||
|
|
|
|||
6
yazi-plugin/src/external/es.rs
vendored
6
yazi-plugin/src/external/es.rs
vendored
|
|
@ -2,11 +2,7 @@ use std::path::Path;
|
|||
use std::process::Stdio;
|
||||
|
||||
use anyhow::Result;
|
||||
use tokio::{
|
||||
io::{AsyncBufReadExt, BufReader},
|
||||
process::{Child, Command},
|
||||
sync::mpsc::{self, UnboundedReceiver},
|
||||
};
|
||||
use tokio::{io::{AsyncBufReadExt, BufReader},process::{Child, Command},sync::mpsc::{self, UnboundedReceiver},};
|
||||
use yazi_fs::File;
|
||||
use yazi_shared::url::Url;
|
||||
|
||||
|
|
|
|||
|
|
@ -1,20 +1,10 @@
|
|||
use std::{
|
||||
borrow::Cow,
|
||||
ffi::OsStr,
|
||||
fmt::{Debug, Formatter},
|
||||
hash::BuildHasher,
|
||||
ops::Deref,
|
||||
path::{Path, PathBuf},
|
||||
};
|
||||
use std::{borrow::Cow, ffi::OsStr, fmt::{Debug, Formatter}, hash::BuildHasher, ops::Deref, path::{Path, PathBuf}};
|
||||
|
||||
use percent_encoding::percent_decode;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use super::UrnBuf;
|
||||
use crate::{
|
||||
IntoOsStr,
|
||||
url::{Components, Display, Loc, Scheme},
|
||||
};
|
||||
use crate::{IntoOsStr, url::{Components, Display, Loc, Scheme}};
|
||||
|
||||
#[derive(Clone, Default, Eq, Ord, PartialOrd, PartialEq, Hash)]
|
||||
pub struct Url {
|
||||
|
|
@ -25,33 +15,23 @@ pub struct Url {
|
|||
impl Deref for Url {
|
||||
type Target = Loc;
|
||||
|
||||
fn deref(&self) -> &Self::Target {
|
||||
&self.loc
|
||||
}
|
||||
fn deref(&self) -> &Self::Target { &self.loc }
|
||||
}
|
||||
|
||||
impl From<Loc> for Url {
|
||||
fn from(loc: Loc) -> Self {
|
||||
Self { loc, scheme: Scheme::Regular }
|
||||
}
|
||||
fn from(loc: Loc) -> Self { Self { loc, scheme: Scheme::Regular } }
|
||||
}
|
||||
|
||||
impl From<PathBuf> for Url {
|
||||
fn from(path: PathBuf) -> Self {
|
||||
Loc::from(path).into()
|
||||
}
|
||||
fn from(path: PathBuf) -> Self { Loc::from(path).into() }
|
||||
}
|
||||
|
||||
impl From<&PathBuf> for Url {
|
||||
fn from(path: &PathBuf) -> Self {
|
||||
path.to_owned().into()
|
||||
}
|
||||
fn from(path: &PathBuf) -> Self { path.to_owned().into() }
|
||||
}
|
||||
|
||||
impl From<&Path> for Url {
|
||||
fn from(path: &Path) -> Self {
|
||||
path.to_path_buf().into()
|
||||
}
|
||||
fn from(path: &Path) -> Self { path.to_path_buf().into() }
|
||||
}
|
||||
|
||||
impl TryFrom<&[u8]> for Url {
|
||||
|
|
@ -73,48 +53,34 @@ impl TryFrom<&[u8]> for Url {
|
|||
impl TryFrom<&str> for Url {
|
||||
type Error = anyhow::Error;
|
||||
|
||||
fn try_from(value: &str) -> Result<Self, Self::Error> {
|
||||
value.as_bytes().try_into()
|
||||
}
|
||||
fn try_from(value: &str) -> Result<Self, Self::Error> { value.as_bytes().try_into() }
|
||||
}
|
||||
|
||||
impl TryFrom<String> for Url {
|
||||
type Error = anyhow::Error;
|
||||
|
||||
fn try_from(value: String) -> Result<Self, Self::Error> {
|
||||
value.as_bytes().try_into()
|
||||
}
|
||||
fn try_from(value: String) -> Result<Self, Self::Error> { value.as_bytes().try_into() }
|
||||
}
|
||||
|
||||
impl AsRef<Url> for Url {
|
||||
fn as_ref(&self) -> &Url {
|
||||
self
|
||||
}
|
||||
fn as_ref(&self) -> &Url { self }
|
||||
}
|
||||
|
||||
// FIXME: remove
|
||||
impl AsRef<Path> for Url {
|
||||
fn as_ref(&self) -> &Path {
|
||||
&self.loc
|
||||
}
|
||||
fn as_ref(&self) -> &Path { &self.loc }
|
||||
}
|
||||
|
||||
impl<'a> From<&'a Url> for Cow<'a, Url> {
|
||||
fn from(url: &'a Url) -> Self {
|
||||
Cow::Borrowed(url)
|
||||
}
|
||||
fn from(url: &'a Url) -> Self { Cow::Borrowed(url) }
|
||||
}
|
||||
|
||||
impl From<Url> for Cow<'_, Url> {
|
||||
fn from(url: Url) -> Self {
|
||||
Cow::Owned(url)
|
||||
}
|
||||
fn from(url: Url) -> Self { Cow::Owned(url) }
|
||||
}
|
||||
|
||||
impl From<Cow<'_, Url>> for Url {
|
||||
fn from(url: Cow<'_, Url>) -> Self {
|
||||
url.into_owned()
|
||||
}
|
||||
fn from(url: Cow<'_, Url>) -> Self { url.into_owned() }
|
||||
}
|
||||
|
||||
impl Url {
|
||||
|
|
@ -139,16 +105,16 @@ impl Url {
|
|||
Scheme::SearchItem => {
|
||||
Self { loc: Loc::with(self.loc.base(), self.loc.join(path)), scheme: Scheme::SearchItem }
|
||||
}
|
||||
Scheme::Archive(_) => Self { loc: self.loc.join(path).into(), scheme: self.scheme.clone() },
|
||||
Scheme::Archive(_) => {
|
||||
Self { loc: self.loc.join(path).into(), scheme: self.scheme.clone() }
|
||||
}
|
||||
Scheme::Sftp(_) => Self { loc: self.loc.join(path).into(), scheme: self.scheme.clone() },
|
||||
}
|
||||
}
|
||||
|
||||
// FIXME: check usages
|
||||
#[inline]
|
||||
pub fn components(&self) -> Components<'_> {
|
||||
Components::new(self)
|
||||
}
|
||||
pub fn components(&self) -> Components<'_> { Components::new(self) }
|
||||
|
||||
#[inline]
|
||||
pub fn covariant(&self, other: &Self) -> bool {
|
||||
|
|
@ -156,14 +122,10 @@ impl Url {
|
|||
}
|
||||
|
||||
#[inline]
|
||||
pub fn display(&self) -> Display<'_> {
|
||||
Display::new(self)
|
||||
}
|
||||
pub fn display(&self) -> Display<'_> { Display::new(self) }
|
||||
|
||||
#[inline]
|
||||
pub fn os_str(&self) -> Cow<'_, OsStr> {
|
||||
self.components().os_str()
|
||||
}
|
||||
pub fn os_str(&self) -> Cow<'_, OsStr> { self.components().os_str() }
|
||||
|
||||
pub fn parent_url(&self) -> Option<Url> {
|
||||
let parent = self.loc.parent()?;
|
||||
|
|
@ -189,7 +151,10 @@ impl Url {
|
|||
return None;
|
||||
}
|
||||
|
||||
Some(Self { loc: self.loc.strip_prefix(&base.loc).ok()?.into(), scheme: self.scheme.clone() })
|
||||
Some(Self {
|
||||
loc: self.loc.strip_prefix(&base.loc).ok()?.into(),
|
||||
scheme: self.scheme.clone(),
|
||||
})
|
||||
}
|
||||
|
||||
#[inline]
|
||||
|
|
@ -198,19 +163,13 @@ impl Url {
|
|||
}
|
||||
|
||||
#[inline]
|
||||
pub fn set_name(&mut self, name: impl AsRef<OsStr>) {
|
||||
self.loc.set_name(name);
|
||||
}
|
||||
pub fn set_name(&mut self, name: impl AsRef<OsStr>) { self.loc.set_name(name); }
|
||||
|
||||
#[inline]
|
||||
pub fn pair(&self) -> Option<(Self, UrnBuf)> {
|
||||
Some((self.parent_url()?, self.loc.urn_owned()))
|
||||
}
|
||||
pub fn pair(&self) -> Option<(Self, UrnBuf)> { Some((self.parent_url()?, self.loc.urn_owned())) }
|
||||
|
||||
#[inline]
|
||||
pub fn hash_u64(&self) -> u64 {
|
||||
foldhash::fast::FixedState::default().hash_one(self)
|
||||
}
|
||||
pub fn hash_u64(&self) -> u64 { foldhash::fast::FixedState::default().hash_one(self) }
|
||||
|
||||
#[inline]
|
||||
pub fn rebase(&self, parent: &Path) -> Self {
|
||||
|
|
@ -222,14 +181,10 @@ impl Url {
|
|||
impl Url {
|
||||
// --- Regular
|
||||
#[inline]
|
||||
pub fn is_regular(&self) -> bool {
|
||||
self.scheme == Scheme::Regular
|
||||
}
|
||||
pub fn is_regular(&self) -> bool { self.scheme == Scheme::Regular }
|
||||
|
||||
#[inline]
|
||||
pub fn to_regular(&self) -> Self {
|
||||
Self { loc: self.loc.clone(), scheme: Scheme::Regular }
|
||||
}
|
||||
pub fn to_regular(&self) -> Self { Self { loc: self.loc.clone(), scheme: Scheme::Regular } }
|
||||
|
||||
#[inline]
|
||||
pub fn into_regular(mut self) -> Self {
|
||||
|
|
@ -239,9 +194,7 @@ impl Url {
|
|||
|
||||
// --- Search
|
||||
#[inline]
|
||||
pub fn is_search(&self) -> bool {
|
||||
matches!(self.scheme, Scheme::Search(_))
|
||||
}
|
||||
pub fn is_search(&self) -> bool { matches!(self.scheme, Scheme::Search(_)) }
|
||||
|
||||
#[inline]
|
||||
pub fn to_search(&self, frag: impl AsRef<str>) -> Self {
|
||||
|
|
@ -256,15 +209,11 @@ impl Url {
|
|||
|
||||
// --- Archive
|
||||
#[inline]
|
||||
pub fn is_archive(&self) -> bool {
|
||||
matches!(self.scheme, Scheme::Archive(_))
|
||||
}
|
||||
pub fn is_archive(&self) -> bool { matches!(self.scheme, Scheme::Archive(_)) }
|
||||
|
||||
// FIXME: remove
|
||||
#[inline]
|
||||
pub fn into_path(self) -> PathBuf {
|
||||
self.loc.into_path()
|
||||
}
|
||||
pub fn into_path(self) -> PathBuf { self.loc.into_path() }
|
||||
}
|
||||
|
||||
impl Debug for Url {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue