|
|
|
@ -384,6 +384,84 @@ imv-msg "$IMV_PID" quit
|
|
|
|
|
|
|
|
|
|
</details>
|
|
|
|
|
|
|
|
|
|
### Text preview pane
|
|
|
|
|
|
|
|
|
|
Preview text files in a native xplr pane (should be fast enough).
|
|
|
|
|
|
|
|
|
|
<details>
|
|
|
|
|
<summary>Expand for details</summary>
|
|
|
|
|
|
|
|
|
|
- Author: [@sayanarijit][8]
|
|
|
|
|
- Requires: none
|
|
|
|
|
- Tested on: Linux
|
|
|
|
|
|
|
|
|
|
```lua
|
|
|
|
|
local function stat(node)
|
|
|
|
|
return node.mime_essence
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
local function read(path, lines)
|
|
|
|
|
local out = ""
|
|
|
|
|
local p = io.open(path)
|
|
|
|
|
|
|
|
|
|
if p == nil then
|
|
|
|
|
return stat(path)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
local i = 0
|
|
|
|
|
for line in p:lines() do
|
|
|
|
|
out = out .. line .. "\n"
|
|
|
|
|
if i == lines then
|
|
|
|
|
break
|
|
|
|
|
end
|
|
|
|
|
i = i + 1
|
|
|
|
|
end
|
|
|
|
|
p:close()
|
|
|
|
|
|
|
|
|
|
return out
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
xplr.config.layouts.builtin.default = {
|
|
|
|
|
Horizontal = {
|
|
|
|
|
config = {
|
|
|
|
|
constraints = {
|
|
|
|
|
{ Percentage = 60 },
|
|
|
|
|
{ Percentage = 40 },
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
splits = {
|
|
|
|
|
"Table",
|
|
|
|
|
{
|
|
|
|
|
CustomContent = {
|
|
|
|
|
title = "preview",
|
|
|
|
|
body = { DynamicParagraph = { render = "custom.render_layout" } },
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
xplr.fn.custom.render_layout = function(ctx)
|
|
|
|
|
local n = ctx.app.focused_node
|
|
|
|
|
|
|
|
|
|
if n.canonical then
|
|
|
|
|
n = n.canonical
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
if n then
|
|
|
|
|
if n.is_file and not n.is_symlink then
|
|
|
|
|
return read(n.absolute_path, ctx.layout_size.height)
|
|
|
|
|
else
|
|
|
|
|
return stat(n)
|
|
|
|
|
end
|
|
|
|
|
else
|
|
|
|
|
return ""
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
```
|
|
|
|
|
</details>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
## Also See:
|
|
|
|
|
|
|
|
|
|
- [Awesome Plugins][15]
|
|
|
|
|