better file select for debugger - native support for moonscript
This commit is contained in:
@@ -214,7 +214,7 @@ local page = UI.Page {
|
|||||||
breaks = UI.Tab {
|
breaks = UI.Tab {
|
||||||
title = 'Breakpoints',
|
title = 'Breakpoints',
|
||||||
index = 2,
|
index = 2,
|
||||||
menuBar = UI.MenuBar {
|
UI.MenuBar {
|
||||||
buttons = {
|
buttons = {
|
||||||
{ text = 'Toggle', event = 'toggle' },
|
{ text = 'Toggle', event = 'toggle' },
|
||||||
{ text = 'Remove', event = 'remove' },
|
{ text = 'Remove', event = 'remove' },
|
||||||
@@ -274,7 +274,7 @@ local page = UI.Page {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
menuBar = UI.MenuBar {
|
UI.MenuBar {
|
||||||
y = -1,
|
y = -1,
|
||||||
backgroundColor = 'primary',
|
backgroundColor = 'primary',
|
||||||
buttonClass = 'InverseButton',
|
buttonClass = 'InverseButton',
|
||||||
@@ -362,6 +362,43 @@ local page = UI.Page {
|
|||||||
y = '50%',
|
y = '50%',
|
||||||
modal = true,
|
modal = true,
|
||||||
enable = function() end,
|
enable = function() end,
|
||||||
|
getFiles = function()
|
||||||
|
local paths = { }
|
||||||
|
for _,v in pairs(Util.split(client.env.package.path, '(.-);')) do
|
||||||
|
v = v:match('(.+)%?') or ''
|
||||||
|
if v:sub(1, 1) ~= '/' then
|
||||||
|
v = fs.combine(fs.getDir(filename), v)
|
||||||
|
end
|
||||||
|
if fs.exists(v) and fs.isDir(v) then
|
||||||
|
paths[fs.combine(v, '')] = true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
local t = { }
|
||||||
|
for k in pairs(paths) do
|
||||||
|
local function recurse(dir)
|
||||||
|
local files = fs.list(dir)
|
||||||
|
for _,f in ipairs(files) do
|
||||||
|
local fullName = fs.combine(dir, f)
|
||||||
|
if fs.isDir(fullName) then
|
||||||
|
-- skip virtual dirs
|
||||||
|
if f ~= '.git' and fs.native.isDir(fullName) then
|
||||||
|
recurse(fullName)
|
||||||
|
end
|
||||||
|
elseif fullName:match('(.+)%.lua$') then
|
||||||
|
table.insert(t, {
|
||||||
|
name = f,
|
||||||
|
dir = dir,
|
||||||
|
lname = f:lower(),
|
||||||
|
fullName = fullName,
|
||||||
|
})
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
recurse(k)
|
||||||
|
end
|
||||||
|
return t
|
||||||
|
end,
|
||||||
show = function(self)
|
show = function(self)
|
||||||
UI.QuickSelect.enable(self)
|
UI.QuickSelect.enable(self)
|
||||||
self:focusFirst()
|
self:focusFirst()
|
||||||
|
|||||||
37
moonscript/autorun/startup.lua
Normal file
37
moonscript/autorun/startup.lua
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
local Map = require('opus.map')
|
||||||
|
|
||||||
|
local fs = _G.fs
|
||||||
|
local shell = _ENV.shell
|
||||||
|
|
||||||
|
local commands = Map.transpose {
|
||||||
|
'packages/moonscript/moon',
|
||||||
|
'packages/moonscript/moonc'
|
||||||
|
}
|
||||||
|
|
||||||
|
local function compatEnv(source)
|
||||||
|
local env = Map.shallowCopy(source._G)
|
||||||
|
Map.merge(env, source)
|
||||||
|
env._G = env
|
||||||
|
_G.requireInjector(env, 'packages/moon')
|
||||||
|
return env
|
||||||
|
end
|
||||||
|
|
||||||
|
shell.registerHandler(function(args, env)
|
||||||
|
if args[1]:match('(.+)%.moon$') then
|
||||||
|
return {
|
||||||
|
title = fs.getName(args[1]):match('([^%.]+)'),
|
||||||
|
path = 'packages/moonscript/moon',
|
||||||
|
args = args,
|
||||||
|
load = loadfile,
|
||||||
|
env = compatEnv(env),
|
||||||
|
}
|
||||||
|
end
|
||||||
|
local command = shell.resolveProgram(args[1]) or ''
|
||||||
|
return commands[command] and {
|
||||||
|
title = fs.getName(command),
|
||||||
|
path = command,
|
||||||
|
args = { table.unpack(args, 2) },
|
||||||
|
load = loadfile,
|
||||||
|
env = compatEnv(env),
|
||||||
|
}
|
||||||
|
end)
|
||||||
@@ -48,7 +48,7 @@ run = function()
|
|||||||
require("moonscript.version").print_version()
|
require("moonscript.version").print_version()
|
||||||
os.exit()
|
os.exit()
|
||||||
end
|
end
|
||||||
local script_fname = shell.resolve(opts.script)
|
local script_fname = shell.resolveProgram(opts.script)
|
||||||
args = {
|
args = {
|
||||||
unpack(arg, base + 1)
|
unpack(arg, base + 1)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user