2020-03-31 15:57:23 +00:00
|
|
|
local UI = require('opus.ui')
|
|
|
|
local Util = require('opus.util')
|
|
|
|
|
|
|
|
local shell = _ENV.shell
|
|
|
|
|
|
|
|
-- fileui [--path=path] [--exec=filename]
|
|
|
|
|
|
|
|
local page = UI.Page {
|
2020-04-05 02:56:53 +00:00
|
|
|
fileselect = UI.FileSelect { },
|
|
|
|
eventHandler = function(self, event)
|
|
|
|
if event.type == 'select_file' then
|
|
|
|
self.selected = event.file
|
2020-03-31 15:57:23 +00:00
|
|
|
UI:quit()
|
|
|
|
|
2020-04-05 02:56:53 +00:00
|
|
|
elseif event.type == 'select_cancel' then
|
2020-03-31 15:57:23 +00:00
|
|
|
UI:quit()
|
|
|
|
end
|
|
|
|
|
2020-04-05 02:56:53 +00:00
|
|
|
return UI.FileSelect.eventHandler(self, event)
|
|
|
|
end,
|
|
|
|
}
|
2020-03-31 15:57:23 +00:00
|
|
|
|
|
|
|
local _, args = Util.parse(...)
|
|
|
|
|
|
|
|
UI:setPage(page, args.path)
|
|
|
|
UI:start()
|
|
|
|
UI.term:setCursorBlink(false)
|
|
|
|
|
2020-04-05 02:56:53 +00:00
|
|
|
if args.exec and page.selected then
|
|
|
|
shell.openForegroundTab(string.format('%s %s', args.exec, page.selected))
|
2020-03-31 15:57:23 +00:00
|
|
|
return
|
|
|
|
end
|
|
|
|
|
2020-04-05 02:56:53 +00:00
|
|
|
-- print('selected: ' .. tostring(selected))
|
|
|
|
return page.selected
|