mirror of
https://github.com/sxyazi/yazi.git
synced 2026-07-22 23:31:05 +00:00
feat: search view shares file selection and yank state (#2855)
This commit is contained in:
parent
c0615e5f45
commit
693dff25e3
18 changed files with 108 additions and 101 deletions
80
Cargo.lock
generated
80
Cargo.lock
generated
|
|
@ -68,9 +68,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "anstream"
|
||||
version = "0.6.18"
|
||||
version = "0.6.19"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8acc5369981196006228e28809f761875c0327210a891e941f4c683b3a99529b"
|
||||
checksum = "301af1932e46185686725e0fad2f8f2aa7da69dd70bf6ecc44d6b703844a3933"
|
||||
dependencies = [
|
||||
"anstyle",
|
||||
"anstyle-parse",
|
||||
|
|
@ -83,33 +83,33 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "anstyle"
|
||||
version = "1.0.10"
|
||||
version = "1.0.11"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "55cc3b69f167a1ef2e161439aa98aed94e6028e5f9a59be9a6ffb47aef1651f9"
|
||||
checksum = "862ed96ca487e809f1c8e5a8447f6ee2cf102f846893800b20cebdf541fc6bbd"
|
||||
|
||||
[[package]]
|
||||
name = "anstyle-parse"
|
||||
version = "0.2.6"
|
||||
version = "0.2.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3b2d16507662817a6a20a9ea92df6652ee4f94f914589377d69f3b21bc5798a9"
|
||||
checksum = "4e7644824f0aa2c7b9384579234ef10eb7efb6a0deb83f9630a49594dd9c15c2"
|
||||
dependencies = [
|
||||
"utf8parse",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "anstyle-query"
|
||||
version = "1.1.2"
|
||||
version = "1.1.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "79947af37f4177cfead1110013d678905c37501914fba0efea834c3fe9a8d60c"
|
||||
checksum = "6c8bdeb6047d8983be085bab0ba1472e6dc604e7041dbf6fcd5e71523014fae9"
|
||||
dependencies = [
|
||||
"windows-sys 0.59.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "anstyle-wincon"
|
||||
version = "3.0.8"
|
||||
version = "3.0.9"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6680de5231bd6ee4c6191b8a1325daa282b415391ec9d3a37bd34f2060dc73fa"
|
||||
checksum = "403f75924867bb1033c59fbf0797484329750cfbe3c4325cd33127941fabc882"
|
||||
dependencies = [
|
||||
"anstyle",
|
||||
"once_cell_polyfill",
|
||||
|
|
@ -301,9 +301,9 @@ checksum = "56ed6191a7e78c36abdb16ab65341eefd73d64d303fffccdbb00d51e4205967b"
|
|||
|
||||
[[package]]
|
||||
name = "bumpalo"
|
||||
version = "3.17.0"
|
||||
version = "3.18.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1628fb46dfa0b37568d12e5edd512553eccf6a22a78e8bde00bb4aed84d5bdbf"
|
||||
checksum = "793db76d6187cd04dff33004d8e6c9cc4e05cd330500379d2394209271b4aeee"
|
||||
|
||||
[[package]]
|
||||
name = "by_address"
|
||||
|
|
@ -313,9 +313,9 @@ checksum = "64fa3c856b712db6612c019f14756e64e4bcea13337a6b33b696333a9eaa2d06"
|
|||
|
||||
[[package]]
|
||||
name = "bytemuck"
|
||||
version = "1.23.0"
|
||||
version = "1.23.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9134a6ef01ce4b366b50689c94f82c14bc72bc5d0386829828a2e2752ef7958c"
|
||||
checksum = "5c76a5792e44e4abe34d3abf15636779261d45a7450612059293d1d2cfc63422"
|
||||
|
||||
[[package]]
|
||||
name = "byteorder-lite"
|
||||
|
|
@ -346,9 +346,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "cc"
|
||||
version = "1.2.25"
|
||||
version = "1.2.26"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d0fc897dc1e865cc67c0e05a836d9d3f1df3cbe442aa4a9473b18e12624a4951"
|
||||
checksum = "956a5e21988b87f372569b66183b78babf23ebc2e744b733e4350a752c4dafac"
|
||||
dependencies = [
|
||||
"jobserver",
|
||||
"libc",
|
||||
|
|
@ -469,9 +469,9 @@ checksum = "3d7b894f5411737b7867f4827955924d7c254fc9f4d91a6aad6b097804b1018b"
|
|||
|
||||
[[package]]
|
||||
name = "colorchoice"
|
||||
version = "1.0.3"
|
||||
version = "1.0.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5b63caa9aa9397e2d9480a9b13673856c78d8ac123288526c37d7839f2a86990"
|
||||
checksum = "b05b61dc5112cbb17e4b6cd61790d9845d13888356391624cbe7e41efeac1e75"
|
||||
|
||||
[[package]]
|
||||
name = "compact_str"
|
||||
|
|
@ -870,9 +870,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "flate2"
|
||||
version = "1.1.1"
|
||||
version = "1.1.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7ced92e76e966ca2fd84c8f7aa01a4aea65b0eb6648d72f7c8f3e2764a67fece"
|
||||
checksum = "4a3d7db9596fecd151c5f638c0ee5d5bd487b6e0ea232e5dc96d5250f6f94b1d"
|
||||
dependencies = [
|
||||
"crc32fast",
|
||||
"miniz_oxide",
|
||||
|
|
@ -1058,9 +1058,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "hashbrown"
|
||||
version = "0.15.3"
|
||||
version = "0.15.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "84b26c544d002229e640969970a2e74021aadf6e2f96372b9c58eff97de08eb3"
|
||||
checksum = "5971ac85611da7067dbfcabef3c70ebb5606018acd9e2a3903a0da507521e0d5"
|
||||
dependencies = [
|
||||
"allocator-api2",
|
||||
"equivalent",
|
||||
|
|
@ -2282,9 +2282,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "serde_spanned"
|
||||
version = "0.6.8"
|
||||
version = "0.6.9"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "87607cb1398ed59d48732e575a4c28a7a8ebf2454b964fe3f224f2afc07909e1"
|
||||
checksum = "bf41e0cfaf7226dca15e8197172c295a782857fcb97fad1808a166870dee75a3"
|
||||
dependencies = [
|
||||
"serde",
|
||||
]
|
||||
|
|
@ -2378,9 +2378,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "smallvec"
|
||||
version = "1.15.0"
|
||||
version = "1.15.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8917285742e9f3e1683f0a9c4e6b57960b7314d0b08d30d1ecd426713ee2eee9"
|
||||
checksum = "67b1b7a3b5fe4f1376887184045fcf45c69e92af734b7aaddc05fb777b6fbd03"
|
||||
|
||||
[[package]]
|
||||
name = "smawk"
|
||||
|
|
@ -2658,9 +2658,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "toml"
|
||||
version = "0.8.22"
|
||||
version = "0.8.23"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "05ae329d1f08c4d17a59bed7ff5b5a769d062e64a62d34a3261b219e62cd5aae"
|
||||
checksum = "dc1beb996b9d83529a9e75c17a1686767d148d70663143c7854d8b4a09ced362"
|
||||
dependencies = [
|
||||
"serde",
|
||||
"serde_spanned",
|
||||
|
|
@ -2670,18 +2670,18 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "toml_datetime"
|
||||
version = "0.6.9"
|
||||
version = "0.6.11"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3da5db5a963e24bc68be8b17b6fa82814bb22ee8660f192bb182771d498f09a3"
|
||||
checksum = "22cddaf88f4fbc13c51aebbf5f8eceb5c7c5a9da2ac40a13519eb5b0a0e8f11c"
|
||||
dependencies = [
|
||||
"serde",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "toml_edit"
|
||||
version = "0.22.26"
|
||||
version = "0.22.27"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "310068873db2c5b3e7659d2cc35d21855dbafa50d1ce336397c666e3cb08137e"
|
||||
checksum = "41fe8c660ae4257887cf66394862d21dbca4a6ddd26f04a3560410406a2f819a"
|
||||
dependencies = [
|
||||
"indexmap",
|
||||
"serde",
|
||||
|
|
@ -2693,9 +2693,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "toml_write"
|
||||
version = "0.1.1"
|
||||
version = "0.1.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "bfb942dfe1d8e29a7ee7fcbde5bd2b9a25fb89aa70caea2eba3bee836ff41076"
|
||||
checksum = "5d99f8c9a7727884afe522e9bd5edbfc91a3312b36a77b5fb8926e4c31a41801"
|
||||
|
||||
[[package]]
|
||||
name = "tracing"
|
||||
|
|
@ -2722,9 +2722,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "tracing-attributes"
|
||||
version = "0.1.28"
|
||||
version = "0.1.29"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "395ae124c09f9e6918a2310af6038fba074bcf474ac352496d5910dd59a2226d"
|
||||
checksum = "1b1ffbcf9c6f6b99d386e7444eb608ba646ae452a36b39737deb9663b610f662"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
|
|
@ -2733,9 +2733,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "tracing-core"
|
||||
version = "0.1.33"
|
||||
version = "0.1.34"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e672c95779cf947c5311f83787af4fa8fffd12fb27e4993211a84bdfd9610f9c"
|
||||
checksum = "b9d12581f227e93f094d3af2ae690a574abb8a2b9b7a96e7cfe9647b2b617678"
|
||||
dependencies = [
|
||||
"once_cell",
|
||||
"valuable",
|
||||
|
|
@ -3708,9 +3708,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "zune-jpeg"
|
||||
version = "0.4.14"
|
||||
version = "0.4.16"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "99a5bab8d7dedf81405c4bb1f2b83ea057643d9cb28778cea9eecddeedd2e028"
|
||||
checksum = "3e4a518c0ea2576f4da876349d7f67a7be489297cd77c2cf9e04c2e05fcd3974"
|
||||
dependencies = [
|
||||
"zune-core",
|
||||
]
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@ syntect = { version = "5.2.0", default-features = false, features =
|
|||
tokio = { version = "1.45.1", features = [ "full" ] }
|
||||
tokio-stream = "0.1.17"
|
||||
tokio-util = "0.7.15"
|
||||
toml = { version = "0.8.22" }
|
||||
toml = { version = "0.8.23" }
|
||||
tracing = { version = "0.1.41", features = [ "max_level_debug", "release_max_level_debug" ] }
|
||||
twox-hash = { version = "2.1.0", default-features = false, features = [ "std", "random", "xxhash3_128" ] }
|
||||
unicode-width = { version = "0.2.0", default-features = false }
|
||||
|
|
|
|||
|
|
@ -8,22 +8,22 @@ pub enum Error {
|
|||
Io(std::io::Error),
|
||||
IoKind(std::io::ErrorKind),
|
||||
Serde(serde_json::Error),
|
||||
Custom(String),
|
||||
Custom(Cow<'static, str>),
|
||||
}
|
||||
|
||||
impl Error {
|
||||
pub fn install(lua: &Lua) -> mlua::Result<()> {
|
||||
let new = lua.create_function(|_, msg: String| Ok(Error::Custom(msg)))?;
|
||||
let new = lua.create_function(|_, msg: String| Ok(Error::Custom(msg.into())))?;
|
||||
|
||||
lua.globals().raw_set("Error", lua.create_table_from([("custom", new)])?)
|
||||
}
|
||||
|
||||
fn to_string(&self) -> Cow<str> {
|
||||
pub fn into_string(self) -> Cow<'static, str> {
|
||||
match self {
|
||||
Error::Io(e) => Cow::Owned(e.to_string()),
|
||||
Error::IoKind(e) => Cow::Owned(e.to_string()),
|
||||
Error::Serde(e) => Cow::Owned(e.to_string()),
|
||||
Error::Custom(s) => Cow::Borrowed(s),
|
||||
Error::Custom(s) => s,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -60,7 +60,10 @@ impl UserData for Error {
|
|||
|
||||
fn add_methods<M: UserDataMethods<Self>>(methods: &mut M) {
|
||||
methods.add_meta_method(MetaMethod::ToString, |lua, me, ()| {
|
||||
lua.create_string(me.to_string().as_ref())
|
||||
Ok(match me {
|
||||
Error::Io(_) | Error::IoKind(_) | Error::Serde(_) => lua.create_string(me.to_string()),
|
||||
Error::Custom(s) => lua.create_string(s.as_ref()),
|
||||
})
|
||||
});
|
||||
methods.add_meta_function(MetaMethod::Concat, |lua, (lhs, rhs): (Value, Value)| {
|
||||
match (lhs, rhs) {
|
||||
|
|
|
|||
|
|
@ -37,20 +37,20 @@ pub(super) enum Command {
|
|||
|
||||
#[derive(clap::Args)]
|
||||
pub(super) struct CommandEmit {
|
||||
/// The name of the command.
|
||||
/// Name of the command.
|
||||
pub(super) name: String,
|
||||
/// The arguments of the command.
|
||||
/// Arguments of the command.
|
||||
#[arg(allow_hyphen_values = true, trailing_var_arg = true)]
|
||||
pub(super) args: Vec<String>,
|
||||
}
|
||||
|
||||
#[derive(clap::Args)]
|
||||
pub(super) struct CommandEmitTo {
|
||||
/// The receiver ID.
|
||||
/// Receiver ID.
|
||||
pub(super) receiver: Id,
|
||||
/// The name of the command.
|
||||
/// Name of the command.
|
||||
pub(super) name: String,
|
||||
/// The arguments of the command.
|
||||
/// Arguments of the command.
|
||||
#[arg(allow_hyphen_values = true, trailing_var_arg = true)]
|
||||
pub(super) args: Vec<String>,
|
||||
}
|
||||
|
|
@ -60,14 +60,14 @@ pub(super) enum CommandPkg {
|
|||
/// Add packages.
|
||||
#[command(arg_required_else_help = true)]
|
||||
Add {
|
||||
/// The packages to add.
|
||||
/// Packages to add.
|
||||
#[arg(index = 1, num_args = 1..)]
|
||||
ids: Vec<String>,
|
||||
},
|
||||
/// Delete packages.
|
||||
#[command(arg_required_else_help = true)]
|
||||
Delete {
|
||||
/// The packages to delete.
|
||||
/// Packages to delete.
|
||||
#[arg(index = 1, num_args = 1..)]
|
||||
ids: Vec<String>,
|
||||
},
|
||||
|
|
@ -76,10 +76,9 @@ pub(super) enum CommandPkg {
|
|||
/// List all packages.
|
||||
List,
|
||||
/// Upgrade all packages.
|
||||
#[command(arg_required_else_help = true)]
|
||||
Upgrade {
|
||||
/// The packages to delete.
|
||||
#[arg(index = 1, num_args = 1..)]
|
||||
/// Packages to upgrade, upgrade all if unspecified.
|
||||
#[arg(index = 1, num_args = 0..)]
|
||||
ids: Vec<String>,
|
||||
},
|
||||
}
|
||||
|
|
@ -106,7 +105,7 @@ pub(super) struct CommandPack {
|
|||
|
||||
#[derive(clap::Args)]
|
||||
pub(super) struct CommandPub {
|
||||
/// The kind of message.
|
||||
/// Kind of message.
|
||||
#[arg(index = 1)]
|
||||
pub(super) kind: String,
|
||||
/// Send the message with a string body.
|
||||
|
|
@ -133,10 +132,10 @@ impl CommandPub {
|
|||
|
||||
#[derive(clap::Args)]
|
||||
pub(super) struct CommandPubTo {
|
||||
/// The receiver ID.
|
||||
/// Receiver ID.
|
||||
#[arg(index = 1)]
|
||||
pub(super) receiver: Id,
|
||||
/// The kind of message.
|
||||
/// Kind of message.
|
||||
#[arg(index = 2)]
|
||||
pub(super) kind: String,
|
||||
/// Send the message with a string body.
|
||||
|
|
@ -152,7 +151,7 @@ pub(super) struct CommandPubTo {
|
|||
|
||||
#[derive(clap::Args)]
|
||||
pub(super) struct CommandSub {
|
||||
/// The kind of messages to subscribe to, separated by commas if multiple.
|
||||
/// Kind of messages to subscribe to, separated by commas if multiple.
|
||||
#[arg(index = 1)]
|
||||
pub(super) kinds: String,
|
||||
}
|
||||
|
|
|
|||
|
|
@ -62,7 +62,7 @@ impl Package {
|
|||
pub(crate) async fn upgrade_many(&mut self, uses: &[String]) -> Result<()> {
|
||||
macro_rules! go {
|
||||
($dep:expr) => {
|
||||
if uses.contains(&$dep.r#use) {
|
||||
if uses.is_empty() || uses.contains(&$dep.r#use) {
|
||||
let r = $dep.upgrade().await;
|
||||
self.save().await?;
|
||||
r?;
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ ratatui = { workspace = true }
|
|||
regex = { workspace = true }
|
||||
serde = { workspace = true }
|
||||
toml = { workspace = true }
|
||||
toml_edit = "0.22.26"
|
||||
toml_edit = "0.22.27"
|
||||
tracing = { workspace = true }
|
||||
|
||||
[target.'cfg(target_os = "macos")'.dependencies]
|
||||
|
|
|
|||
|
|
@ -83,7 +83,7 @@ micro_workers = 10
|
|||
macro_workers = 10
|
||||
bizarre_retry = 3
|
||||
image_alloc = 536870912 # 512MB
|
||||
image_bound = [ 5000, 5000 ]
|
||||
image_bound = [ 10000, 10000 ]
|
||||
suppress_preload = false
|
||||
|
||||
[plugin]
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ use yazi_dds::Pubsub;
|
|||
use yazi_fs::FilesOp;
|
||||
use yazi_shared::url::Url;
|
||||
|
||||
#[derive(Default)]
|
||||
#[derive(Debug, Default)]
|
||||
pub struct Yanked {
|
||||
pub cut: bool,
|
||||
urls: HashSet<Url>,
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ function M:peek(job)
|
|||
ya.sleep(math.max(0, rt.preview.image_delay / 1000 + start - os.clock()))
|
||||
|
||||
local _, err = ya.image_show(cache, job.area)
|
||||
ya.preview_widget(job, err and ui.Text(tostring(err)):area(job.area):wrap(ui.Wrap.YES))
|
||||
ya.preview_widget(job, err and ui.Text(err):area(job.area):wrap(ui.Wrap.YES))
|
||||
end
|
||||
|
||||
function M:seek() end
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ function M:peek(job)
|
|||
ya.sleep(math.max(0, rt.preview.image_delay / 1000 + start - os.clock()))
|
||||
|
||||
local _, err = ya.image_show(url, job.area)
|
||||
ya.preview_widget(job, err and ui.Text(tostring(err)):area(job.area):wrap(ui.Wrap.YES))
|
||||
ya.preview_widget(job, err and ui.Text(err):area(job.area):wrap(ui.Wrap.YES))
|
||||
end
|
||||
|
||||
function M:seek() end
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ function M:peek(job)
|
|||
ya.sleep(math.max(0, rt.preview.image_delay / 1000 + start - os.clock()))
|
||||
|
||||
local _, err = ya.image_show(cache, job.area)
|
||||
ya.preview_widget(job, err and ui.Text(tostring(err)):area(job.area):wrap(ui.Wrap.YES))
|
||||
ya.preview_widget(job, err and ui.Text(err):area(job.area):wrap(ui.Wrap.YES))
|
||||
end
|
||||
|
||||
function M:seek() end
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ function M:peek(job)
|
|||
ya.sleep(math.max(0, rt.preview.image_delay / 1000 + start - os.clock()))
|
||||
|
||||
local _, err = ya.image_show(cache, job.area)
|
||||
ya.preview_widget(job, err and ui.Text(tostring(err)):area(job.area):wrap(ui.Wrap.YES))
|
||||
ya.preview_widget(job, err and ui.Text(err):area(job.area):wrap(ui.Wrap.YES))
|
||||
end
|
||||
|
||||
function M:seek(job)
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ function M:peek(job)
|
|||
ya.sleep(math.max(0, rt.preview.image_delay / 1000 + start - os.clock()))
|
||||
|
||||
local _, err = ya.image_show(cache, job.area)
|
||||
ya.preview_widget(job, err and ui.Text(tostring(err)):area(job.area):wrap(ui.Wrap.YES))
|
||||
ya.preview_widget(job, err and ui.Text(err):area(job.area):wrap(ui.Wrap.YES))
|
||||
end
|
||||
|
||||
function M:seek() end
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ function M:peek(job)
|
|||
ya.sleep(math.max(0, rt.preview.image_delay / 1000 + start - os.clock()))
|
||||
|
||||
local _, err = ya.image_show(cache, job.area)
|
||||
ya.preview_widget(job, err and ui.Text(tostring(err)):area(job.area):wrap(ui.Wrap.YES))
|
||||
ya.preview_widget(job, err and ui.Text(err):area(job.area):wrap(ui.Wrap.YES))
|
||||
end
|
||||
|
||||
function M:seek(job)
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ impl UserData for MpscTx {
|
|||
methods.add_async_method("send", |lua, me, value: Value| async move {
|
||||
match me.0.send(value).await {
|
||||
Ok(()) => true.into_lua_multi(&lua),
|
||||
Err(e) => (false, Error::Custom(e.to_string())).into_lua_multi(&lua),
|
||||
Err(e) => (false, Error::Custom(e.to_string().into())).into_lua_multi(&lua),
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
@ -33,7 +33,7 @@ impl UserData for MpscUnboundedTx {
|
|||
fn add_methods<M: mlua::UserDataMethods<Self>>(methods: &mut M) {
|
||||
methods.add_method("send", |lua, me, value: Value| match me.0.send(value) {
|
||||
Ok(()) => true.into_lua_multi(lua),
|
||||
Err(e) => (false, Error::Custom(e.to_string())).into_lua_multi(lua),
|
||||
Err(e) => (false, Error::Custom(e.to_string().into())).into_lua_multi(lua),
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
@ -60,7 +60,7 @@ impl UserData for OneshotTx {
|
|||
};
|
||||
match tx.send(value) {
|
||||
Ok(()) => true.into_lua_multi(lua),
|
||||
Err(_) => (false, Error::Custom("Oneshot receiver closed".to_string())).into_lua_multi(lua),
|
||||
Err(_) => (false, Error::Custom("Oneshot receiver closed".into())).into_lua_multi(lua),
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
@ -74,7 +74,7 @@ impl UserData for OneshotRx {
|
|||
};
|
||||
match rx.await {
|
||||
Ok(value) => value.into_lua_multi(&lua),
|
||||
Err(e) => (Value::Nil, Error::Custom(e.to_string())).into_lua_multi(&lua),
|
||||
Err(e) => (Value::Nil, Error::Custom(e.to_string().into())).into_lua_multi(&lua),
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,8 +1,9 @@
|
|||
use std::mem;
|
||||
use std::{any::TypeId, mem};
|
||||
|
||||
use ansi_to_tui::IntoText;
|
||||
use mlua::{AnyUserData, ExternalError, ExternalResult, IntoLua, Lua, MetaMethod, Table, UserData, Value};
|
||||
use ratatui::widgets::Widget;
|
||||
use yazi_binding::Error;
|
||||
|
||||
use super::{Area, Line, Span, Wrap};
|
||||
use crate::elements::Align;
|
||||
|
|
@ -53,17 +54,13 @@ impl TryFrom<Value> for Text {
|
|||
let inner = match value {
|
||||
Value::Table(tb) => return Self::try_from(tb),
|
||||
Value::String(s) => s.to_string_lossy().into(),
|
||||
Value::UserData(ud) => {
|
||||
if let Ok(Line { inner: line, .. }) = ud.take() {
|
||||
line.into()
|
||||
} else if let Ok(Span(span)) = ud.take() {
|
||||
span.into()
|
||||
} else if let Ok(text) = ud.take() {
|
||||
return Ok(text);
|
||||
} else {
|
||||
Err(EXPECTED.into_lua_err())?
|
||||
}
|
||||
}
|
||||
Value::UserData(ud) => match ud.type_id() {
|
||||
Some(t) if t == TypeId::of::<Line>() => ud.take::<Line>()?.inner.into(),
|
||||
Some(t) if t == TypeId::of::<Span>() => ud.take::<Span>()?.0.into(),
|
||||
Some(t) if t == TypeId::of::<Text>() => return ud.take(),
|
||||
Some(t) if t == TypeId::of::<Error>() => ud.take::<Error>()?.into_string().into(),
|
||||
_ => Err(EXPECTED.into_lua_err())?,
|
||||
},
|
||||
_ => Err(EXPECTED.into_lua_err())?,
|
||||
};
|
||||
Ok(Self { inner, ..Default::default() })
|
||||
|
|
@ -76,19 +73,16 @@ impl TryFrom<Table> for Text {
|
|||
fn try_from(tb: Table) -> Result<Self, Self::Error> {
|
||||
let mut lines = Vec::with_capacity(tb.raw_len());
|
||||
for v in tb.sequence_values() {
|
||||
match v? {
|
||||
Value::String(s) => lines.push(s.to_string_lossy().into()),
|
||||
Value::UserData(ud) => {
|
||||
if let Ok(Span(span)) = ud.take() {
|
||||
lines.push(span.into());
|
||||
} else if let Ok(Line { inner: line, .. }) = ud.take() {
|
||||
lines.push(line);
|
||||
} else {
|
||||
return Err(EXPECTED.into_lua_err());
|
||||
}
|
||||
}
|
||||
lines.push(match v? {
|
||||
Value::String(s) => s.to_string_lossy().into(),
|
||||
Value::UserData(ud) => match ud.type_id() {
|
||||
Some(t) if t == TypeId::of::<Span>() => ud.take::<Span>()?.0.into(),
|
||||
Some(t) if t == TypeId::of::<Line>() => ud.take::<Line>()?.inner,
|
||||
Some(t) if t == TypeId::of::<Error>() => ud.take::<Error>()?.into_string().into(),
|
||||
_ => Err(EXPECTED.into_lua_err())?,
|
||||
},
|
||||
_ => Err(EXPECTED.into_lua_err())?,
|
||||
}
|
||||
})
|
||||
}
|
||||
Ok(Self { inner: lines.into(), ..Default::default() })
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ impl Utils {
|
|||
lua.create_async_function(|lua, url: UrlRef| async move {
|
||||
match yazi_adapter::ImageInfo::new(&url).await {
|
||||
Ok(info) => ImageInfo::from(info).into_lua_multi(&lua),
|
||||
Err(e) => (Value::Nil, Error::Custom(e.to_string())).into_lua_multi(&lua),
|
||||
Err(e) => (Value::Nil, Error::Custom(e.to_string().into())).into_lua_multi(&lua),
|
||||
}
|
||||
})
|
||||
}
|
||||
|
|
@ -19,7 +19,7 @@ impl Utils {
|
|||
lua.create_async_function(|lua, (url, rect): (UrlRef, Rect)| async move {
|
||||
match ADAPTOR.get().image_show(&url, *rect).await {
|
||||
Ok(area) => Rect::from(area).into_lua_multi(&lua),
|
||||
Err(e) => (Value::Nil, Error::Custom(e.to_string())).into_lua_multi(&lua),
|
||||
Err(e) => (Value::Nil, Error::Custom(e.to_string().into())).into_lua_multi(&lua),
|
||||
}
|
||||
})
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ use crate::url::Loc;
|
|||
|
||||
const ENCODE_SET: &AsciiSet = &CONTROLS.add(b'#');
|
||||
|
||||
#[derive(Clone, Default, Eq, Ord, PartialEq, PartialOrd)]
|
||||
#[derive(Clone, Default, Eq, Ord, PartialOrd)]
|
||||
pub struct Url {
|
||||
loc: Loc,
|
||||
scheme: UrlScheme,
|
||||
|
|
@ -279,6 +279,17 @@ impl Hash for Url {
|
|||
}
|
||||
}
|
||||
|
||||
impl PartialEq for Url {
|
||||
fn eq(&self, other: &Self) -> bool {
|
||||
match (self.scheme, other.scheme) {
|
||||
(UrlScheme::Regular | UrlScheme::SearchItem, UrlScheme::Regular | UrlScheme::SearchItem) => {
|
||||
self.loc == other.loc
|
||||
}
|
||||
_ => self.loc == other.loc && self.scheme == other.scheme,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Serialize for Url {
|
||||
fn serialize<S: serde::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
|
||||
serializer.collect_str(self)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue