mirror of
https://github.com/sxyazi/yazi.git
synced 2026-07-25 08:41:05 +00:00
..
This commit is contained in:
parent
6ca1c6315a
commit
93604362d7
4 changed files with 12 additions and 6 deletions
|
|
@ -31,7 +31,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/):
|
||||||
- New `ind-which-activate` DDS event to change the which component behavior ([#3608])
|
- New `ind-which-activate` DDS event to change the which component behavior ([#3608])
|
||||||
- New `hey` DDS event fires when static messages are restored from persistence ([#3725])
|
- New `hey` DDS event fires when static messages are restored from persistence ([#3725])
|
||||||
- New `cx.which` API to access the which component state ([#3617])
|
- New `cx.which` API to access the which component state ([#3617])
|
||||||
- New experimental `ya.co()` API that creates a coroutine ([#1234])
|
- New experimental `ya.co()` API that creates a coroutine ([#3757])
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
|
|
||||||
|
|
@ -1681,3 +1681,4 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/):
|
||||||
[#3733]: https://github.com/sxyazi/yazi/pull/3733
|
[#3733]: https://github.com/sxyazi/yazi/pull/3733
|
||||||
[#3744]: https://github.com/sxyazi/yazi/pull/3744
|
[#3744]: https://github.com/sxyazi/yazi/pull/3744
|
||||||
[#3748]: https://github.com/sxyazi/yazi/pull/3748
|
[#3748]: https://github.com/sxyazi/yazi/pull/3748
|
||||||
|
[#3757]: https://github.com/sxyazi/yazi/pull/3757
|
||||||
|
|
|
||||||
|
|
@ -50,7 +50,7 @@ function M:seek(job)
|
||||||
end
|
end
|
||||||
|
|
||||||
function M:spot(job)
|
function M:spot(job)
|
||||||
local i = 0
|
local i, url = 0, job.file.url
|
||||||
for rows in self:spot_base(job) do
|
for rows in self:spot_base(job) do
|
||||||
i, rows[#rows + 1] = i + 1, ui.Row {}
|
i, rows[#rows + 1] = i + 1, ui.Row {}
|
||||||
ya.spot_table(
|
ya.spot_table(
|
||||||
|
|
@ -64,6 +64,9 @@ function M:spot(job)
|
||||||
:widths { ui.Constraint.Length(14), ui.Constraint.Fill(1) }
|
:widths { ui.Constraint.Length(14), ui.Constraint.Fill(1) }
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
if self.size then
|
||||||
|
ya.emit("update_files", { op = fs.op("size", { url = url.parent, sizes = { [url.urn] = self.size } }) })
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function M:spot_base(job)
|
function M:spot_base(job)
|
||||||
|
|
@ -74,6 +77,7 @@ function M:spot_base(job)
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
self.size = nil
|
||||||
return ya.co(function()
|
return ya.co(function()
|
||||||
yield("0B (?)")
|
yield("0B (?)")
|
||||||
|
|
||||||
|
|
@ -94,6 +98,7 @@ function M:spot_base(job)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
self.size = size
|
||||||
yield(ya.readable_size(size))
|
yield(ya.readable_size(size))
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -45,7 +45,7 @@ function M:spot_base(_, selected)
|
||||||
while it do
|
while it do
|
||||||
local next, now = it:recv(), ya.time()
|
local next, now = it:recv(), ya.time()
|
||||||
if not next then
|
if not next then
|
||||||
self.sizes[url] = it.cha.is_dir and size
|
self.sizes[url] = it.cha.is_dir and size or nil
|
||||||
break
|
break
|
||||||
elseif now >= last + 0.1 then
|
elseif now >= last + 0.1 then
|
||||||
last, size, sum = now, size + next, sum + next
|
last, size, sum = now, size + next, sum + next
|
||||||
|
|
|
||||||
|
|
@ -15,15 +15,15 @@ impl Utils {
|
||||||
pub(super) fn co(lua: &Lua) -> mlua::Result<Function> {
|
pub(super) fn co(lua: &Lua) -> mlua::Result<Function> {
|
||||||
lua.create_function(|lua, f: Function| {
|
lua.create_function(|lua, f: Function| {
|
||||||
let thread = lua.create_thread(f)?;
|
let thread = lua.create_thread(f)?;
|
||||||
lua.create_async_function(move |lua, args: MultiValue| {
|
lua.create_async_function(move |lua, mut args: MultiValue| {
|
||||||
let thread = thread.clone();
|
let thread = thread.clone();
|
||||||
async move {
|
async move {
|
||||||
loop {
|
loop {
|
||||||
let values: MultiValue = thread.resume(&args)?;
|
let values: MultiValue = thread.resume(args)?;
|
||||||
if let Some(Value::LightUserData(ud)) = values.get(0)
|
if let Some(Value::LightUserData(ud)) = values.get(0)
|
||||||
&& *ud == Lua::poll_pending()
|
&& *ud == Lua::poll_pending()
|
||||||
{
|
{
|
||||||
lua.yield_with::<()>(values).await?;
|
args = lua.yield_with(values).await?;
|
||||||
} else {
|
} else {
|
||||||
return Ok(values);
|
return Ok(values);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue