It was meant for vifm. Ranger most likely doesn't have dialog but last I checked it had a --choose-file option to select a single file. Anyway, thanks for considering this feature.
Got it. In Vifm it will be -1 because there is also --on-choose and it should also be possible to constraint it. I still need to finalize it, but already have the implementation.
I mostly need the hjkl motions working from commandline mode.
How to use this:
local added = vifm.keys.add {
shortcut = "<a-j>",
modes = { "cmdline" },
description = "go up",
handler = function()
local c = vifm.currview().cursor
c.pos = c.pos + 1
end,
}
if not added then
vifm.sb.error("Failed to register Alt-j key")
end
local added = vifm.keys.add {
shortcut = "<a-k>",
modes = { "cmdline" },
description = "go down",
handler = function()
local c = vifm.currview().cursor
c.pos = c.pos - 1
end,
}
if not added then
vifm.sb.error("Failed to register Alt-k key")
end
local added = vifm.keys.add {
shortcut = "<a-h>",
modes = { "cmdline" },
description = "go to parent",
handler = function()
vifm.currview():cd("..")
end,
}
if not added then
vifm.sb.error("Failed to register Alt-h key")
end
local added = vifm.keys.add {
shortcut = "<a-l>",
modes = { "cmdline" },
description = "enter directory",
handler = function()
local v = vifm.currview()
local e = v:entry(v.currententry)
if e.type == 'dir' then
v:cd(e.name)
end
end,
}
if not added then
vifm.sb.error("Failed to register Alt-l key")
end
return {}
Also, completely unrelated but I am curious if there is a way to quit vifm printing some message to the stdout.
There is, but stdout needs to be redirected. Looks like this:
vifm.events.listen {
event = 'app.exit',
handler = function()
vifm.stdout():write('hello')
end
}