mirror of
https://github.com/sxyazi/yazi.git
synced 2026-05-13 08:16:40 +00:00
feat: new base field for the Url userdata (#2492)
This commit is contained in:
parent
c5808a0db4
commit
7632163678
7 changed files with 15 additions and 16 deletions
|
|
@ -28,7 +28,7 @@ Yazi (means "duck") is a terminal file manager written in Rust, based on non-blo
|
|||
- 🧰 Integration with ripgrep, fd, fzf, zoxide
|
||||
- 💫 Vim-like input/pick/confirm/which/notify component, auto-completion for cd paths
|
||||
- 🏷️ Multi-Tab Support, Cross-directory selection, Scrollable Preview (for videos, PDFs, archives, code, directories, etc.)
|
||||
- 🔄 Bulk Renaming, Visual Mode, File Chooser, [Git Integration](https://github.com/yazi-rs/plugins/tree/main/git.yazi), [Mount Manager](https://github.com/yazi-rs/plugins/tree/main/mount.yazi)
|
||||
- 🔄 Bulk Renaming, Archive Extraction, Visual Mode, File Chooser, [Git Integration](https://github.com/yazi-rs/plugins/tree/main/git.yazi), [Mount Manager](https://github.com/yazi-rs/plugins/tree/main/mount.yazi)
|
||||
- 🎨 Theme System, Mouse Support, Trash Bin, Custom Layouts, CSI u, OSC 52
|
||||
- ... and more!
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
#!/bin/bash
|
||||
set -euo pipefail
|
||||
|
||||
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
cd $SCRIPT_DIR/..
|
||||
|
||||
echo "Bumping version: $1"
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
# Default Configuration
|
||||
|
||||
> [!IMPORTANT]
|
||||
> If you're using a stable release of Yazi instead of the latest nightly build, make sure you're checking these files from [the `shipped` tag][shipped], not the latest main branch.
|
||||
> If you're using a stable release of Yazi instead of the newest nightly build, make sure you're checking these files out from [the `shipped` tag][shipped], not the newest `main` branch.
|
||||
|
||||
This directory contains the default configuration files for Yazi:
|
||||
|
||||
|
|
|
|||
|
|
@ -32,6 +32,7 @@ impl Tasks {
|
|||
|
||||
terminal_clear(TTY.writer()).ok();
|
||||
TTY.writer().write_all(buffered.as_bytes()).ok();
|
||||
TTY.writer().flush().ok();
|
||||
|
||||
defer! { disable_raw_mode().ok(); }
|
||||
enable_raw_mode().ok();
|
||||
|
|
|
|||
|
|
@ -168,19 +168,11 @@ impl Sendable {
|
|||
}
|
||||
|
||||
pub fn list_to_values(lua: &Lua, data: Vec<Data>) -> mlua::Result<MultiValue> {
|
||||
let mut vec = Vec::with_capacity(data.len());
|
||||
for v in data {
|
||||
vec.push(Self::data_to_value(lua, v)?);
|
||||
}
|
||||
Ok(MultiValue::from_vec(vec))
|
||||
data.into_iter().map(|d| Self::data_to_value(lua, d)).collect()
|
||||
}
|
||||
|
||||
pub fn values_to_list(values: MultiValue) -> mlua::Result<Vec<Data>> {
|
||||
let mut vec = Vec::with_capacity(values.len());
|
||||
for value in values {
|
||||
vec.push(Self::value_to_data(value)?);
|
||||
}
|
||||
Ok(vec)
|
||||
values.into_iter().map(Self::value_to_data).collect()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -8,6 +8,9 @@ impl Url {
|
|||
pub fn register(lua: &Lua) -> mlua::Result<()> {
|
||||
lua.register_userdata_type::<yazi_shared::url::Url>(|reg| {
|
||||
reg.add_method("frag", |lua, me, ()| lua.create_string(me.frag()));
|
||||
reg.add_field_method_get("base", |_, me| {
|
||||
Ok(if me.base().as_os_str().is_empty() { None } else { Some(Self::from(me.base())) })
|
||||
});
|
||||
reg.add_field_method_get("is_regular", |_, me| Ok(me.is_regular()));
|
||||
reg.add_field_method_get("is_search", |_, me| Ok(me.is_search()));
|
||||
reg.add_field_method_get("is_archive", |_, me| Ok(me.is_archive()));
|
||||
|
|
@ -15,7 +18,10 @@ impl Url {
|
|||
reg.add_field_method_get("has_root", |_, me| Ok(me.has_root()));
|
||||
|
||||
reg.add_method("name", |lua, me, ()| {
|
||||
me.file_name().map(|s| lua.create_string(s.as_encoded_bytes())).transpose()
|
||||
Some(me.name())
|
||||
.filter(|&s| !s.is_empty())
|
||||
.map(|s| lua.create_string(s.as_encoded_bytes()))
|
||||
.transpose()
|
||||
});
|
||||
reg.add_method("stem", |lua, me, ()| {
|
||||
me.file_stem().map(|s| lua.create_string(s.as_encoded_bytes())).transpose()
|
||||
|
|
|
|||
|
|
@ -91,9 +91,9 @@ impl Utils {
|
|||
let args = [Ok(Value::Table(plugin))]
|
||||
.into_iter()
|
||||
.chain(args.into_iter().map(|d| Sendable::data_to_value(lua, d)))
|
||||
.collect::<mlua::Result<_>>()?;
|
||||
.collect::<mlua::Result<MultiValue>>()?;
|
||||
|
||||
let values = Sendable::values_to_list(block.call(MultiValue::from_vec(args))?)?;
|
||||
let values = Sendable::values_to_list(block.call(args)?)?;
|
||||
tx.send(values).map_err(|_| "send failed".into_lua_err())
|
||||
})
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue