summaryrefslogtreecommitdiff
path: root/mac/.config/yazi/plugins.bak/piper.yazi/main.lua
diff options
context:
space:
mode:
authorTheSiahxyz <164138827+TheSiahxyz@users.noreply.github.com>2025-09-13 17:14:51 +0900
committerTheSiahxyz <164138827+TheSiahxyz@users.noreply.github.com>2025-09-13 17:14:51 +0900
commita3ed0a3cb36d192c37e040d0dfe57c42113f2161 (patch)
treec216d680c4bfbe2e53232af1496c9655e347d79b /mac/.config/yazi/plugins.bak/piper.yazi/main.lua
parent2e6d3671d0e01ff5751893075e7fc5c53b288f95 (diff)
updates
Diffstat (limited to 'mac/.config/yazi/plugins.bak/piper.yazi/main.lua')
-rw-r--r--mac/.config/yazi/plugins.bak/piper.yazi/main.lua70
1 files changed, 0 insertions, 70 deletions
diff --git a/mac/.config/yazi/plugins.bak/piper.yazi/main.lua b/mac/.config/yazi/plugins.bak/piper.yazi/main.lua
deleted file mode 100644
index aef08eb..0000000
--- a/mac/.config/yazi/plugins.bak/piper.yazi/main.lua
+++ /dev/null
@@ -1,70 +0,0 @@
---- @since 25.5.31
-
-local M = {}
-
-local function fail(job, s) ya.preview_widget(job, ui.Text.parse(s):area(job.area):wrap(ui.Wrap.YES)) end
-
-function M:peek(job)
- local child, err = Command("sh")
- :arg({ "-c", job.args[1], "sh", tostring(job.file.url) })
- :env("w", job.area.w)
- :env("h", job.area.h)
- :stdout(Command.PIPED)
- :stderr(Command.PIPED)
- :spawn()
-
- if not child then
- return fail(job, "sh: " .. err)
- end
-
- local limit = job.area.h
- local i, outs, errs = 0, {}, {}
- repeat
- local next, event = child:read_line()
- if event == 1 then
- errs[#errs + 1] = next
- elseif event ~= 0 then
- break
- end
-
- i = i + 1
- if i > job.skip then
- outs[#outs + 1] = next
- end
- until i >= job.skip + limit
-
- child:start_kill()
- if #errs > 0 then
- fail(job, table.concat(errs, ""))
- elseif job.skip > 0 and i < job.skip + limit then
- ya.emit("peek", { math.max(0, i - limit), only_if = job.file.url, upper_bound = true })
- else
- ya.preview_widget(job, M.format(job, outs))
- end
-end
-
-function M:seek(job) require("code"):seek(job) end
-
-function M.format(job, lines)
- local format = job.args.format
- if format ~= "url" then
- local s = table.concat(lines, ""):gsub("\r", ""):gsub("\t", string.rep(" ", rt.preview.tab_size))
- return ui.Text.parse(s):area(job.area)
- end
-
- for i = 1, #lines do
- lines[i] = lines[i]:gsub("[\r\n]+$", "")
-
- local icon = File({
- url = Url(lines[i]),
- cha = Cha { kind = lines[i]:sub(-1) == "/" and 1 or 0 },
- }):icon()
-
- if icon then
- lines[i] = ui.Line { ui.Span(" " .. icon.text .. " "):style(icon.style), lines[i] }
- end
- end
- return ui.Text(lines):area(job.area)
-end
-
-return M