refactor: update for Yazi v25.2.26
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
--- @since 25.2.7
|
--- @since 25.2.26
|
||||||
|
|
||||||
local selected_or_hovered = ya.sync(function()
|
local selected_or_hovered = ya.sync(function()
|
||||||
local tab, paths = cx.active, {}
|
local tab, paths = cx.active, {}
|
||||||
@@ -13,7 +13,7 @@ end)
|
|||||||
|
|
||||||
return {
|
return {
|
||||||
entry = function()
|
entry = function()
|
||||||
ya.manager_emit("escape", { visual = true })
|
ya.mgr_emit("escape", { visual = true })
|
||||||
|
|
||||||
local urls = selected_or_hovered()
|
local urls = selected_or_hovered()
|
||||||
if #urls == 0 then
|
if #urls == 0 then
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
--- @since 25.2.7
|
--- @since 25.2.26
|
||||||
|
|
||||||
local function setup(_, opts)
|
local function setup(_, opts)
|
||||||
local type = opts and opts.type or ui.Border.ROUNDED
|
local type = opts and opts.type or ui.Border.ROUNDED
|
||||||
@@ -24,7 +24,7 @@ local function setup(_, opts)
|
|||||||
c[3]:pad(ui.Pad.y(1)),
|
c[3]:pad(ui.Pad.y(1)),
|
||||||
}
|
}
|
||||||
|
|
||||||
local style = THEME.manager.border_style
|
local style = th.mgr.border_style
|
||||||
self._base = ya.list_merge(self._base or {}, {
|
self._base = ya.list_merge(self._base or {}, {
|
||||||
ui.Border(ui.Border.ALL):area(self._area):type(type):style(style),
|
ui.Border(ui.Border.ALL):area(self._area):type(type):style(style),
|
||||||
ui.Bar(ui.Bar.RIGHT):area(self._chunks[1]):style(style),
|
ui.Bar(ui.Bar.RIGHT):area(self._chunks[1]):style(style),
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
--- @since 25.2.7
|
--- @since 25.2.26
|
||||||
--- @sync entry
|
--- @sync entry
|
||||||
|
|
||||||
local function entry(st)
|
local function entry(st)
|
||||||
@@ -14,12 +14,12 @@ local function entry(st)
|
|||||||
else
|
else
|
||||||
st.old = Tab.layout
|
st.old = Tab.layout
|
||||||
Tab.layout = function(self)
|
Tab.layout = function(self)
|
||||||
local all = MANAGER.ratio.parent + MANAGER.ratio.current
|
local r = rt.mgr.ratio
|
||||||
self._chunks = ui.Layout()
|
self._chunks = ui.Layout()
|
||||||
:direction(ui.Layout.HORIZONTAL)
|
:direction(ui.Layout.HORIZONTAL)
|
||||||
:constraints({
|
:constraints({
|
||||||
ui.Constraint.Ratio(MANAGER.ratio.parent, all),
|
ui.Constraint.Ratio(r.parent, r.parent + r.current),
|
||||||
ui.Constraint.Ratio(MANAGER.ratio.current, all),
|
ui.Constraint.Ratio(r.current, r.parent + r.current),
|
||||||
ui.Constraint.Length(1),
|
ui.Constraint.Length(1),
|
||||||
})
|
})
|
||||||
:split(self._area)
|
:split(self._area)
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
--- @since 25.2.7
|
--- @since 25.2.26
|
||||||
|
|
||||||
local AVAILABLE_CHARS = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789."
|
local AVAILABLE_CHARS = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789."
|
||||||
|
|
||||||
@@ -24,9 +24,9 @@ return {
|
|||||||
|
|
||||||
local kw = escape(cands[idx].on)
|
local kw = escape(cands[idx].on)
|
||||||
if changed(kw) then
|
if changed(kw) then
|
||||||
ya.manager_emit("find_do", { "^" .. kw })
|
ya.mgr_emit("find_do", { "^" .. kw })
|
||||||
else
|
else
|
||||||
ya.manager_emit("find_arrow", {})
|
ya.mgr_emit("find_arrow", {})
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
--- @since 25.2.7
|
--- @since 25.2.26
|
||||||
|
|
||||||
local M = {}
|
local M = {}
|
||||||
|
|
||||||
@@ -32,7 +32,7 @@ function M:peek(job)
|
|||||||
|
|
||||||
child:start_kill()
|
child:start_kill()
|
||||||
if job.skip > 0 and i < job.skip + limit then
|
if job.skip > 0 and i < job.skip + limit then
|
||||||
ya.manager_emit("peek", { math.max(0, i - limit), only_if = job.file.url, upper_bound = true })
|
ya.mgr_emit("peek", { math.max(0, i - limit), only_if = job.file.url, upper_bound = true })
|
||||||
else
|
else
|
||||||
ya.preview_widgets(job, { ui.Text(lines):area(job.area) })
|
ya.preview_widgets(job, { ui.Text(lines):area(job.area) })
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
--- @since 25.2.7
|
--- @since 25.2.26
|
||||||
|
|
||||||
local update = ya.sync(function(st, tags)
|
local update = ya.sync(function(st, tags)
|
||||||
for path, tag in pairs(tags) do
|
for path, tag in pairs(tags) do
|
||||||
@@ -76,7 +76,7 @@ end)
|
|||||||
|
|
||||||
local function entry(self, job)
|
local function entry(self, job)
|
||||||
assert(job.args[1] == "add" or job.args[1] == "remove", "Invalid action")
|
assert(job.args[1] == "add" or job.args[1] == "remove", "Invalid action")
|
||||||
ya.manager_emit("escape", { visual = true })
|
ya.mgr_emit("escape", { visual = true })
|
||||||
|
|
||||||
local cands = cands()
|
local cands = cands()
|
||||||
local choice = ya.which { cands = cands }
|
local choice = ya.which { cands = cands }
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
--- @since 25.2.7
|
--- @since 25.2.26
|
||||||
|
|
||||||
local FILES = {
|
local FILES = {
|
||||||
[".envrc"] = "text/plain",
|
[".envrc"] = "text/plain",
|
||||||
@@ -1096,7 +1096,7 @@ function M:fetch(job)
|
|||||||
end
|
end
|
||||||
|
|
||||||
if next(updates) then
|
if next(updates) then
|
||||||
ya.manager_emit("update_mimes", { updates = updates })
|
ya.mgr_emit("update_mimes", { updates = updates })
|
||||||
end
|
end
|
||||||
|
|
||||||
if #unknown > 0 then
|
if #unknown > 0 then
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
--- @since 25.2.7
|
--- @since 25.2.26
|
||||||
|
|
||||||
local toggle_ui = ya.sync(function(self)
|
local toggle_ui = ya.sync(function(self)
|
||||||
if self.children then
|
if self.children then
|
||||||
@@ -12,7 +12,7 @@ end)
|
|||||||
|
|
||||||
local subscribe = ya.sync(function(self)
|
local subscribe = ya.sync(function(self)
|
||||||
ps.unsub("mount")
|
ps.unsub("mount")
|
||||||
ps.sub("mount", function() ya.manager_emit("plugin", { self._id, "refresh" }) end)
|
ps.sub("mount", function() ya.mgr_emit("plugin", { self._id, "refresh" }) end)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
local update_partitions = ya.sync(function(self, partitions)
|
local update_partitions = ya.sync(function(self, partitions)
|
||||||
@@ -113,7 +113,7 @@ function M:entry(job)
|
|||||||
elseif run == "enter" then
|
elseif run == "enter" then
|
||||||
local active = active_partition()
|
local active = active_partition()
|
||||||
if active and active.dist then
|
if active and active.dist then
|
||||||
ya.manager_emit("cd", { active.dist })
|
ya.mgr_emit("cd", { active.dist })
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
tx2:send(run)
|
tx2:send(run)
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
--- @since 25.2.7
|
--- @since 25.2.26
|
||||||
--- @sync entry
|
--- @sync entry
|
||||||
|
|
||||||
local function setup(self, opts) self.open_multi = opts.open_multi end
|
local function setup(self, opts) self.open_multi = opts.open_multi end
|
||||||
|
|
||||||
local function entry(self)
|
local function entry(self)
|
||||||
local h = cx.active.current.hovered
|
local h = cx.active.current.hovered
|
||||||
ya.manager_emit(h and h.cha.is_dir and "enter" or "open", { hovered = not self.open_multi })
|
ya.mgr_emit(h and h.cha.is_dir and "enter" or "open", { hovered = not self.open_multi })
|
||||||
end
|
end
|
||||||
|
|
||||||
return { entry = entry, setup = setup }
|
return { entry = entry, setup = setup }
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
--- @since 25.2.7
|
--- @since 25.2.26
|
||||||
|
|
||||||
local hovered = ya.sync(function()
|
local hovered = ya.sync(function()
|
||||||
local h = cx.active.current.hovered
|
local h = cx.active.current.hovered
|
||||||
@@ -28,20 +28,20 @@ local function entry()
|
|||||||
while true do
|
while true do
|
||||||
local value, event = input:recv()
|
local value, event = input:recv()
|
||||||
if event ~= 1 and event ~= 3 then
|
if event ~= 1 and event ~= 3 then
|
||||||
ya.manager_emit("escape", { filter = true })
|
ya.mgr_emit("escape", { filter = true })
|
||||||
break
|
break
|
||||||
end
|
end
|
||||||
|
|
||||||
ya.manager_emit("filter_do", { value, smart = true })
|
ya.mgr_emit("filter_do", { value, smart = true })
|
||||||
|
|
||||||
local h = hovered()
|
local h = hovered()
|
||||||
if h.unique and h.is_dir then
|
if h.unique and h.is_dir then
|
||||||
ya.manager_emit("escape", { filter = true })
|
ya.mgr_emit("escape", { filter = true })
|
||||||
ya.manager_emit("enter", {})
|
ya.mgr_emit("enter", {})
|
||||||
input = prompt()
|
input = prompt()
|
||||||
elseif event == 1 then
|
elseif event == 1 then
|
||||||
ya.manager_emit("escape", { filter = true })
|
ya.mgr_emit("escape", { filter = true })
|
||||||
ya.manager_emit(h.is_dir and "enter" or "open", { h.url })
|
ya.mgr_emit(h.is_dir and "enter" or "open", { h.url })
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
--- @since 25.2.7
|
--- @since 25.2.26
|
||||||
--- @sync entry
|
--- @sync entry
|
||||||
|
|
||||||
local function entry(st, job)
|
local function entry(st, job)
|
||||||
local R = MANAGER.ratio
|
local R = rt.mgr.ratio
|
||||||
job = type(job) == "string" and { args = { job } } or job
|
job = type(job) == "string" and { args = { job } } or job
|
||||||
|
|
||||||
st.parent = st.parent and st.parent or R.parent
|
st.parent = st.parent and st.parent or R.parent
|
||||||
|
|||||||
Reference in New Issue
Block a user