mirror of
https://github.com/sxyazi/yazi.git
synced 2026-07-21 23:01:05 +00:00
fix: hidden attribute of files on Windows (#632)
This commit is contained in:
parent
d776ce1074
commit
59e889a3b5
24 changed files with 192 additions and 149 deletions
128
Cargo.lock
generated
128
Cargo.lock
generated
|
|
@ -86,9 +86,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "anstyle"
|
||||
version = "1.0.4"
|
||||
version = "1.0.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7079075b41f533b8c61d2a4d073c4676e1f8b249ff94a393b0595db304e0dd87"
|
||||
checksum = "8901269c6307e8d93993578286ac0edf7f195079ffff5ebdeea6a59ffb7e36bc"
|
||||
|
||||
[[package]]
|
||||
name = "anstyle-parse"
|
||||
|
|
@ -252,6 +252,15 @@ version = "0.3.0"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "df8670b8c7b9dae1793364eafadf7239c40d669904660c5960d74cfd80b46a53"
|
||||
|
||||
[[package]]
|
||||
name = "castaway"
|
||||
version = "0.2.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8a17ed5635fc8536268e5d4de1e22e81ac34419e5f052d4d51f4e01dcc263fcc"
|
||||
dependencies = [
|
||||
"rustversion",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "cc"
|
||||
version = "1.0.83"
|
||||
|
|
@ -303,9 +312,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "clap_complete"
|
||||
version = "4.4.9"
|
||||
version = "4.4.10"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "df631ae429f6613fcd3a7c1adbdb65f637271e561b03680adaa6573015dfb106"
|
||||
checksum = "abb745187d7f4d76267b37485a65e0149edd0e91a4cfcdd3f27524ad86cee9f3"
|
||||
dependencies = [
|
||||
"clap",
|
||||
]
|
||||
|
|
@ -371,6 +380,19 @@ version = "1.0.0"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "acbf1af155f9b9ef647e42cdc158db4b64a1b61f743629225fde6f3e0be2a7c7"
|
||||
|
||||
[[package]]
|
||||
name = "compact_str"
|
||||
version = "0.7.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f86b9c4c00838774a6d902ef931eff7470720c51d90c2e32cfe15dc304737b3f"
|
||||
dependencies = [
|
||||
"castaway",
|
||||
"cfg-if",
|
||||
"itoa",
|
||||
"ryu",
|
||||
"static_assertions",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "concurrent-queue"
|
||||
version = "2.4.0"
|
||||
|
|
@ -583,9 +605,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "exr"
|
||||
version = "1.71.0"
|
||||
version = "1.72.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "832a761f35ab3e6664babfbdc6cef35a4860e816ec3916dcfd0882954e98a8a8"
|
||||
checksum = "887d93f60543e9a9362ef8a21beedd0a833c5d9610e18c67abe15a5963dcb1a4"
|
||||
dependencies = [
|
||||
"bit_field",
|
||||
"flume",
|
||||
|
|
@ -805,10 +827,11 @@ checksum = "d2fabcfbdc87f4758337ca535fb41a6d701b65693ce38287d856d1674551ec9b"
|
|||
|
||||
[[package]]
|
||||
name = "half"
|
||||
version = "2.2.1"
|
||||
version = "2.3.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "02b4af3693f1b705df946e9fe5631932443781d0aabb423b62fcd4d73f6d2fd0"
|
||||
checksum = "bc52e53916c08643f1b56ec082790d1e86a32e58dc5268f897f313fbae7b4872"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"crunchy",
|
||||
]
|
||||
|
||||
|
|
@ -830,9 +853,9 @@ checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8"
|
|||
|
||||
[[package]]
|
||||
name = "hermit-abi"
|
||||
version = "0.3.4"
|
||||
version = "0.3.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5d3d0e0f38255e7fa3cf31335b3a56f05febd18025f4db5ef7a0cfb4f8da651f"
|
||||
checksum = "d0c62115964e08cb8039170eb33c1d0e2388a256930279edca206fff675f82c3"
|
||||
|
||||
[[package]]
|
||||
name = "home"
|
||||
|
|
@ -845,9 +868,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "iana-time-zone"
|
||||
version = "0.1.59"
|
||||
version = "0.1.60"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b6a67363e2aa4443928ce15e57ebae94fd8949958fd1223c4cfc0cd473ad7539"
|
||||
checksum = "e7ffbb5a1b541ea2561f8c41c087286cc091e21e556a4f09a8f6cbf17b69b141"
|
||||
dependencies = [
|
||||
"android_system_properties",
|
||||
"core-foundation-sys",
|
||||
|
|
@ -918,9 +941,9 @@ checksum = "029d73f573d8e8d63e6d5020011d3255b28c3ba85d6cf870a07184ed23de9284"
|
|||
|
||||
[[package]]
|
||||
name = "indexmap"
|
||||
version = "2.2.1"
|
||||
version = "2.2.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "433de089bd45971eecf4668ee0ee8f4cec17db4f8bd8f7bc3197a6ce37aa7d9b"
|
||||
checksum = "824b2ae422412366ba479e8111fd301f7b5faece8149317bb81925979a53f520"
|
||||
dependencies = [
|
||||
"equivalent",
|
||||
"hashbrown",
|
||||
|
|
@ -954,9 +977,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "itertools"
|
||||
version = "0.12.0"
|
||||
version = "0.12.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "25db6b064527c5d482d0423354fcd07a89a2dfe07b67892e62411946db7f07b0"
|
||||
checksum = "ba291022dbbd398a455acf126c1e341954079855bc60dfdda641363bd6922569"
|
||||
dependencies = [
|
||||
"either",
|
||||
]
|
||||
|
|
@ -1028,9 +1051,9 @@ checksum = "03087c2bad5e1034e8cace5926dec053fb3790248370865f5117a7d0213354c8"
|
|||
|
||||
[[package]]
|
||||
name = "libc"
|
||||
version = "0.2.152"
|
||||
version = "0.2.153"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "13e3bf6590cbc649f4d1a3eefc9d5d6eb746f5200ffb04e5e142700b8faa56e7"
|
||||
checksum = "9c198f91728a82281a64e1f4f9eeb25d82cb32a5de251c6bd1b5154d63a8e7bd"
|
||||
|
||||
[[package]]
|
||||
name = "libredox"
|
||||
|
|
@ -1094,9 +1117,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "luajit-src"
|
||||
version = "210.5.5+f2336c4"
|
||||
version = "210.5.6+9cc2e42"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d8bcba9790f4e3b1c1467d75cdd011a63bbe6bc75da95af5d2cb4e3631f939c4"
|
||||
checksum = "23b365d859c9ffc187f48bb3e25ec80c3b40cf3f68f53544f4adeaee70554157"
|
||||
dependencies = [
|
||||
"cc",
|
||||
"which",
|
||||
|
|
@ -1135,9 +1158,9 @@ checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a"
|
|||
|
||||
[[package]]
|
||||
name = "miniz_oxide"
|
||||
version = "0.7.1"
|
||||
version = "0.7.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e7810e0be55b428ada41041c41f32c9f1a42817901b4ccf45fa3d4b6561e74c7"
|
||||
checksum = "9d811f3e15f28568be3407c8e7fdb6514c1cda3cb30683f15b6a1a1dc4ea14a7"
|
||||
dependencies = [
|
||||
"adler",
|
||||
"simd-adler32",
|
||||
|
|
@ -1245,6 +1268,12 @@ dependencies = [
|
|||
"winapi",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "num-conv"
|
||||
version = "0.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "51d515d32fb182ee37cda2ccdcb92950d6a3c2893aa280e540671c2cd0f3b1d9"
|
||||
|
||||
[[package]]
|
||||
name = "num-traits"
|
||||
version = "0.2.17"
|
||||
|
|
@ -1494,12 +1523,13 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "ratatui"
|
||||
version = "0.25.0"
|
||||
version = "0.26.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a5659e52e4ba6e07b2dad9f1158f578ef84a73762625ddb51536019f34d180eb"
|
||||
checksum = "154b85ef15a5d1719bcaa193c3c81fe645cd120c156874cd660fe49fd21d1373"
|
||||
dependencies = [
|
||||
"bitflags 2.4.2",
|
||||
"cassowary",
|
||||
"compact_str",
|
||||
"crossterm",
|
||||
"indoc",
|
||||
"itertools",
|
||||
|
|
@ -1600,9 +1630,9 @@ checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2"
|
|||
|
||||
[[package]]
|
||||
name = "rustix"
|
||||
version = "0.38.30"
|
||||
version = "0.38.31"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "322394588aaf33c24007e8bb3238ee3e4c5c09c084ab32bc73890b99ff326bca"
|
||||
checksum = "6ea3e1a662af26cd7a3ba09c0297a31af215563ecf42817c98df621387f4e949"
|
||||
dependencies = [
|
||||
"bitflags 2.4.2",
|
||||
"errno",
|
||||
|
|
@ -1801,6 +1831,12 @@ dependencies = [
|
|||
"syn 1.0.109",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "static_assertions"
|
||||
version = "1.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f"
|
||||
|
||||
[[package]]
|
||||
name = "str-buf"
|
||||
version = "1.0.6"
|
||||
|
|
@ -1815,18 +1851,18 @@ checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623"
|
|||
|
||||
[[package]]
|
||||
name = "strum"
|
||||
version = "0.25.0"
|
||||
version = "0.26.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "290d54ea6f91c969195bdbcd7442c8c2a2ba87da8bf60a7ee86a235d4bc1e125"
|
||||
checksum = "723b93e8addf9aa965ebe2d11da6d7540fa2283fcea14b3371ff055f7ba13f5f"
|
||||
dependencies = [
|
||||
"strum_macros",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "strum_macros"
|
||||
version = "0.25.3"
|
||||
version = "0.26.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "23dc1fa9ac9c169a78ba62f0b841814b7abae11bdd047b9c58f893439e309ea0"
|
||||
checksum = "7a3417fc93d76740d974a01654a09777cb500428cc874ca9f45edfe0c4d4cd18"
|
||||
dependencies = [
|
||||
"heck",
|
||||
"proc-macro2",
|
||||
|
|
@ -1920,13 +1956,14 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "time"
|
||||
version = "0.3.31"
|
||||
version = "0.3.34"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f657ba42c3f86e7680e53c8cd3af8abbe56b5491790b46e22e19c0d57463583e"
|
||||
checksum = "c8248b6521bb14bc45b4067159b9b6ad792e2d6d754d6c41fb50e29fefe38749"
|
||||
dependencies = [
|
||||
"deranged",
|
||||
"itoa",
|
||||
"libc",
|
||||
"num-conv",
|
||||
"num_threads",
|
||||
"powerfmt",
|
||||
"serde",
|
||||
|
|
@ -1942,10 +1979,11 @@ checksum = "ef927ca75afb808a4d64dd374f00a2adf8d0fcff8e7b184af886c3c87ec4a3f3"
|
|||
|
||||
[[package]]
|
||||
name = "time-macros"
|
||||
version = "0.2.16"
|
||||
version = "0.2.17"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "26197e33420244aeb70c3e8c78376ca46571bc4e701e4791c2cd9f57dcb3a43f"
|
||||
checksum = "7ba3a3ef41e6672a2f0f001392bb5dcd3ff0a9992d618ca761a11c3121547774"
|
||||
dependencies = [
|
||||
"num-conv",
|
||||
"time-core",
|
||||
]
|
||||
|
||||
|
|
@ -1966,9 +2004,9 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20"
|
|||
|
||||
[[package]]
|
||||
name = "tokio"
|
||||
version = "1.35.1"
|
||||
version = "1.36.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c89b4efa943be685f629b149f53829423f8f5531ea21249408e8e2f8671ec104"
|
||||
checksum = "61285f6515fa018fb2d1e46eb21223fff441ee8db5d0f1435e8ab4f5cdb80931"
|
||||
dependencies = [
|
||||
"backtrace",
|
||||
"bytes",
|
||||
|
|
@ -2020,9 +2058,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "toml"
|
||||
version = "0.8.8"
|
||||
version = "0.8.9"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a1a195ec8c9da26928f773888e0742ca3ca1040c6cd859c919c9f59c1954ab35"
|
||||
checksum = "c6a4b9e8023eb94392d3dca65d717c53abc5dad49c07cb65bb8fcd87115fa325"
|
||||
dependencies = [
|
||||
"indexmap",
|
||||
"serde",
|
||||
|
|
@ -2042,9 +2080,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "toml_edit"
|
||||
version = "0.21.0"
|
||||
version = "0.21.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d34d383cd00a163b4a5b85053df514d45bc330f6de7737edfe0a93311d1eaa03"
|
||||
checksum = "6a8534fd7f78b5405e860340ad6575217ce99f38d4d5c8f2442cb5ecb50090e1"
|
||||
dependencies = [
|
||||
"indexmap",
|
||||
"serde",
|
||||
|
|
@ -2348,15 +2386,15 @@ checksum = "53a85b86a771b1c87058196170769dd264f66c0782acf1ae6cc51bfd64b39082"
|
|||
|
||||
[[package]]
|
||||
name = "which"
|
||||
version = "5.0.0"
|
||||
version = "6.0.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9bf3ea8596f3a0dd5980b46430f2058dfe2c36a27ccfbb1845d6fbfcd9ba6e14"
|
||||
checksum = "7fa5e0c10bf77f44aac573e498d1a82d5fbd5e91f6fc0a99e7be4b38e85e101c"
|
||||
dependencies = [
|
||||
"either",
|
||||
"home",
|
||||
"once_cell",
|
||||
"rustix",
|
||||
"windows-sys 0.48.0",
|
||||
"windows-sys 0.52.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
|
@ -2599,9 +2637,9 @@ checksum = "dff9641d1cd4be8d1a070daf9e3773c5f67e78b4d9d42263020c057706765c04"
|
|||
|
||||
[[package]]
|
||||
name = "winnow"
|
||||
version = "0.5.35"
|
||||
version = "0.5.37"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1931d78a9c73861da0134f453bb1f790ce49b2e30eba8410b4b79bac72b46a2d"
|
||||
checksum = "a7cad8365489051ae9f054164e459304af2e7e9bb407c958076c8bf4aef52da5"
|
||||
dependencies = [
|
||||
"memchr",
|
||||
]
|
||||
|
|
|
|||
|
|
@ -231,6 +231,7 @@ impl Files {
|
|||
}
|
||||
}
|
||||
|
||||
#[cfg(unix)]
|
||||
pub fn update_deleting(&mut self, urls: Vec<Url>) {
|
||||
if urls.is_empty() {
|
||||
return;
|
||||
|
|
@ -266,6 +267,28 @@ impl Files {
|
|||
}
|
||||
}
|
||||
|
||||
#[cfg(windows)]
|
||||
pub fn update_deleting(&mut self, urls: Vec<Url>) {
|
||||
macro_rules! go {
|
||||
($dist:expr, $src:expr) => {
|
||||
let len = $dist.len();
|
||||
|
||||
$dist.retain(|f| !$src.remove(&f.url));
|
||||
if $dist.len() != len {
|
||||
self.revision += 1;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
let mut urls: BTreeSet<_> = urls.into_iter().collect();
|
||||
if !urls.is_empty() {
|
||||
go!(self.items, urls);
|
||||
}
|
||||
if !urls.is_empty() {
|
||||
go!(self.hidden, urls);
|
||||
}
|
||||
}
|
||||
|
||||
pub fn update_updating(
|
||||
&mut self,
|
||||
files: BTreeMap<Url, File>,
|
||||
|
|
|
|||
|
|
@ -143,7 +143,7 @@ impl Watcher {
|
|||
|
||||
async fn on_changed(rx: UnboundedReceiver<Url>) {
|
||||
// TODO: revert this once a new notification is implemented
|
||||
let rx = UnboundedReceiverStream::new(rx).chunks_timeout(50, Duration::from_millis(20));
|
||||
let rx = UnboundedReceiverStream::new(rx).chunks_timeout(100, Duration::from_millis(20));
|
||||
pin!(rx);
|
||||
|
||||
while let Some(urls) = rx.next().await {
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ impl Tab {
|
|||
};
|
||||
|
||||
self.cd(parent.clone());
|
||||
FilesOp::Creating(parent, vec![File::from_dummy(opt.target.clone())]).emit();
|
||||
FilesOp::Creating(parent, vec![File::from_dummy(&opt.target)]).emit();
|
||||
Manager::_hover(Some(opt.target));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
use std::path::MAIN_SEPARATOR;
|
||||
|
||||
use ratatui::{buffer::Buffer, layout::Rect, widgets::{Block, BorderType, Borders, List, ListItem, Widget}};
|
||||
use ratatui::{buffer::Buffer, layout::Rect, widgets::{Block, BorderType, List, ListItem, Widget}};
|
||||
use yazi_config::{popup::{Offset, Position}, THEME};
|
||||
|
||||
use crate::{widgets, Ctx};
|
||||
|
|
@ -30,9 +30,9 @@ impl<'a> Widget for Completion<'a> {
|
|||
|
||||
let mut item = ListItem::new(format!(" {} {}", icon, x));
|
||||
if i == self.cx.completion.rel_cursor() {
|
||||
item = item.style(THEME.completion.active.into());
|
||||
item = item.style(THEME.completion.active);
|
||||
} else {
|
||||
item = item.style(THEME.completion.inactive.into());
|
||||
item = item.style(THEME.completion.inactive);
|
||||
}
|
||||
|
||||
item
|
||||
|
|
@ -57,10 +57,7 @@ impl<'a> Widget for Completion<'a> {
|
|||
widgets::Clear.render(area, buf);
|
||||
List::new(items)
|
||||
.block(
|
||||
Block::new()
|
||||
.borders(Borders::ALL)
|
||||
.border_type(BorderType::Rounded)
|
||||
.border_style(THEME.completion.border.into()),
|
||||
Block::bordered().border_type(BorderType::Rounded).border_style(THEME.completion.border),
|
||||
)
|
||||
.render(area, buf);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
use ratatui::{buffer::Buffer, layout::{self, Constraint, Direction, Rect}, widgets::{List, ListItem, Widget}};
|
||||
use ratatui::{buffer::Buffer, layout::{self, Constraint, Rect}, widgets::{List, ListItem, Widget}};
|
||||
use yazi_config::THEME;
|
||||
|
||||
use crate::Ctx;
|
||||
|
|
@ -19,24 +19,20 @@ impl Widget for Bindings<'_> {
|
|||
}
|
||||
|
||||
// On
|
||||
let col1 = bindings
|
||||
.iter()
|
||||
.map(|c| ListItem::new(c.on()).style(THEME.help.on.into()))
|
||||
.collect::<Vec<_>>();
|
||||
let col1 =
|
||||
bindings.iter().map(|c| ListItem::new(c.on()).style(THEME.help.on)).collect::<Vec<_>>();
|
||||
|
||||
// Exec
|
||||
let col2 = bindings
|
||||
.iter()
|
||||
.map(|c| ListItem::new(c.exec()).style(THEME.help.exec.into()))
|
||||
.collect::<Vec<_>>();
|
||||
let col2 =
|
||||
bindings.iter().map(|c| ListItem::new(c.exec()).style(THEME.help.exec)).collect::<Vec<_>>();
|
||||
|
||||
// Desc
|
||||
let col3 = bindings
|
||||
.iter()
|
||||
.map(|c| ListItem::new(c.desc.as_deref().unwrap_or("-")).style(THEME.help.desc.into()))
|
||||
.map(|c| ListItem::new(c.desc.as_deref().unwrap_or("-")).style(THEME.help.desc))
|
||||
.collect::<Vec<_>>();
|
||||
|
||||
let chunks = layout::Layout::new(Direction::Horizontal, [
|
||||
let chunks = layout::Layout::horizontal([
|
||||
Constraint::Ratio(2, 10),
|
||||
Constraint::Ratio(3, 10),
|
||||
Constraint::Ratio(5, 10),
|
||||
|
|
@ -46,7 +42,7 @@ impl Widget for Bindings<'_> {
|
|||
let cursor = self.cx.help.rel_cursor() as u16;
|
||||
buf.set_style(
|
||||
Rect { x: area.x, y: area.y + cursor, width: area.width, height: 1 },
|
||||
THEME.help.hovered.into(),
|
||||
THEME.help.hovered,
|
||||
);
|
||||
|
||||
List::new(col1).render(chunks[0], buf);
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
use ratatui::{buffer::Buffer, layout::{self, Constraint, Direction, Rect}, widgets::{Paragraph, Widget}};
|
||||
use ratatui::{buffer::Buffer, layout::{self, Constraint, Rect}, text::Line, widgets::Widget};
|
||||
use yazi_config::THEME;
|
||||
|
||||
use super::Bindings;
|
||||
|
|
@ -14,16 +14,15 @@ impl<'a> Layout<'a> {
|
|||
|
||||
impl<'a> Widget for Layout<'a> {
|
||||
fn render(self, area: Rect, buf: &mut Buffer) {
|
||||
let chunks =
|
||||
layout::Layout::new(Direction::Vertical, [Constraint::Min(0), Constraint::Length(1)])
|
||||
.split(area);
|
||||
|
||||
let help = &self.cx.help;
|
||||
widgets::Clear.render(area, buf);
|
||||
|
||||
let help = &self.cx.help;
|
||||
Paragraph::new(help.keyword().unwrap_or_else(|| format!("{}.help", help.layer.to_string())))
|
||||
.style(THEME.help.footer.into())
|
||||
.render(chunks[1], buf);
|
||||
let chunks = layout::Layout::vertical([Constraint::Min(0), Constraint::Length(1)]).split(area);
|
||||
Line::styled(
|
||||
help.keyword().unwrap_or_else(|| format!("{}.help", help.layer.to_string())),
|
||||
THEME.help.footer,
|
||||
)
|
||||
.render(chunks[1], buf);
|
||||
|
||||
Bindings::new(self.cx).render(chunks[0], buf);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
use std::ops::Range;
|
||||
|
||||
use anyhow::{bail, Result};
|
||||
use ratatui::{buffer::Buffer, layout::Rect, text::Line, widgets::{Block, BorderType, Borders, Paragraph, Widget}};
|
||||
use ratatui::{buffer::Buffer, layout::Rect, text::Line, widgets::{Block, BorderType, Paragraph, Widget}};
|
||||
use syntect::easy::HighlightLines;
|
||||
use yazi_config::THEME;
|
||||
use yazi_core::input::InputMode;
|
||||
|
|
@ -40,17 +40,12 @@ impl<'a> Widget for Input<'a> {
|
|||
widgets::Clear.render(area, buf);
|
||||
Paragraph::new(self.highlighted_value().unwrap_or_else(|_| Line::from(input.value())))
|
||||
.block(
|
||||
Block::new()
|
||||
.borders(Borders::ALL)
|
||||
Block::bordered()
|
||||
.border_type(BorderType::Rounded)
|
||||
.border_style(THEME.input.border.into())
|
||||
.title({
|
||||
let mut line = Line::from(input.title.as_str());
|
||||
line.patch_style(THEME.input.title.into());
|
||||
line
|
||||
}),
|
||||
.border_style(THEME.input.border)
|
||||
.title(Line::styled(&input.title, THEME.input.title)),
|
||||
)
|
||||
.style(THEME.input.value.into())
|
||||
.style(THEME.input.value)
|
||||
.render(area, buf);
|
||||
|
||||
if let Some(Range { start, end }) = input.selected() {
|
||||
|
|
@ -59,7 +54,7 @@ impl<'a> Widget for Input<'a> {
|
|||
|
||||
buf.set_style(
|
||||
Rect { x, y, width: (end - start).min(win.width - x), height: 1.min(win.height - y) },
|
||||
THEME.input.selected.into(),
|
||||
THEME.input.selected,
|
||||
)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
use std::sync::atomic::AtomicBool;
|
||||
|
||||
use ratatui::{buffer::Buffer, layout::{Constraint, Direction, Layout, Rect}, widgets::Widget};
|
||||
use ratatui::{buffer::Buffer, layout::{Constraint, Layout, Rect}, widgets::Widget};
|
||||
|
||||
use super::{completion, input, select, tasks, which};
|
||||
use crate::{components, help, Ctx};
|
||||
|
|
@ -17,12 +17,9 @@ impl<'a> Root<'a> {
|
|||
|
||||
impl<'a> Widget for Root<'a> {
|
||||
fn render(self, area: Rect, buf: &mut Buffer) {
|
||||
let chunks = Layout::new(Direction::Vertical, [
|
||||
Constraint::Length(1),
|
||||
Constraint::Min(0),
|
||||
Constraint::Length(1),
|
||||
])
|
||||
.split(area);
|
||||
let chunks =
|
||||
Layout::vertical([Constraint::Length(1), Constraint::Min(0), Constraint::Length(1)])
|
||||
.split(area);
|
||||
|
||||
components::Header.render(chunks[0], buf);
|
||||
components::Manager.render(chunks[1], buf);
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
use ratatui::{buffer::Buffer, layout::Rect, widgets::{Block, BorderType, Borders, List, ListItem, Widget}};
|
||||
use ratatui::{buffer::Buffer, layout::Rect, widgets::{Block, BorderType, List, ListItem, Widget}};
|
||||
use yazi_config::THEME;
|
||||
|
||||
use crate::{widgets, Ctx};
|
||||
|
|
@ -22,21 +22,20 @@ impl<'a> Widget for Select<'a> {
|
|||
.enumerate()
|
||||
.map(|(i, v)| {
|
||||
if i != select.rel_cursor() {
|
||||
return ListItem::new(format!(" {v}")).style(THEME.select.inactive.into());
|
||||
return ListItem::new(format!(" {v}")).style(THEME.select.inactive);
|
||||
}
|
||||
|
||||
ListItem::new(format!(" {v}")).style(THEME.select.active.into())
|
||||
ListItem::new(format!(" {v}")).style(THEME.select.active)
|
||||
})
|
||||
.collect::<Vec<_>>();
|
||||
|
||||
widgets::Clear.render(area, buf);
|
||||
List::new(items)
|
||||
.block(
|
||||
Block::new()
|
||||
Block::bordered()
|
||||
.title(select.title())
|
||||
.borders(Borders::ALL)
|
||||
.border_type(BorderType::Rounded)
|
||||
.border_style(THEME.select.border.into()),
|
||||
.border_style(THEME.select.border),
|
||||
)
|
||||
.render(area, buf);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
use ratatui::{buffer::Buffer, layout::{self, Alignment, Constraint, Direction, Rect}, text::Line, widgets::{Block, BorderType, Borders, List, ListItem, Padding, Widget}};
|
||||
use ratatui::{buffer::Buffer, layout::{self, Alignment, Constraint, Rect}, text::Line, widgets::{Block, BorderType, List, ListItem, Padding, Widget}};
|
||||
use yazi_config::THEME;
|
||||
use yazi_core::tasks::TASKS_PERCENT;
|
||||
|
||||
|
|
@ -12,14 +12,14 @@ impl<'a> Layout<'a> {
|
|||
pub(crate) fn new(cx: &'a Ctx) -> Self { Self { cx } }
|
||||
|
||||
pub(super) fn area(area: Rect) -> Rect {
|
||||
let chunk = layout::Layout::new(Direction::Vertical, [
|
||||
let chunk = layout::Layout::vertical([
|
||||
Constraint::Percentage((100 - TASKS_PERCENT) / 2),
|
||||
Constraint::Percentage(TASKS_PERCENT),
|
||||
Constraint::Percentage((100 - TASKS_PERCENT) / 2),
|
||||
])
|
||||
.split(area)[1];
|
||||
|
||||
layout::Layout::new(Direction::Horizontal, [
|
||||
layout::Layout::horizontal([
|
||||
Constraint::Percentage((100 - TASKS_PERCENT) / 2),
|
||||
Constraint::Percentage(TASKS_PERCENT),
|
||||
Constraint::Percentage((100 - TASKS_PERCENT) / 2),
|
||||
|
|
@ -33,17 +33,12 @@ impl<'a> Widget for Layout<'a> {
|
|||
let area = Self::area(area);
|
||||
|
||||
widgets::Clear.render(area, buf);
|
||||
let block = Block::new()
|
||||
.title({
|
||||
let mut line = Line::from("Tasks");
|
||||
line.patch_style(THEME.tasks.title.into());
|
||||
line
|
||||
})
|
||||
let block = Block::bordered()
|
||||
.title(Line::styled("Tasks", THEME.tasks.title))
|
||||
.title_alignment(Alignment::Center)
|
||||
.padding(Padding::new(0, 0, 1, 1))
|
||||
.borders(Borders::ALL)
|
||||
.padding(Padding::symmetric(1, 1))
|
||||
.border_type(BorderType::Rounded)
|
||||
.border_style(THEME.tasks.border.into());
|
||||
.border_style(THEME.tasks.border);
|
||||
block.clone().render(area, buf);
|
||||
|
||||
let tasks = &self.cx.tasks;
|
||||
|
|
@ -54,7 +49,7 @@ impl<'a> Widget for Layout<'a> {
|
|||
.map(|(i, v)| {
|
||||
let mut item = ListItem::new(v.name.clone());
|
||||
if i == tasks.cursor {
|
||||
item = item.style(THEME.tasks.hovered.into());
|
||||
item = item.style(THEME.tasks.hovered);
|
||||
}
|
||||
item
|
||||
})
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
use ratatui::{buffer::Buffer, layout::Rect, text::{Line, Span}, widgets::{Paragraph, Widget}};
|
||||
use ratatui::{buffer::Buffer, layout::Rect, text::{Line, Span}, widgets::Widget};
|
||||
use yazi_config::{keymap::Control, THEME};
|
||||
|
||||
pub(super) struct Cand<'a> {
|
||||
|
|
@ -23,17 +23,17 @@ impl Widget for Cand<'_> {
|
|||
spans.push(Span::raw(" ".repeat(10usize.saturating_sub(keys.join("").len()))));
|
||||
|
||||
// First key
|
||||
spans.push(Span::styled(keys[0].clone(), THEME.which.cand.into()));
|
||||
spans.push(Span::styled(keys[0].clone(), THEME.which.cand));
|
||||
|
||||
// Rest keys
|
||||
spans.extend(keys.iter().skip(1).map(|k| Span::styled(k, THEME.which.rest.into())));
|
||||
spans.extend(keys.iter().skip(1).map(|k| Span::styled(k, THEME.which.rest)));
|
||||
|
||||
// Separator
|
||||
spans.push(Span::styled(&THEME.which.separator, THEME.which.separator_style.into()));
|
||||
spans.push(Span::styled(&THEME.which.separator, THEME.which.separator_style));
|
||||
|
||||
// Description
|
||||
spans.push(Span::styled(self.cand.desc_or_exec(), THEME.which.desc.into()));
|
||||
spans.push(Span::styled(self.cand.desc_or_exec(), THEME.which.desc));
|
||||
|
||||
Paragraph::new(Line::from(spans)).render(area, buf);
|
||||
Line::from(spans).render(area, buf);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
use ratatui::{buffer::Buffer, layout, layout::{Constraint, Direction, Rect}, widgets::{Block, Widget}};
|
||||
use ratatui::{buffer::Buffer, layout, layout::{Constraint, Rect}, widgets::{Block, Widget}};
|
||||
use yazi_config::THEME;
|
||||
|
||||
use super::Cand;
|
||||
|
|
@ -38,7 +38,7 @@ impl Widget for Which<'_> {
|
|||
|
||||
let chunks = {
|
||||
use Constraint::*;
|
||||
layout::Layout::new(Direction::Horizontal, match cols {
|
||||
layout::Layout::horizontal(match cols {
|
||||
1 => &[Ratio(1, 1)] as &[Constraint],
|
||||
2 => &[Ratio(1, 2), Ratio(1, 2)],
|
||||
_ => &[Ratio(1, 3), Ratio(1, 3), Ratio(1, 3)],
|
||||
|
|
@ -47,7 +47,7 @@ impl Widget for Which<'_> {
|
|||
};
|
||||
|
||||
widgets::Clear.render(area, buf);
|
||||
Block::new().style(THEME.which.mask.into()).render(area, buf);
|
||||
Block::new().style(THEME.which.mask).render(area, buf);
|
||||
|
||||
for y in 0..area.height {
|
||||
for (x, chunk) in chunks.iter().enumerate() {
|
||||
|
|
|
|||
|
|
@ -11,7 +11,6 @@ where
|
|||
T: IntoLua<'lua>,
|
||||
{
|
||||
fn into_lua(self, lua: &'lua mlua::Lua) -> mlua::Result<mlua::Value> {
|
||||
let tbl = lua.create_sequence_from([self.0.start, self.0.end])?;
|
||||
tbl.into_lua(lua)
|
||||
lua.create_sequence_from([self.0.start, self.0.end])?.into_lua(lua)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -51,7 +51,7 @@ impl UserData for Bar {
|
|||
let mut me = ud.borrow_mut::<Self>()?;
|
||||
match value {
|
||||
Value::Nil => me.style = None,
|
||||
Value::Table(tbl) => me.style = Some(Style::from(tbl).0),
|
||||
Value::Table(tb) => me.style = Some(Style::from(tb).0),
|
||||
Value::UserData(ud) => me.style = Some(ud.borrow::<Style>()?.0),
|
||||
_ => return Err("expected a Style or Table or nil".into_lua_err()),
|
||||
}
|
||||
|
|
|
|||
|
|
@ -71,7 +71,7 @@ impl UserData for Border {
|
|||
let mut me = ud.borrow_mut::<Self>()?;
|
||||
match value {
|
||||
Value::Nil => me.style = None,
|
||||
Value::Table(tbl) => me.style = Some(Style::from(tbl).0),
|
||||
Value::Table(tb) => me.style = Some(Style::from(tb).0),
|
||||
Value::UserData(ud) => me.style = Some(ud.borrow::<Style>()?.0),
|
||||
_ => return Err("expected a Style or Table or nil".into_lua_err()),
|
||||
}
|
||||
|
|
|
|||
|
|
@ -50,7 +50,7 @@ impl UserData for Gauge {
|
|||
methods.add_function("style", |_, (ud, value): (AnyUserData, Value)| {
|
||||
ud.borrow_mut::<Self>()?.style = match value {
|
||||
Value::Nil => None,
|
||||
Value::Table(tbl) => Some(Style::from(tbl).0),
|
||||
Value::Table(tb) => Some(Style::from(tb).0),
|
||||
Value::UserData(ud) => Some(ud.borrow::<Style>()?.0),
|
||||
_ => return Err("expected a Style or Table or nil".into_lua_err()),
|
||||
};
|
||||
|
|
@ -60,7 +60,7 @@ impl UserData for Gauge {
|
|||
methods.add_function("gauge_style", |_, (ud, value): (AnyUserData, Value)| {
|
||||
ud.borrow_mut::<Self>()?.gauge_style = match value {
|
||||
Value::Nil => None,
|
||||
Value::Table(tbl) => Some(Style::from(tbl).0),
|
||||
Value::Table(tb) => Some(Style::from(tb).0),
|
||||
Value::UserData(ud) => Some(ud.borrow::<Style>()?.0),
|
||||
_ => return Err("expected a Style or Table or nil".into_lua_err()),
|
||||
};
|
||||
|
|
|
|||
|
|
@ -12,8 +12,8 @@ pub struct Line(pub(super) ratatui::text::Line<'static>);
|
|||
impl<'a> TryFrom<Table<'a>> for Line {
|
||||
type Error = mlua::Error;
|
||||
|
||||
fn try_from(tbl: Table) -> Result<Self, Self::Error> {
|
||||
let seq: Vec<_> = tbl.sequence_values().filter_map(|v| v.ok()).collect();
|
||||
fn try_from(tb: Table) -> Result<Self, Self::Error> {
|
||||
let seq: Vec<_> = tb.sequence_values().filter_map(|v| v.ok()).collect();
|
||||
let mut spans = Vec::with_capacity(seq.len());
|
||||
for value in seq {
|
||||
if let Value::UserData(ud) = value {
|
||||
|
|
@ -33,8 +33,8 @@ impl<'a> TryFrom<Table<'a>> for Line {
|
|||
impl Line {
|
||||
pub fn install(lua: &Lua, ui: &Table) -> mlua::Result<()> {
|
||||
let new = lua.create_function(|_, (_, value): (Table, Value)| {
|
||||
if let Value::Table(tbl) = value {
|
||||
return Line::try_from(tbl);
|
||||
if let Value::Table(tb) = value {
|
||||
return Line::try_from(tb);
|
||||
}
|
||||
Err("expected a table of Spans or Lines".into_lua_err())
|
||||
})?;
|
||||
|
|
@ -58,12 +58,12 @@ impl UserData for Line {
|
|||
methods.add_function("style", |_, (ud, value): (AnyUserData, Value)| {
|
||||
{
|
||||
let mut me = ud.borrow_mut::<Self>()?;
|
||||
match value {
|
||||
Value::Nil => me.0.reset_style(),
|
||||
Value::Table(tbl) => me.0.patch_style(Style::from(tbl).0),
|
||||
Value::UserData(ud) => me.0.patch_style(ud.borrow::<Style>()?.0),
|
||||
me.0.style = match value {
|
||||
Value::Nil => me.0.style.patch(ratatui::style::Style::reset()),
|
||||
Value::Table(tb) => me.0.style.patch(Style::from(tb).0),
|
||||
Value::UserData(ud) => me.0.style.patch(ud.borrow::<Style>()?.0),
|
||||
_ => return Err("expected a Style or Table or nil".into_lua_err()),
|
||||
}
|
||||
};
|
||||
}
|
||||
Ok(ud)
|
||||
});
|
||||
|
|
|
|||
|
|
@ -83,7 +83,7 @@ impl UserData for ListItem {
|
|||
methods.add_function("style", |_, (ud, value): (AnyUserData, Value)| {
|
||||
ud.borrow_mut::<Self>()?.style = match value {
|
||||
Value::Nil => None,
|
||||
Value::Table(tbl) => Some(Style::from(tbl).0),
|
||||
Value::Table(tb) => Some(Style::from(tb).0),
|
||||
Value::UserData(ud) => Some(ud.borrow::<Style>()?.0),
|
||||
_ => return Err("expected a Style or Table or nil".into_lua_err()),
|
||||
};
|
||||
|
|
|
|||
|
|
@ -16,25 +16,24 @@ impl Padding {
|
|||
(
|
||||
"left",
|
||||
lua.create_function(|lua, left: u16| {
|
||||
Self::cast(lua, ratatui::widgets::Padding::new(left, 0, 0, 0))
|
||||
Self::cast(lua, ratatui::widgets::Padding::left(left))
|
||||
})?,
|
||||
),
|
||||
(
|
||||
"right",
|
||||
lua.create_function(|lua, right: u16| {
|
||||
Self::cast(lua, ratatui::widgets::Padding::new(0, right, 0, 0))
|
||||
Self::cast(lua, ratatui::widgets::Padding::right(right))
|
||||
})?,
|
||||
),
|
||||
(
|
||||
"top",
|
||||
lua.create_function(|lua, top: u16| {
|
||||
Self::cast(lua, ratatui::widgets::Padding::new(0, 0, top, 0))
|
||||
})?,
|
||||
lua
|
||||
.create_function(|lua, top: u16| Self::cast(lua, ratatui::widgets::Padding::top(top)))?,
|
||||
),
|
||||
(
|
||||
"bottom",
|
||||
lua.create_function(|lua, bottom: u16| {
|
||||
Self::cast(lua, ratatui::widgets::Padding::new(0, 0, 0, bottom))
|
||||
Self::cast(lua, ratatui::widgets::Padding::bottom(bottom))
|
||||
})?,
|
||||
),
|
||||
(
|
||||
|
|
|
|||
|
|
@ -63,7 +63,7 @@ impl UserData for Paragraph {
|
|||
let mut me = ud.borrow_mut::<Self>()?;
|
||||
match value {
|
||||
Value::Nil => me.style = None,
|
||||
Value::Table(tbl) => me.style = Some(Style::from(tbl).0),
|
||||
Value::Table(tb) => me.style = Some(Style::from(tb).0),
|
||||
Value::UserData(ud) => me.style = Some(ud.borrow::<Style>()?.0),
|
||||
_ => return Err("expected a Style or Table or nil".into_lua_err()),
|
||||
}
|
||||
|
|
|
|||
|
|
@ -67,7 +67,7 @@ impl UserData for Span {
|
|||
methods.add_function("style", |_, (ud, value): (AnyUserData, Value)| {
|
||||
ud.borrow_mut::<Self>()?.0.style = match value {
|
||||
Value::Nil => ratatui::style::Style::default(),
|
||||
Value::Table(tbl) => Style::from(tbl).0,
|
||||
Value::Table(tb) => Style::from(tb).0,
|
||||
Value::UserData(ud) => ud.borrow::<Style>()?.0,
|
||||
_ => return Err("expected a Style or Table or nil".into_lua_err()),
|
||||
};
|
||||
|
|
|
|||
|
|
@ -41,18 +41,23 @@ impl File {
|
|||
ck |= ChaKind::LINK;
|
||||
}
|
||||
|
||||
#[cfg(unix)]
|
||||
if url.is_hidden() {
|
||||
ck |= ChaKind::HIDDEN;
|
||||
}
|
||||
#[cfg(windows)]
|
||||
{
|
||||
use std::os::windows::fs::MetadataExt;
|
||||
if meta.file_attributes() & 2 != 0 {
|
||||
ck |= ChaKind::HIDDEN;
|
||||
}
|
||||
}
|
||||
|
||||
Self { url, cha: Cha::from(meta).with_kind(ck), link_to }
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn from_dummy(url: Url) -> Self {
|
||||
let ck = if url.is_hidden() { ChaKind::HIDDEN } else { ChaKind::empty() };
|
||||
Self { url, cha: Cha::default().with_kind(ck), link_to: None }
|
||||
}
|
||||
pub fn from_dummy(url: &Url) -> Self { Self { url: url.to_owned(), ..Default::default() } }
|
||||
}
|
||||
|
||||
impl File {
|
||||
|
|
|
|||
|
|
@ -144,6 +144,7 @@ impl Url {
|
|||
#[inline]
|
||||
pub fn into_os_string(self) -> OsString { self.path.into_os_string() }
|
||||
|
||||
#[cfg(unix)]
|
||||
#[inline]
|
||||
pub fn is_hidden(&self) -> bool {
|
||||
self.file_name().map_or(false, |s| s.as_encoded_bytes().starts_with(&[b'.']))
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue