mirror of
https://github.com/sxyazi/yazi.git
synced 2026-07-25 08:41:05 +00:00
Do a rustfmt **/*.rs
This commit is contained in:
parent
284d95a3a3
commit
740e679b13
3 changed files with 17 additions and 61 deletions
|
|
@ -1,23 +1,17 @@
|
||||||
use core::files::File;
|
use core::files::File;
|
||||||
|
|
||||||
use config::{MANAGER, THEME};
|
use config::{MANAGER, THEME};
|
||||||
use ratatui::{
|
use ratatui::{buffer::Buffer, layout::Rect, style::{Color, Modifier, Style}, text::{Line, Span}, widgets::{List, ListItem, Widget}};
|
||||||
buffer::Buffer,
|
|
||||||
layout::Rect,
|
|
||||||
style::{Color, Modifier, Style},
|
|
||||||
text::{Line, Span},
|
|
||||||
widgets::{List, ListItem, Widget},
|
|
||||||
};
|
|
||||||
use shared::short_path;
|
use shared::short_path;
|
||||||
|
|
||||||
use crate::Ctx;
|
use crate::Ctx;
|
||||||
|
|
||||||
pub(super) struct Folder<'a> {
|
pub(super) struct Folder<'a> {
|
||||||
cx: &'a Ctx,
|
cx: &'a Ctx,
|
||||||
folder: &'a core::manager::Folder,
|
folder: &'a core::manager::Folder,
|
||||||
is_preview: bool,
|
is_preview: bool,
|
||||||
is_selection: bool,
|
is_selection: bool,
|
||||||
is_find: bool,
|
is_find: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> Folder<'a> {
|
impl<'a> Folder<'a> {
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@ use shared::Url;
|
||||||
use crate::files::Files;
|
use crate::files::Files;
|
||||||
|
|
||||||
pub struct Finder {
|
pub struct Finder {
|
||||||
query: Regex,
|
query: Regex,
|
||||||
matched: BTreeMap<Url, u8>,
|
matched: BTreeMap<Url, u8>,
|
||||||
version: u64,
|
version: u64,
|
||||||
}
|
}
|
||||||
|
|
@ -123,14 +123,10 @@ impl Finder {
|
||||||
|
|
||||||
impl Finder {
|
impl Finder {
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn matched(&self) -> &BTreeMap<Url, u8> {
|
pub fn matched(&self) -> &BTreeMap<Url, u8> { &self.matched }
|
||||||
&self.matched
|
|
||||||
}
|
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn has_matched(&self) -> bool {
|
pub fn has_matched(&self) -> bool { !self.matched.is_empty() }
|
||||||
!self.matched.is_empty()
|
|
||||||
}
|
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn matched_idx(&self, url: &Url) -> Option<u8> {
|
pub fn matched_idx(&self, url: &Url) -> Option<u8> {
|
||||||
|
|
|
||||||
|
|
@ -1,14 +1,7 @@
|
||||||
use std::{
|
use std::{collections::VecDeque, path::{Path, PathBuf}};
|
||||||
collections::VecDeque,
|
|
||||||
path::{Path, PathBuf},
|
|
||||||
};
|
|
||||||
|
|
||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
use tokio::{
|
use tokio::{fs, io, select, sync::{mpsc, oneshot}, time};
|
||||||
fs, io, select,
|
|
||||||
sync::{mpsc, oneshot},
|
|
||||||
time,
|
|
||||||
};
|
|
||||||
|
|
||||||
pub async fn calculate_size(path: &Path) -> u64 {
|
pub async fn calculate_size(path: &Path) -> u64 {
|
||||||
let mut total = 0;
|
let mut total = 0;
|
||||||
|
|
@ -102,10 +95,7 @@ pub fn copy_with_progress(from: &Path, to: &Path) -> mpsc::Receiver<Result<u64,
|
||||||
#[cfg(not(target_os = "windows"))]
|
#[cfg(not(target_os = "windows"))]
|
||||||
#[allow(clippy::collapsible_else_if)]
|
#[allow(clippy::collapsible_else_if)]
|
||||||
pub fn file_mode(mode: u32) -> String {
|
pub fn file_mode(mode: u32) -> String {
|
||||||
use libc::{
|
use libc::{S_IFBLK, S_IFCHR, S_IFDIR, S_IFIFO, S_IFLNK, S_IFMT, S_IFSOCK, S_IRGRP, S_IROTH, S_IRUSR, S_ISGID, S_ISUID, S_ISVTX, S_IWGRP, S_IWOTH, S_IWUSR, S_IXGRP, S_IXOTH, S_IXUSR};
|
||||||
S_IFBLK, S_IFCHR, S_IFDIR, S_IFIFO, S_IFLNK, S_IFMT, S_IFSOCK, S_IRGRP, S_IROTH, S_IRUSR,
|
|
||||||
S_ISGID, S_ISUID, S_ISVTX, S_IWGRP, S_IWOTH, S_IWUSR, S_IXGRP, S_IXOTH, S_IXUSR,
|
|
||||||
};
|
|
||||||
|
|
||||||
#[cfg(target_os = "macos")]
|
#[cfg(target_os = "macos")]
|
||||||
let m = mode as u16;
|
let m = mode as u16;
|
||||||
|
|
@ -133,51 +123,27 @@ pub fn file_mode(mode: u32) -> String {
|
||||||
s.push(if m & S_IRUSR != 0 { 'r' } else { '-' });
|
s.push(if m & S_IRUSR != 0 { 'r' } else { '-' });
|
||||||
s.push(if m & S_IWUSR != 0 { 'w' } else { '-' });
|
s.push(if m & S_IWUSR != 0 { 'w' } else { '-' });
|
||||||
s.push(if m & S_IXUSR != 0 {
|
s.push(if m & S_IXUSR != 0 {
|
||||||
if m & S_ISUID != 0 {
|
if m & S_ISUID != 0 { 's' } else { 'x' }
|
||||||
's'
|
|
||||||
} else {
|
|
||||||
'x'
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
if m & S_ISUID != 0 {
|
if m & S_ISUID != 0 { 'S' } else { '-' }
|
||||||
'S'
|
|
||||||
} else {
|
|
||||||
'-'
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// Group
|
// Group
|
||||||
s.push(if m & S_IRGRP != 0 { 'r' } else { '-' });
|
s.push(if m & S_IRGRP != 0 { 'r' } else { '-' });
|
||||||
s.push(if m & S_IWGRP != 0 { 'w' } else { '-' });
|
s.push(if m & S_IWGRP != 0 { 'w' } else { '-' });
|
||||||
s.push(if m & S_IXGRP != 0 {
|
s.push(if m & S_IXGRP != 0 {
|
||||||
if m & S_ISGID != 0 {
|
if m & S_ISGID != 0 { 's' } else { 'x' }
|
||||||
's'
|
|
||||||
} else {
|
|
||||||
'x'
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
if m & S_ISGID != 0 {
|
if m & S_ISGID != 0 { 'S' } else { '-' }
|
||||||
'S'
|
|
||||||
} else {
|
|
||||||
'-'
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// Other
|
// Other
|
||||||
s.push(if m & S_IROTH != 0 { 'r' } else { '-' });
|
s.push(if m & S_IROTH != 0 { 'r' } else { '-' });
|
||||||
s.push(if m & S_IWOTH != 0 { 'w' } else { '-' });
|
s.push(if m & S_IWOTH != 0 { 'w' } else { '-' });
|
||||||
s.push(if m & S_IXOTH != 0 {
|
s.push(if m & S_IXOTH != 0 {
|
||||||
if m & S_ISVTX != 0 {
|
if m & S_ISVTX != 0 { 't' } else { 'x' }
|
||||||
't'
|
|
||||||
} else {
|
|
||||||
'x'
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
if m & S_ISVTX != 0 {
|
if m & S_ISVTX != 0 { 'T' } else { '-' }
|
||||||
'T'
|
|
||||||
} else {
|
|
||||||
'-'
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
s
|
s
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue