refactor: remove compatibility code for Yazi 0.3
This commit is contained in:
@@ -154,10 +154,7 @@ local function setup(st, opts)
|
|||||||
end, opts.order)
|
end, opts.order)
|
||||||
end
|
end
|
||||||
|
|
||||||
local function fetch(self, job)
|
local function fetch(_, job)
|
||||||
-- TODO: remove this once Yazi 0.4 is released
|
|
||||||
job = job or self
|
|
||||||
|
|
||||||
local cwd = job.files[1].url:parent()
|
local cwd = job.files[1].url:parent()
|
||||||
local repo = root(cwd)
|
local repo = root(cwd)
|
||||||
if not repo then
|
if not repo then
|
||||||
|
|||||||
@@ -1,9 +1,6 @@
|
|||||||
local M = {}
|
local M = {}
|
||||||
|
|
||||||
function M:peek(job)
|
function M:peek(job)
|
||||||
-- TODO: remove this once Yazi 0.4 is released
|
|
||||||
job = job or self
|
|
||||||
|
|
||||||
local child, code = Command("lsar"):arg(tostring(job.file.url)):stdout(Command.PIPED):spawn()
|
local child, code = Command("lsar"):arg(tostring(job.file.url)):stdout(Command.PIPED):spawn()
|
||||||
if not child then
|
if not child then
|
||||||
return ya.err("spawn `lsar` command returns " .. tostring(code))
|
return ya.err("spawn `lsar` command returns " .. tostring(code))
|
||||||
@@ -39,19 +36,6 @@ function M:peek(job)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function M:seek(job)
|
function M:seek(job) require("code"):seek(job) end
|
||||||
-- TODO: remove this once Yazi 0.4 is released
|
|
||||||
local units = type(job) == "table" and job.units or job
|
|
||||||
job = type(job) == "table" and job or self
|
|
||||||
|
|
||||||
local h = cx.active.current.hovered
|
|
||||||
if h and h.url == job.file.url then
|
|
||||||
local step = math.floor(units * job.area.h / 10)
|
|
||||||
ya.manager_emit("peek", {
|
|
||||||
math.max(0, cx.active.preview.skip + step),
|
|
||||||
only_if = job.file.url,
|
|
||||||
})
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
return M
|
return M
|
||||||
|
|||||||
@@ -35,10 +35,7 @@ local function setup(st, opts)
|
|||||||
end, 500)
|
end, 500)
|
||||||
end
|
end
|
||||||
|
|
||||||
local function fetch(self, job)
|
local function fetch(_, job)
|
||||||
-- TODO: remove this once Yazi 0.4 is released
|
|
||||||
job = job or self
|
|
||||||
|
|
||||||
local paths = {}
|
local paths = {}
|
||||||
for _, file in ipairs(job.files) do
|
for _, file in ipairs(job.files) do
|
||||||
paths[#paths + 1] = tostring(file.url)
|
paths[#paths + 1] = tostring(file.url)
|
||||||
@@ -76,10 +73,7 @@ local cands = ya.sync(function(st)
|
|||||||
end)
|
end)
|
||||||
|
|
||||||
local function entry(self, job)
|
local function entry(self, job)
|
||||||
-- TODO: remove this once Yazi 0.4 is released
|
assert(job.args[1] == "add" or job.args[1] == "remove", "Invalid action")
|
||||||
local args = job.args or job
|
|
||||||
|
|
||||||
assert(args[1] == "add" or args[1] == "remove", "Invalid action")
|
|
||||||
ya.manager_emit("escape", { visual = true })
|
ya.manager_emit("escape", { visual = true })
|
||||||
|
|
||||||
local cands = cands()
|
local cands = cands()
|
||||||
@@ -88,7 +82,7 @@ local function entry(self, job)
|
|||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
local t = { args[1] == "remove" and "-r" or "-a", cands[choice].desc }
|
local t = { job.args[1] == "remove" and "-r" or "-a", cands[choice].desc }
|
||||||
local files = {}
|
local files = {}
|
||||||
for _, url in ipairs(selected_or_hovered()) do
|
for _, url in ipairs(selected_or_hovered()) do
|
||||||
t[#t + 1] = tostring(url)
|
t[#t + 1] = tostring(url)
|
||||||
|
|||||||
@@ -1060,10 +1060,6 @@ function M:setup(opts)
|
|||||||
end
|
end
|
||||||
|
|
||||||
function M:fetch(job)
|
function M:fetch(job)
|
||||||
-- TODO: remove this once Yazi 0.4 is released
|
|
||||||
local not_v4 = not job
|
|
||||||
job = job or self
|
|
||||||
|
|
||||||
local opts = options()
|
local opts = options()
|
||||||
local merged_files = ya.dict_merge(FILES, opts.with_files or {})
|
local merged_files = ya.dict_merge(FILES, opts.with_files or {})
|
||||||
local merged_exts = ya.dict_merge(EXTS, opts.with_exts or {})
|
local merged_exts = ya.dict_merge(EXTS, opts.with_exts or {})
|
||||||
@@ -1089,12 +1085,11 @@ function M:fetch(job)
|
|||||||
|
|
||||||
if next(updates) then
|
if next(updates) then
|
||||||
ya.manager_emit("update_mimes", { updates = updates })
|
ya.manager_emit("update_mimes", { updates = updates })
|
||||||
ya.manager_emit("update_mimetype", { updates = updates }) -- TODO: remove this
|
|
||||||
end
|
end
|
||||||
|
|
||||||
if #unknown > 0 then
|
if #unknown > 0 then
|
||||||
job.files = unknown
|
job.files = unknown
|
||||||
return not_v4 and require("mime").fetch(job) or require("mime"):fetch(job)
|
return require("mime"):fetch(job)
|
||||||
end
|
end
|
||||||
|
|
||||||
return 1
|
return 1
|
||||||
|
|||||||
@@ -1,13 +1,7 @@
|
|||||||
local function setup()
|
local function setup()
|
||||||
local old_layout = Tab.layout
|
local old_layout = Tab.layout
|
||||||
|
|
||||||
-- TODO: remove this check once v0.4 is released
|
|
||||||
if Status.redraw then
|
|
||||||
Status.redraw = function() return {} end
|
Status.redraw = function() return {} end
|
||||||
else
|
|
||||||
Status.render = function() return {} end
|
|
||||||
end
|
|
||||||
|
|
||||||
Tab.layout = function(self, ...)
|
Tab.layout = function(self, ...)
|
||||||
self._area = ui.Rect { x = self._area.x, y = self._area.y, w = self._area.w, h = self._area.h + 1 }
|
self._area = ui.Rect { x = self._area.x, y = self._area.y, w = self._area.w, h = self._area.h + 1 }
|
||||||
return old_layout(self, ...)
|
return old_layout(self, ...)
|
||||||
|
|||||||
Reference in New Issue
Block a user